Skip to content

feat: Output username and password for code server --dev #1193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 27, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Avoid data race on buffer by reading after exit
  • Loading branch information
mafredri committed Apr 27, 2022
commit e94fdaf4b8c3954d17cf55b4074532e8c4a61d14
11 changes: 6 additions & 5 deletions cli/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ func TestServer(t *testing.T) {
go func() {
err := root.ExecuteContext(ctx)
require.ErrorIs(t, err, context.Canceled)

// Verify that credentials were output to the terminal.
wantEmail := "email: admin@coder.com"
wantPassword := "password: password"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could export defaultDevUser so we could assert the output in tests

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's definitely an option, we discussed it a bit and I added a commit that this this but ultimately dropped it before the merge.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I should've read back before I commented!

assert.Contains(t, stdoutBuf.String(), wantEmail, "expected output %q; got no match", wantEmail)
assert.Contains(t, stdoutBuf.String(), wantPassword, "expected output %q; got no match", wantPassword)
}()
var token string
require.Eventually(t, func() bool {
Expand All @@ -92,11 +98,6 @@ func TestServer(t *testing.T) {
require.NoError(t, err)
parsed, err := url.Parse(accessURL)
require.NoError(t, err)
// Verify that credentials were output to the terminal.
wantEmail := "email: admin@coder.com"
wantPassword := "password: password"
assert.Contains(t, stdoutBuf.String(), wantEmail, "expected output %q; got no match", wantEmail)
assert.Contains(t, stdoutBuf.String(), wantPassword, "expected output %q; got no match", wantPassword)
client := codersdk.New(parsed)
client.SessionToken = token
_, err = client.User(ctx, codersdk.Me)
Expand Down