Download this file
| 1 | package equipotest |
| 2 | |
| 3 | import ( |
| 4 | "amadan.net/oficina/equipo/internal/equipo" |
| 5 | "net/http/httptest" |
| 6 | "strings" |
| 7 | "testing" |
| 8 | ) |
| 9 | |
| 10 | func TestExpiredConnectionShowsSignInAgain(t *testing.T) { |
| 11 | f := connectionStore(t) |
| 12 | f.choice(t, f.ids["claude"]) |
| 13 | f.reports[0].Available = false |
| 14 | f.reports[0].UnavailableReason = "account.sign_in_again" |
| 15 | executionMust(t, f.s.ReportConnections(connectionContext, f.principal, f.reports)) |
| 16 | f.denied(t, "Engineering", "") |
| 17 | mail := &capturingMailer{} |
| 18 | h, err := equipo.App(f.d, testConfig(testOrigin), mail, nil) |
| 19 | executionMust(t, err) |
| 20 | server := httptest.NewServer(h) |
| 21 | defer server.Close() |
| 22 | client := signinClient(t, server.URL) |
| 23 | signinEmail(t, client, server.URL, testOrigin, mail, ownerAddress) |
| 24 | res, err := client.Get(server.URL + "/connections") |
| 25 | executionMust(t, err) |
| 26 | body := readBody(t, res) |
| 27 | if res.StatusCode != 200 || !strings.Contains(body, "Sign in again") { |
| 28 | t.Fatal("expired connection has no sign-in state", res.StatusCode) |
| 29 | } |
| 30 | } |
| 31 | |