injectSystemActor is a test-only middleware that seeds an RBAC actor into the request context so handlers using api.Authorize do not panic via httpmw.UserAuthorization. Pair it with mockAuthorizer to short-circuit authorization in tests that focus on plumbing rather than RBAC.
(next http.Handler)
| 98 | // short-circuit authorization in tests that focus on plumbing rather |
| 99 | // than RBAC. |
| 100 | func injectSystemActor(next http.Handler) http.Handler { |
| 101 | return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) { |
| 102 | next.ServeHTTP(rw, r.WithContext(dbauthz.AsSystemRestricted(r.Context()))) |
| 103 | }) |
| 104 | } |
| 105 | |
| 106 | // runWatchChatGitWorkspaceLookupTest exercises the GetWorkspaceByID |
| 107 | // error branches in authorizeChatWorkspaceExec. The chat middleware |
nothing calls this directly
no test coverage detected