From d3c23a223c3f80647b5652687b0a0607e795999a Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 5 Aug 2025 10:28:54 +0200 Subject: [PATCH] e2e/global: TestPromptExitCode: group plugin preparation steps Use names for the plugin that don't refer to content-trust, as that's not related to this test. Make it slightly more clear which steps are preparation and which are the actual test. The test sometimes fails in the preparation step, and we could consider moving those separate and XFail the test if the preparation fails; Stderr: error pushing plugin: failed to do request: Head "https://registry:5000/v2/plugin-content-trust-upgrade/blobs/sha256:af932a31d4df3a2890f900bcf28e16cea87b2b440b8036ba86ab3418f3e50a35": http: server gave HTTP response to HTTPS client Signed-off-by: Sebastiaan van Stijn --- e2e/global/cli_test.go | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/e2e/global/cli_test.go b/e2e/global/cli_test.go index 89d4d56be4..534e88a067 100644 --- a/e2e/global/cli_test.go +++ b/e2e/global/cli_test.go @@ -145,13 +145,14 @@ func TestPromptExitCode(t *testing.T) { t.Helper() skip.If(t, versions.LessThan(environment.DaemonAPIVersion(t), "1.44")) + const plugin = "registry:5000/plugin-install-test:latest" + pluginDir := testutils.SetupPlugin(t, ctx) - - plugin := "registry:5000/plugin-content-trust-install:latest" - icmd.RunCommand("docker", "plugin", "create", plugin, pluginDir).Assert(t, icmd.Success) icmd.RunCmd(icmd.Command("docker", "plugin", "push", plugin), defaultCmdOpts...).Assert(t, icmd.Success) icmd.RunCmd(icmd.Command("docker", "plugin", "rm", "-f", plugin), defaultCmdOpts...).Assert(t, icmd.Success) + + // Test prompt to grant privileges. return icmd.Command("docker", "plugin", "install", plugin) }, }, @@ -161,18 +162,22 @@ func TestPromptExitCode(t *testing.T) { t.Helper() skip.If(t, versions.LessThan(environment.DaemonAPIVersion(t), "1.44")) + const plugin = "registry:5000/plugin-upgrade-test" + pluginLatestDir := testutils.SetupPlugin(t, ctx) - pluginNextDir := testutils.SetupPlugin(t, ctx) - - plugin := "registry:5000/plugin-content-trust-upgrade" - icmd.RunCommand("docker", "plugin", "create", plugin+":latest", pluginLatestDir).Assert(t, icmd.Success) - icmd.RunCommand("docker", "plugin", "create", plugin+":next", pluginNextDir).Assert(t, icmd.Success) icmd.RunCmd(icmd.Command("docker", "plugin", "push", plugin+":latest"), defaultCmdOpts...).Assert(t, icmd.Success) - icmd.RunCmd(icmd.Command("docker", "plugin", "push", plugin+":next"), defaultCmdOpts...).Assert(t, icmd.Success) icmd.RunCmd(icmd.Command("docker", "plugin", "rm", "-f", plugin+":latest"), defaultCmdOpts...).Assert(t, icmd.Success) + + pluginNextDir := testutils.SetupPlugin(t, ctx) + icmd.RunCommand("docker", "plugin", "create", plugin+":next", pluginNextDir).Assert(t, icmd.Success) + icmd.RunCmd(icmd.Command("docker", "plugin", "push", plugin+":next"), defaultCmdOpts...).Assert(t, icmd.Success) icmd.RunCmd(icmd.Command("docker", "plugin", "rm", "-f", plugin+":next"), defaultCmdOpts...).Assert(t, icmd.Success) + + // Using "--grant-all-permissions" to disable prompting for confirmation. icmd.RunCmd(icmd.Command("docker", "plugin", "install", "--disable", "--grant-all-permissions", plugin+":latest"), defaultCmdOpts...).Assert(t, icmd.Success) + + // Test prompting for upgrade. return icmd.Command("docker", "plugin", "upgrade", plugin+":latest", plugin+":next") }, },