// This case happends when the package-lock.json with property '"lockfileVersion": 1,' gets updated to version '"lockfileVersion": 2,' (from npm v6 to npm v7/v8).
// Seems like the compatibility upgrades may result in dependencies losing their integrity.
// We try to get the integrity from the cache index.
This case happends when the package-lock.json with property '"lockfileVersion": 1,' gets updated to version '"lockfileVersion": 2,' (from npm v6 to npm v7/v8).
Seems like the compatibility upgrades may result in dependencies losing their integrity.
We try to get the integrity from the cache index.
// This case happends when the package - lock . json with property ' " lockfileVersion " : 1 ' gets updated to version ' " lockfileVersion " : 2 ' ( from npm v6 to npm v7 / v8 ) . // Seems like the compatibility upgrades may result in dependencies losing their integrity . // We try to get the integrity from the cache index .
func TestDependencyWithNoIntegrity(t *testing.T) {
	npmVersion, _, err := GetNpmVersionAndExecPath(logger)
	assert.NoError(t, err)
	path, err := filepath.Abs(filepath.Join("..", "testdata"))
	assert.NoError(t, err)
	projectPath, cleanup := testdatautils.CreateNpmTest(t, path, "project2", true, npmVersion)
	defer cleanup()
	npmArgs := []string{"--cache=" + filepath.Join(projectPath, "tmpcache")}
	_, _, err = RunNpmCmd("npm", projectPath, Ci, npmArgs, logger)
	assert.NoError(t, err)
	dependencies, err := CalculateDependenciesList("npm", projectPath, "jfrogtest", npmArgs, logger)
	assert.NoError(t, err)
	var excpected []entities.Dependency
	assert.NoError(t, utils.Unmarshal(filepath.Join(projectPath, "excpected_dependencies_list.json"), &excpected))
	assert.True(t, entities.IsEqualDependencySlices(excpected, dependencies))
}
func TestDependencyWithNoIntegrity ( t * testing . T ) { npmVersion , _ , err := GetNpmVersionAndExecPath ( logger ) assert . NoError ( t , err ) path , err := filepath . Abs ( filepath . Join ( " " , " " ) ) assert . NoError ( t , err ) projectPath , cleanup := testdatautils . CreateNpmTest ( t , path , " " , true , npmVersion ) defer cleanup ( ) npmArgs := [ ] string { " " + filepath . Join ( projectPath , " " ) } _ , _ , err = RunNpmCmd ( " " , projectPath , Ci , npmArgs , logger ) assert . NoError ( t , err ) dependencies , err := CalculateDependenciesList ( " " , projectPath , " " , npmArgs , logger ) assert . NoError ( t , err ) var excpected [ ] entities . Dependency assert . NoError ( t , utils . Unmarshal ( filepath . Join ( projectPath , " " ) , & excpected ) ) assert . True ( t , entities . IsEqualDependencySlices ( excpected , dependencies ) ) }
This case happends when the package-lock.json with property '"lockfileVersion": 1,' gets updated to version '"lockfileVersion": 2,' (from npm v6 to npm v7/v8).
This case happends when the package - lock . json with property ' " lockfileVersion " : 1 ' gets updated to version ' " lockfileVersion " : 2 ' ( from npm v6 to npm v7 / v8 ) .
// Create the second npm project which has a transitive dependency without integrity (ansi-regex:5.0.0). // Run npm CI to create this special case where the 'ansi-regex:5.0.0' is missing the integrity. // Calculate dependencies. // Verify results.