Skip to content

Commit e26e6cb

Browse files
committed
make gen impl
1 parent c0671f5 commit e26e6cb

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

coderd/database/dbauthz/dbauthz.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,7 +1851,10 @@ func (q *querier) GetNotificationsSettings(ctx context.Context) (string, error)
18511851
}
18521852

18531853
func (q *querier) GetOAuth2GithubDefaultEligible(ctx context.Context) (bool, error) {
1854-
panic("not implemented")
1854+
if err := q.authorizeContext(ctx, policy.ActionRead, rbac.ResourceDeploymentConfig); err != nil {
1855+
return false, err
1856+
}
1857+
return q.db.GetOAuth2GithubDefaultEligible(ctx)
18551858
}
18561859

18571860
func (q *querier) GetOAuth2ProviderAppByID(ctx context.Context, id uuid.UUID) (database.OAuth2ProviderApp, error) {
@@ -4435,7 +4438,10 @@ func (q *querier) UpsertNotificationsSettings(ctx context.Context, value string)
44354438
}
44364439

44374440
func (q *querier) UpsertOAuth2GithubDefaultEligible(ctx context.Context, eligible bool) error {
4438-
panic("not implemented")
4441+
if err := q.authorizeContext(ctx, policy.ActionUpdate, rbac.ResourceDeploymentConfig); err != nil {
4442+
return err
4443+
}
4444+
return q.db.UpsertOAuth2GithubDefaultEligible(ctx, eligible)
44394445
}
44404446

44414447
func (q *querier) UpsertOAuthSigningKey(ctx context.Context, value string) error {

coderd/database/dbauthz/dbauthz_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4404,6 +4404,12 @@ func (s *MethodTestSuite) TestSystemFunctions() {
44044404
Value: "value",
44054405
}).Asserts(rbac.ResourceSystem, policy.ActionUpdate)
44064406
}))
4407+
s.Run("GetOAuth2GithubDefaultEligible", s.Subtest(func(db database.Store, check *expects) {
4408+
check.Args().Asserts(rbac.ResourceDeploymentConfig, policy.ActionRead).Errors(sql.ErrNoRows)
4409+
}))
4410+
s.Run("UpsertOAuth2GithubDefaultEligible", s.Subtest(func(db database.Store, check *expects) {
4411+
check.Args(true).Asserts(rbac.ResourceDeploymentConfig, policy.ActionUpdate)
4412+
}))
44074413
}
44084414

44094415
func (s *MethodTestSuite) TestNotifications() {

coderd/database/dbmem/dbmem.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ type data struct {
254254
announcementBanners []byte
255255
healthSettings []byte
256256
notificationsSettings []byte
257+
oauth2GithubDefaultEligible *bool
257258
applicationName string
258259
logoURL string
259260
appSecurityKey string
@@ -3528,8 +3529,14 @@ func (q *FakeQuerier) GetNotificationsSettings(_ context.Context) (string, error
35283529
return string(q.notificationsSettings), nil
35293530
}
35303531

3531-
func (q *FakeQuerier) GetOAuth2GithubDefaultEligible(ctx context.Context) (bool, error) {
3532-
panic("not implemented")
3532+
func (q *FakeQuerier) GetOAuth2GithubDefaultEligible(_ context.Context) (bool, error) {
3533+
q.mutex.RLock()
3534+
defer q.mutex.RUnlock()
3535+
3536+
if q.oauth2GithubDefaultEligible == nil {
3537+
return false, sql.ErrNoRows
3538+
}
3539+
return *q.oauth2GithubDefaultEligible, nil
35333540
}
35343541

35353542
func (q *FakeQuerier) GetOAuth2ProviderAppByID(_ context.Context, id uuid.UUID) (database.OAuth2ProviderApp, error) {
@@ -11151,8 +11158,12 @@ func (q *FakeQuerier) UpsertNotificationsSettings(_ context.Context, data string
1115111158
return nil
1115211159
}
1115311160

11154-
func (q *FakeQuerier) UpsertOAuth2GithubDefaultEligible(ctx context.Context, eligible bool) error {
11155-
panic("not implemented")
11161+
func (q *FakeQuerier) UpsertOAuth2GithubDefaultEligible(_ context.Context, eligible bool) error {
11162+
q.mutex.Lock()
11163+
defer q.mutex.Unlock()
11164+
11165+
q.oauth2GithubDefaultEligible = &eligible
11166+
return nil
1115611167
}
1115711168

1115811169
func (q *FakeQuerier) UpsertOAuthSigningKey(_ context.Context, value string) error {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy