Skip to content

Commit

Permalink
Set generated test password by env variable instead of constant value
Browse files Browse the repository at this point in the history
  • Loading branch information
vapopov committed Jan 16, 2025
1 parent 894aab9 commit 5961a09
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 2 additions & 3 deletions integration/autoupdate/tools/updater/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion integration/autoupdate/tools/updater/tsh/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion integration/autoupdate/tools/updater_tsh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 5961a09

Please sign in to comment.