oficina / sheets Public

The Keymail continuation says where it's going, and is tested

Review (Fable): the notice rendered an empty status line and no test
reached the page. The render is a method now, tested directly.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 1657f59b175ed6ff08bc372c0a468d88303723b0 parent 91e7f8c
2 files changed, +33 −10
  • internal/sheets/home.go +14 −10
  • internal/sheets/signin_door_test.go +19 −0

CI passed — run details

diff --git a/internal/sheets/home.go b/internal/sheets/home.go
index 219ab3a..32cea90 100644
--- a/internal/sheets/home.go
+++ b/internal/sheets/home.go
@@ -160,16 +160,20 @@ func (a *App) homeLocalComplete(w http.ResponseWriter, r *http.Request) {
a.homeRoutes.LocalComplete(w, r)
}
func (a *App) homeLocalBegin(w http.ResponseWriter, r *http.Request) {
- connect.OAuthContinuation(a.origin, a.handleBegin, func(w http.ResponseWriter, r *http.Request, destination string) {
- p := connect.OAuthPage(destination)
- // The page between the door and Keymail is the same card: the
- // refresh stays Home's (head), the body is the door's notice.
- a.render(w, r, "home_oauth", frame{parts: []string{p.Title}, signinPage: true}, http.StatusOK, homeOAuthView{
- Page: p,
- Door: chrome.SignInNotice{Icon: brand.Path("sheets"), App: "Sheets", Sky: sky.For(r.Host), Heading: p.Title,
- Link: &chrome.Link{Href: p.URL, Label: p.ActionLabel}},
- })
- })(w, r)
+ connect.OAuthContinuation(a.origin, a.handleBegin, a.renderHomeOAuth)(w, r)
+}
+
+// renderHomeOAuth is the page between the door and Keymail, and it is
+// the same card: the refresh stays Home's (head), the body is the
+// door's notice.
+func (a *App) renderHomeOAuth(w http.ResponseWriter, r *http.Request, destination string) {
+ p := connect.OAuthPage(destination)
+ a.render(w, r, "home_oauth", frame{parts: []string{p.Title}, signinPage: true}, http.StatusOK, homeOAuthView{
+ Page: p,
+ Door: chrome.SignInNotice{Icon: brand.Path("sheets"), App: "Sheets", Sky: sky.For(r.Host),
+ Heading: p.Title, Body: "Taking you to Keymail to finish signing in.",
+ Link: &chrome.Link{Href: p.URL, Label: p.ActionLabel}},
+ })
}
func (a *App) rejectDisabledHome(next http.Handler) http.Handler {
diff --git a/internal/sheets/signin_door_test.go b/internal/sheets/signin_door_test.go
index f74dc0a..37a78d5 100644
--- a/internal/sheets/signin_door_test.go
+++ b/internal/sheets/signin_door_test.go
@@ -1,6 +1,7 @@
package sheets
import (
+ "html"
"net/http"
"net/http/httptest"
"regexp"
@@ -37,3 +38,21 @@ func TestSignInPageIsTheDoor(t *testing.T) {
t.Error("sign-in page does not link sky.css")
}
}
+
+// The page between the door and Keymail is the door's notice, and still
+// carries Home's refresh to the destination.
+func TestKeymailContinuationIsTheDoor(t *testing.T) {
+ app := New(Config{})
+ const dest = "https://keymail.example.test/oauth/authorize?state=s"
+ rec := httptest.NewRecorder()
+ app.renderHomeOAuth(rec, httptest.NewRequest(http.MethodPost, "/signin", nil), dest)
+ body := html.UnescapeString(rec.Body.String())
+ for _, want := range []string{
+ `http-equiv="refresh"`, `content="0;url=` + dest + `"`, `href="` + dest + `"`,
+ "estilo-door", "estilo-sky-layer", "<span>Sheets</span>", "Taking you to Keymail",
+ } {
+ if !strings.Contains(body, want) {
+ t.Errorf("continuation lacks %q", want)
+ }
+ }
+}