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

Function TestInsertAPIKey_AsPrebuildsUser

coderd/database/dbauthz/dbauthz_test.go:6171–6184  ·  view source on GitHub ↗

Ensures that the prebuilds actor may never insert an api key.

(t *testing.T)

Source from the content-addressed store, hash-verified

6169
6170// Ensures that the prebuilds actor may never insert an api key.
6171func TestInsertAPIKey_AsPrebuildsUser(t *testing.T) {
6172 t.Parallel()
6173 prebuildsSubj := rbac.Subject{
6174 ID: database.PrebuildsSystemUserID.String(),
6175 }
6176 ctx := dbauthz.As(testutil.Context(t, testutil.WaitShort), prebuildsSubj)
6177 mDB := dbmock.NewMockStore(gomock.NewController(t))
6178 log := slogtest.Make(t, nil)
6179 mDB.EXPECT().Wrappers().Times(1).Return([]string{})
6180 dbz := dbauthz.New(mDB, nil, log, nil)
6181 faker := gofakeit.New(0)
6182 _, err := dbz.InsertAPIKey(ctx, testutil.Fake(t, faker, database.InsertAPIKeyParams{}))
6183 require.True(t, dbauthz.IsNotAuthorizedError(err))
6184}
6185
6186func (s *MethodTestSuite) TestAIBridge() {
6187 s.Run("InsertAIBridgeInterception", s.Mocked(func(db *dbmock.MockStore, faker *gofakeit.Faker, check *expects) {

Callers

nothing calls this directly

Calls 11

EXPECTMethod · 0.95
AsFunction · 0.92
ContextFunction · 0.92
NewMockStoreFunction · 0.92
NewFunction · 0.92
FakeFunction · 0.92
IsNotAuthorizedErrorFunction · 0.92
WrappersMethod · 0.65
NewMethod · 0.65
InsertAPIKeyMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected