Skip to content

Commit 00606bf

Browse files
committed
make gen impl
1 parent cd9c5e3 commit 00606bf

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
@@ -1846,7 +1846,10 @@ func (q *querier) GetNotificationsSettings(ctx context.Context) (string, error)
18461846
}
18471847

18481848
func (q *querier) GetOAuth2GithubDefaultEligible(ctx context.Context) (bool, error) {
1849-
panic("not implemented")
1849+
if err := q.authorizeContext(ctx, policy.ActionRead, rbac.ResourceDeploymentConfig); err != nil {
1850+
return false, err
1851+
}
1852+
return q.db.GetOAuth2GithubDefaultEligible(ctx)
18501853
}
18511854

18521855
func (q *querier) GetOAuth2ProviderAppByID(ctx context.Context, id uuid.UUID) (database.OAuth2ProviderApp, error) {
@@ -4440,7 +4443,10 @@ func (q *querier) UpsertNotificationsSettings(ctx context.Context, value string)
44404443
}
44414444

44424445
func (q *querier) UpsertOAuth2GithubDefaultEligible(ctx context.Context, eligible bool) error {
4443-
panic("not implemented")
4446+
if err := q.authorizeContext(ctx, policy.ActionUpdate, rbac.ResourceDeploymentConfig); err != nil {
4447+
return err
4448+
}
4449+
return q.db.UpsertOAuth2GithubDefaultEligible(ctx, eligible)
44444450
}
44454451

44464452
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
@@ -4405,6 +4405,12 @@ func (s *MethodTestSuite) TestSystemFunctions() {
44054405
Value: "value",
44064406
}).Asserts(rbac.ResourceSystem, policy.ActionUpdate)
44074407
}))
4408+
s.Run("GetOAuth2GithubDefaultEligible", s.Subtest(func(db database.Store, check *expects) {
4409+
check.Args().Asserts(rbac.ResourceDeploymentConfig, policy.ActionRead).Errors(sql.ErrNoRows)
4410+
}))
4411+
s.Run("UpsertOAuth2GithubDefaultEligible", s.Subtest(func(db database.Store, check *expects) {
4412+
check.Args(true).Asserts(rbac.ResourceDeploymentConfig, policy.ActionUpdate)
4413+
}))
44084414
}
44094415

44104416
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
@@ -3515,8 +3516,14 @@ func (q *FakeQuerier) GetNotificationsSettings(_ context.Context) (string, error
35153516
return string(q.notificationsSettings), nil
35163517
}
35173518

3518-
func (q *FakeQuerier) GetOAuth2GithubDefaultEligible(ctx context.Context) (bool, error) {
3519-
panic("not implemented")
3519+
func (q *FakeQuerier) GetOAuth2GithubDefaultEligible(_ context.Context) (bool, error) {
3520+
q.mutex.RLock()
3521+
defer q.mutex.RUnlock()
3522+
3523+
if q.oauth2GithubDefaultEligible == nil {
3524+
return false, sql.ErrNoRows
3525+
}
3526+
return *q.oauth2GithubDefaultEligible, nil
35203527
}
35213528

35223529
func (q *FakeQuerier) GetOAuth2ProviderAppByID(_ context.Context, id uuid.UUID) (database.OAuth2ProviderApp, error) {
@@ -11158,8 +11165,12 @@ func (q *FakeQuerier) UpsertNotificationsSettings(_ context.Context, data string
1115811165
return nil
1115911166
}
1116011167

11161-
func (q *FakeQuerier) UpsertOAuth2GithubDefaultEligible(ctx context.Context, eligible bool) error {
11162-
panic("not implemented")
11168+
func (q *FakeQuerier) UpsertOAuth2GithubDefaultEligible(_ context.Context, eligible bool) error {
11169+
q.mutex.Lock()
11170+
defer q.mutex.Unlock()
11171+
11172+
q.oauth2GithubDefaultEligible = &eligible
11173+
return nil
1116311174
}
1116411175

1116511176
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