MCPcopy Index your code
hub / github.com/coder/coder / dbauthzTestStore

Function dbauthzTestStore

coderd/mcp_internal_test.go:27–35  ·  view source on GitHub ↗

dbauthzTestStore wraps the test database with the same dbauthz layer used in production (coderd.go:370). Without it the test would not catch RBAC failures from the chatd subject; with it the test fails loudly if the elevation in OIDCAccessToken is removed or weakened.

(t *testing.T, db database.Store)

Source from the content-addressed store, hash-verified

25// catch RBAC failures from the chatd subject; with it the test fails
26// loudly if the elevation in OIDCAccessToken is removed or weakened.
27func dbauthzTestStore(t *testing.T, db database.Store) database.Store {
28 t.Helper()
29
30 authz := rbac.NewStrictCachingAuthorizer(prometheus.NewRegistry())
31 acs := &atomic.Pointer[dbauthz.AccessControlStore]{}
32 var tacs dbauthz.AccessControlStore = fakeAccessControlStore{}
33 acs.Store(&tacs)
34 return dbauthz.New(db, authz, testutil.Logger(t), acs)
35}
36
37// fakeAccessControlStore mirrors coderdtest.FakeAccessControlStore but is
38// inlined here to avoid an import cycle (coderdtest imports coderd).

Callers 1

TestOIDCMCPTokenSourceFunction · 0.85

Calls 5

NewFunction · 0.92
LoggerFunction · 0.92
HelperMethod · 0.65
StoreMethod · 0.45

Tested by

no test coverage detected