From 467305fcea0c8a66f18305028bbaecd9d60cf7c4 Mon Sep 17 00:00:00 2001 From: Alano Terblanche <18033717+Benehiko@users.noreply.github.com> Date: Fri, 29 Aug 2025 12:15:49 +0200 Subject: [PATCH] Test setAllowNegativex509 Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com> --- cli/command/cli_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/cli/command/cli_test.go b/cli/command/cli_test.go index 02e69044e..092fcad38 100644 --- a/cli/command/cli_test.go +++ b/cli/command/cli_test.go @@ -18,6 +18,7 @@ import ( "github.com/docker/cli/cli/config" "github.com/docker/cli/cli/config/configfile" + "github.com/docker/cli/cli/context/store" "github.com/docker/cli/cli/flags" "github.com/moby/moby/api/types" "github.com/moby/moby/client" @@ -352,3 +353,23 @@ func TestHooksEnabled(t *testing.T) { assert.Check(t, !cli.HooksEnabled()) }) } + +func TestAllowNegativex509(t *testing.T) { + t.Run("GODEBUG already set", func(t *testing.T) { + t.Setenv("GODEBUG", "val1,val2") + meta := store.Metadata{} + setAllowNegativex509(meta) + assert.Equal(t, "val1,val2", os.Getenv("GODEBUG")) + }) + t.Run("GODEBUG in context metadata can set env", func(t *testing.T) { + meta := store.Metadata{ + Metadata: DockerContext{ + AdditionalFields: map[string]any{ + "GODEBUG": "val1,val2=1", + }, + }, + } + setAllowNegativex509(meta) + assert.Equal(t, "val1,val2=1", os.Getenv("GODEBUG")) + }) +}