From 5961a090a1d959ab20e83c8ff258896e6cae9913 Mon Sep 17 00:00:00 2001 From: Vadym Popov Date: Thu, 16 Jan 2025 15:07:25 -0800 Subject: [PATCH] Set generated test password by env variable instead of constant value --- integration/autoupdate/tools/updater/modules.go | 5 ++--- integration/autoupdate/tools/updater/tsh/main.go | 2 +- integration/autoupdate/tools/updater_tsh_test.go | 6 +++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/integration/autoupdate/tools/updater/modules.go b/integration/autoupdate/tools/updater/modules.go index a146fc6031eda..28d03f42333df 100644 --- a/integration/autoupdate/tools/updater/modules.go +++ b/integration/autoupdate/tools/updater/modules.go @@ -35,9 +35,8 @@ import ( "github.com/gravitational/teleport/lib/tlsca" ) -const ( - TestPassword = "abc123def456" -) +// TestPassword is password generated during the test to login in test cluster. +const TestPassword = "UPDATER_TEST_PASSWORD" var ( version = teleport.Version diff --git a/integration/autoupdate/tools/updater/tsh/main.go b/integration/autoupdate/tools/updater/tsh/main.go index 2b878df1b2d3f..73abe237f6436 100644 --- a/integration/autoupdate/tools/updater/tsh/main.go +++ b/integration/autoupdate/tools/updater/tsh/main.go @@ -36,7 +36,7 @@ func main() { modules.SetInsecureTestMode(true) modules.SetModules(&updater.TestModules{}) - prompt.SetStdin(prompt.NewFakeReader().AddString(updater.TestPassword)) + prompt.SetStdin(prompt.NewFakeReader().AddString(os.Getenv(updater.TestPassword))) err := tsh.Run(ctx, os.Args[1:]) if err != nil { diff --git a/integration/autoupdate/tools/updater_tsh_test.go b/integration/autoupdate/tools/updater_tsh_test.go index d945fcdeffc56..661b6bec18df7 100644 --- a/integration/autoupdate/tools/updater_tsh_test.go +++ b/integration/autoupdate/tools/updater_tsh_test.go @@ -36,6 +36,7 @@ import ( "github.com/gravitational/teleport/integration/autoupdate/tools/updater" "github.com/gravitational/teleport/lib/autoupdate/tools" "github.com/gravitational/teleport/lib/client" + "github.com/gravitational/teleport/lib/utils" testserver "github.com/gravitational/teleport/tool/teleport/testenv" ) @@ -84,7 +85,10 @@ func TestAliasLoginWithUpdater(t *testing.T) { require.NoError(t, err) _, err = authService.UpsertAutoUpdateVersion(ctx, version) require.NoError(t, err) - err = authService.UpsertPassword("alice", []byte(updater.TestPassword)) + password, err := utils.CryptoRandomHex(6) + require.NoError(t, err) + t.Setenv(updater.TestPassword, password) + err = authService.UpsertPassword("alice", []byte(password)) require.NoError(t, err) // Assign alias to the login command for test cluster.