Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions internal/api/you_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

func TestYouDecodesBareObjectAndDataEnvelope(t *testing.T) {
for name, body := range map[string]string{
"bare": `{"publicId":"pe-abc123","email":"ada@example.com","name":"Ada","next":{"step":"connect_git","instruction":"Connect GitHub","url":"https://dash.example/git"},"optional":[{"step":"ssh_key","done":false,"instruction":"Add an SSH key","url":"https://dash.example/ssh"}]}`,
"data": `{"data":{"publicId":"pe-abc123","email":"ada@example.com","name":"Ada","next":{"step":"connect_git","instruction":"Connect GitHub","url":"https://dash.example/git"},"optional":[{"step":"ssh_key","done":false,"instruction":"Add an SSH key","url":"https://dash.example/ssh"}]}}`,
"bare": `{"publicId":"pe-abc123","email":"ada@example.com","name":"Ada","next":{"step":"connect_git","instruction":"Connect GitHub","url":"https://dash.example/git"},"optional":[{"step":"add_ssh_key","done":false,"instruction":"Add an SSH key","url":"https://dash.example/ssh"}]}`,
"data": `{"data":{"publicId":"pe-abc123","email":"ada@example.com","name":"Ada","next":{"step":"connect_git","instruction":"Connect GitHub","url":"https://dash.example/git"},"optional":[{"step":"add_ssh_key","done":false,"instruction":"Add an SSH key","url":"https://dash.example/ssh"}]}}`,
} {
t.Run(name, func(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(writer http.ResponseWriter, request *http.Request) {
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/auth/login/login_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func TestLoginTokenStdinKeepsTheTokenPath(t *testing.T) {
func TestLoginShowsAnOpenSSHKeyStep(t *testing.T) {
fake := newFakeAPI(t)
factory, _, _ := loginFactory(t, fake)
fake.you = `{"email":"ada@example.com","next":{"step":"connect_git","instruction":"Connect GitHub","url":"https://dash.example/git"},"optional":[{"step":"ssh_key","done":false,"instruction":"Add an SSH key","url":"https://dash.example/ssh"}]}`
fake.you = `{"email":"ada@example.com","next":{"step":"connect_git","instruction":"Connect GitHub","url":"https://dash.example/git"},"optional":[{"step":"add_ssh_key","done":false,"instruction":"Add an SSH key","url":"https://dash.example/ssh"}]}`

output, err := executeLogin(t, factory, fake.URL)
if err != nil {
Expand All @@ -286,8 +286,8 @@ func TestLoginShowsAnOpenSSHKeyStep(t *testing.T) {
}

for _, you := range []string{
`{"email":"ada@example.com","next":null,"optional":[{"step":"ssh_key","done":true,"instruction":"Add an SSH key","url":"https://dash.example/ssh"}]}`,
`{"email":"ada@example.com","next":{"step":"ssh_key","instruction":"Add an SSH key","url":"https://dash.example/ssh"},"optional":[{"step":"ssh_key","done":false,"instruction":"Add an SSH key","url":"https://dash.example/ssh"}]}`,
`{"email":"ada@example.com","next":null,"optional":[{"step":"add_ssh_key","done":true,"instruction":"Add an SSH key","url":"https://dash.example/ssh"}]}`,
`{"email":"ada@example.com","next":{"step":"add_ssh_key","instruction":"Add an SSH key","url":"https://dash.example/ssh"},"optional":[{"step":"add_ssh_key","done":false,"instruction":"Add an SSH key","url":"https://dash.example/ssh"}]}`,
} {
fake.mu.Lock()
fake.you = you
Expand Down
4 changes: 2 additions & 2 deletions internal/cmdutil/next_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ func TestWriteOpenStepFallsBackAndStripsControl(t *testing.T) {
}
for instruction, want := range cases {
var out bytes.Buffer
you := api.You{Optional: []api.OptionalStep{{Step: "ssh_key", Instruction: instruction, URL: &url}}}
if err := WriteOpenStep(&out, you, "ssh_key", "Add an SSH key"); err != nil || out.String() != want {
you := api.You{Optional: []api.OptionalStep{{Step: "add_ssh_key", Instruction: instruction, URL: &url}}}
if err := WriteOpenStep(&out, you, "add_ssh_key", "Add an SSH key"); err != nil || out.String() != want {
t.Errorf("WriteOpenStep(%q) = %q, %v; want %q", instruction, out.String(), err, want)
}
}
Expand Down
6 changes: 3 additions & 3 deletions internal/sshexec/diagnose.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ const (
)

// SSHKeyStep is the optional /v1/you step that is done once the account has an SSH key.
const SSHKeyStep = "ssh_key"
const SSHKeyStep = "add_ssh_key"

// SSHKeyInstruction stands in when the API gives the ssh_key step no instruction.
// SSHKeyInstruction stands in when the API gives the add_ssh_key step no instruction.
const SSHKeyInstruction = "Add an SSH key"

// keygen is the command that creates a key the dashboard accepts.
Expand Down Expand Up @@ -156,7 +156,7 @@ func Explain(ctx context.Context, err error, account Account) error {
return err
}

// AccountKey reads the ssh_key step from /v1/you: KeyMissing while it is open, with the URL of the step.
// AccountKey reads the add_ssh_key step from /v1/you: KeyMissing while it is open, with the URL of the step.
func AccountKey(ctx context.Context, account Account) (KeyState, string) {
you, err := account.You(ctx)
if err != nil {
Expand Down