Ensures that the prebuilds actor may never insert an api key.
(t *testing.T)
| 6169 | |
| 6170 | // Ensures that the prebuilds actor may never insert an api key. |
| 6171 | func 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 | |
| 6186 | func (s *MethodTestSuite) TestAIBridge() { |
| 6187 | s.Run("InsertAIBridgeInterception", s.Mocked(func(db *dbmock.MockStore, faker *gofakeit.Faker, check *expects) { |
nothing calls this directly
no test coverage detected