Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite26e6cb

Browse files
committed
make gen impl
1 parentc0671f5 commite26e6cb

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+
iferr:=q.authorizeContext(ctx,policy.ActionRead,rbac.ResourceDeploymentConfig);err!=nil {
1855+
returnfalse,err
1856+
}
1857+
returnq.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,eligiblebool)error {
4438-
panic("not implemented")
4441+
iferr:=q.authorizeContext(ctx,policy.ActionUpdate,rbac.ResourceDeploymentConfig);err!=nil {
4442+
returnerr
4443+
}
4444+
returnq.db.UpsertOAuth2GithubDefaultEligible(ctx,eligible)
44394445
}
44404446

44414447
func (q*querier)UpsertOAuthSigningKey(ctx context.Context,valuestring)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
applicationNamestring
258259
logoURLstring
259260
appSecurityKeystring
@@ -3528,8 +3529,14 @@ func (q *FakeQuerier) GetNotificationsSettings(_ context.Context) (string, error
35283529
returnstring(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+
deferq.mutex.RUnlock()
3535+
3536+
ifq.oauth2GithubDefaultEligible==nil {
3537+
returnfalse,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
returnnil
1115211159
}
1115311160

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

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp