package slidestest import ( "net/http" "net/url" "strings" "testing" slides "amadan.net/oficina/slides/internal/slides" ) // TestSignedOutIsRedirectedToSignin: "/" is behind the session gate, // and a signed-out page request lands on the sign-in page rather than // on an empty screen or a bare 403. func TestSignedOutIsRedirectedToSignin(t *testing.T) { rec := get(t, newApp(t), "/") if rec.Code != http.StatusSeeOther { t.Fatalf("GET / signed out: status %d, want %d", rec.Code, http.StatusSeeOther) } if loc := rec.Header().Get("Location"); !strings.HasPrefix(loc, "/signin") { t.Errorf("GET / signed out: Location = %q, want a redirect to /signin", loc) } } // TestSigninPageIsPublic: the front door has to be reachable signed // out, or nobody could ever get in. func TestSigninPageIsPublic(t *testing.T) { rec := get(t, newApp(t), "/signin") if rec.Code != http.StatusOK { t.Fatalf("GET /signin signed out: status %d, want 200", rec.Code) } body := rec.Body.String() if !strings.Contains(body, `name="address"`) { t.Errorf("GET /signin: no address field in the form:\n%s", body) } // A real