MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestKillSwitchRequiresAdmin

Function TestKillSwitchRequiresAdmin

controlplane/admin/kill_switch_test.go:189–209  ·  view source on GitHub ↗

TestKillSwitchRequiresAdmin: all three actions are POSTs, so RoleGate (applied at the group level in production) rejects a viewer with 403.

(t *testing.T)

Source from the content-addressed store, hash-verified

187// TestKillSwitchRequiresAdmin: all three actions are POSTs, so RoleGate (applied
188// at the group level in production) rejects a viewer with 403.
189func TestKillSwitchRequiresAdmin(t *testing.T) {
190 gin.SetMode(gin.TestMode)
191 r := gin.New()
192 grp := r.Group("/api/v1")
193 grp.Use(func(c *gin.Context) {
194 c.Set(ctxIdentityKey, &Identity{Email: "viewer@posthog.com", Role: RoleViewer})
195 })
196 grp.Use(RoleGate())
197 registerLiveAPI(grp, &fakeLiveInfo{}, &fakePeerFetcher{}, &fakeUserAdmin{})
198
199 for _, p := range []string{
200 "/api/v1/orgs/acme/users/bob/kill",
201 "/api/v1/orgs/acme/users/bob/disable",
202 "/api/v1/orgs/acme/users/bob/enable",
203 } {
204 code, _ := doPost(t, r, p)
205 if code != http.StatusForbidden {
206 t.Fatalf("%s as viewer: expected 403, got %d", p, code)
207 }
208 }
209}

Callers

nothing calls this directly

Calls 3

RoleGateFunction · 0.85
registerLiveAPIFunction · 0.85
doPostFunction · 0.85

Tested by

no test coverage detected