Cover live grant and session revocation through TeamMode router
1 file changed,
+34
−0
internal/docs/team_stream_test.go+34 −0
CI passed — run details
diff --git a/internal/docs/team_stream_test.go b/internal/docs/team_stream_test.go| index d20255a..13bfea1 100644 |
| --- a/internal/docs/team_stream_test.go |
| +++ b/internal/docs/team_stream_test.go |
| @@ -7,6 +7,7 @@ import ( |
| "io" |
| "net/http" |
| "net/http/httptest" |
| + "net/url" |
| "strings" |
| "testing" |
| "time" |
| @@ -117,3 +118,36 @@ func TestTeamStreamHealthyPublicationClosesOriginalLeaseAndReconnects(t *testing |
| fresh := teamOpenActualStream(t, f, b, srv) |
| fresh.Body.Close() |
| } |
| + |
| +func TestTeamStreamGuestGrantAndActualSessionRevocation(t *testing.T) { |
| + for _, reason := range []string{"grant", "session"} { |
| + t.Run(reason, func(t *testing.T) { |
| + f := newTeamRouterFixture(t) |
| + guest := f.browser() |
| + guest.localSignin(t, "alice@example.com") |
| + owner := f.browser() |
| + owner.localSignin(t, "bob@example.com") |
| + owner.linkProof(t, teamSubject('b'), "bob@example.com") |
| + routerRedirect(t, owner.do("POST", "/account/home/confirm", ""), "/") |
| + streamDurations(t, f.app, 30*time.Millisecond, 5*time.Second) |
| + srv := httptest.NewServer(f.app.Handler()) |
| + defer srv.Close() |
| + shared := *f |
| + shared.own = f.shared |
| + res := teamOpenActualStream(t, &shared, guest, srv) |
| + defer res.Body.Close() |
| + if reason == "grant" { |
| + routerRedirect(t, owner.do("POST", "/d/"+f.shared.Sqid+"/share/revoke", url.Values{"address": {"alice@example.com"}}.Encode()), "/d/"+f.shared.Sqid+"/share") |
| + } else { |
| + routerRedirect(t, guest.do("POST", "/signout", ""), "/signed-out") |
| + } |
| + done := make(chan struct{}) |
| + go func() { io.Copy(io.Discard, res.Body); close(done) }() |
| + select { |
| + case <-done: |
| + case <-time.After(time.Second): |
| + t.Fatal("live stream survived actual " + reason + " revocation") |
| + } |
| + }) |
| + } |
| +} |