| 1 | package memoria |
| 2 | |
| 3 | import ( |
| 4 | "net/url" |
| 5 | "testing" |
| 6 | ) |
| 7 | |
| 8 | // The route-driven test (memoriatest.TestSigninPageSaysWhatHappened) |
| 9 | // follows every ?err= a test can reach through the real handlers. Two it |
| 10 | // cannot: ?err=keymail needs a keymail round trip to fail after the |
| 11 | // pending cookie verified, and ?err=1 needs signin.Begin to fail for a |
| 12 | // reason other than rate or address. Both are rastrillo's words |
| 13 | // (auth/handlers.go, v0.23.0), read off the source, not guessed. A code |
| 14 | // the page does not know still says something: silence is the bug. |
| 15 | func TestSigninOutcomeCoversTheCodesNoRouteTestReaches(t *testing.T) { |
| 16 | for _, c := range []struct { |
| 17 | query, kind string |
| 18 | }{ |
| 19 | {"force=1&err=keymail", "danger"}, |
| 20 | {"err=1", "danger"}, |
| 21 | {"err=some-future-code", "danger"}, |
| 22 | {"reauth=1", "warn"}, |
| 23 | } { |
| 24 | q, _ := url.ParseQuery(c.query) |
| 25 | msg, kind := signinOutcome(q) |
| 26 | if msg == "" || kind != c.kind { |
| 27 | t.Errorf("?%s: got (%q, %q), want a %s sentence", c.query, msg, kind, c.kind) |
| 28 | } |
| 29 | } |
| 30 | if msg, _ := signinOutcome(url.Values{}); msg != "" { |
| 31 | t.Errorf("a plain visit says %q", msg) |
| 32 | } |
| 33 | } |
| 34 | |