diff --git a/internal/api/you_test.go b/internal/api/you_test.go index 00c9a79..633b995 100644 --- a/internal/api/you_test.go +++ b/internal/api/you_test.go @@ -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) { diff --git a/internal/cmd/auth/login/login_test.go b/internal/cmd/auth/login/login_test.go index 7b32235..9aae84d 100644 --- a/internal/cmd/auth/login/login_test.go +++ b/internal/cmd/auth/login/login_test.go @@ -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 { @@ -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 diff --git a/internal/cmdutil/next_test.go b/internal/cmdutil/next_test.go index 95bd423..7d541f1 100644 --- a/internal/cmdutil/next_test.go +++ b/internal/cmdutil/next_test.go @@ -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) } } diff --git a/internal/sshexec/diagnose.go b/internal/sshexec/diagnose.go index 7e87eca..ef99099 100644 --- a/internal/sshexec/diagnose.go +++ b/internal/sshexec/diagnose.go @@ -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. @@ -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 {