diff --git a/e2e/auth_test.go b/e2e/auth_test.go index 05a4c9b4..944f401a 100644 --- a/e2e/auth_test.go +++ b/e2e/auth_test.go @@ -37,8 +37,9 @@ func TestSnykAuthentication(t *testing.T) { homeDir, cleanFunction := createSnykConfFile(t, "") defer cleanFunction() - cmd, _, cleanup := dockerCli.createTestCmd() + cmd, configDir, cleanup := dockerCli.createTestCmd() defer cleanup() + createScanConfigFile(t, configDir) token := os.Getenv("E2E_TEST_AUTH_TOKEN") assert.Assert(t, token != "", "E2E_TEST_AUTH_TOKEN needs to be filled") @@ -67,8 +68,9 @@ func TestAuthenticationFlagFailsWithImage(t *testing.T) { } func TestAuthenticationChecksToken(t *testing.T) { - cmd, _, cleanup := dockerCli.createTestCmd() + cmd, configDir, cleanup := dockerCli.createTestCmd() defer cleanup() + createScanConfigFile(t, configDir) cmd.Command = dockerCli.Command("scan", "--accept-license", "--login", "--token", "invalid-token") icmd.RunCmd(cmd).Assert(t, icmd.Expected{ diff --git a/e2e/optin_test.go b/e2e/optin_test.go index 1eb2989a..2ae46303 100644 --- a/e2e/optin_test.go +++ b/e2e/optin_test.go @@ -65,6 +65,7 @@ Version:`)) func TestRefuseOptinWithDisableFlag(t *testing.T) { cmd, configDir, cleanup := dockerCli.createTestCmd() defer cleanup() + createScanConfigFile(t, configDir) // docker scan --version should exit immediately cmd.Command = dockerCli.Command("scan", "--reject-license", "--version") diff --git a/e2e/scan_test.go b/e2e/scan_test.go index 9303b28e..f9a13edb 100644 --- a/e2e/scan_test.go +++ b/e2e/scan_test.go @@ -49,6 +49,7 @@ func TestScanFailsNoAuthentication(t *testing.T) { cmd, configDir, cleanup := dockerCli.createTestCmd() defer cleanup() + createScanConfigFile(t, configDir) // write dockerCli config with authentication to a registry which isn't Hub patchConfig(t, configDir, "com.example.registry", "invalid-user", "invalid-password") @@ -66,8 +67,9 @@ func TestScanFailsWithCleanMessage(t *testing.T) { _, cleanFunction := createSnykConfFile(t, "") defer cleanFunction() - cmd, _, cleanup := dockerCli.createTestCmd() + cmd, configDir, cleanup := dockerCli.createTestCmd() defer cleanup() + createScanConfigFile(t, configDir) cmd.Command = dockerCli.Command("scan", "--accept-license", "example:image") icmd.RunCmd(cmd).Assert(t, icmd.Expected{ diff --git a/e2e/version_test.go b/e2e/version_test.go index d6ea0151..a9144ff6 100644 --- a/e2e/version_test.go +++ b/e2e/version_test.go @@ -93,15 +93,19 @@ Provider: %s } func TestVersionWithoutSnykOrConfig(t *testing.T) { - cmd, _, cleanup := dockerCli.createTestCmd() + cmd, configDir, cleanup := dockerCli.createTestCmd() defer cleanup() // docker scan --version should fail with a clean error cmd.Command = dockerCli.Command("scan", "--accept-license", "--version") - icmd.RunCmd(cmd).Assert(t, icmd.Expected{ + output := icmd.RunCmd(cmd).Assert(t, icmd.Expected{ ExitCode: 1, - Err: "could not find Snyk binary", - }) + }).Combined() + expected := fmt.Sprintf( + `failed to read docker scan configuration file. Please restart Docker Desktop: open %s/scan/config.json: no such file or directory +`, + configDir) + assert.Equal(t, output, expected) } func getProviderVersion(env string) string {