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

Commitb9f4ea6

Browse files
committed
Self-review, appeasing CI
Signed-off-by: Danny Kopping <danny@coder.com>
1 parent20e55d5 commitb9f4ea6

File tree

12 files changed

+106
-56
lines changed

12 files changed

+106
-56
lines changed

‎coderd/database/dbauthz/dbauthz.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,11 +1474,11 @@ func (q *querier) GetNotificationMessagesByStatus(ctx context.Context, arg datab
14741474
returnq.db.GetNotificationMessagesByStatus(ctx,arg)
14751475
}
14761476

1477-
func (q*querier)GetNotificationTemplateById(ctx context.Context,id uuid.UUID) (database.NotificationTemplate,error) {
1477+
func (q*querier)GetNotificationTemplateByID(ctx context.Context,id uuid.UUID) (database.NotificationTemplate,error) {
14781478
iferr:=q.authorizeContext(ctx,policy.ActionRead,rbac.ResourceNotificationTemplate);err!=nil {
14791479
return database.NotificationTemplate{},err
14801480
}
1481-
returnq.db.GetNotificationTemplateById(ctx,id)
1481+
returnq.db.GetNotificationTemplateByID(ctx,id)
14821482
}
14831483

14841484
func (q*querier)GetNotificationTemplatesByKind(ctx context.Context,kind database.NotificationTemplateKind) ([]database.NotificationTemplate,error) {
@@ -3033,12 +3033,12 @@ func (q *querier) UpdateMemberRoles(ctx context.Context, arg database.UpdateMemb
30333033
returnq.db.UpdateMemberRoles(ctx,arg)
30343034
}
30353035

3036-
func (q*querier)UpdateNotificationTemplateMethodById(ctx context.Context,arg database.UpdateNotificationTemplateMethodByIdParams) (database.NotificationTemplate,error) {
3036+
func (q*querier)UpdateNotificationTemplateMethodByID(ctx context.Context,arg database.UpdateNotificationTemplateMethodByIDParams) (database.NotificationTemplate,error) {
30373037
// TODO: how to restrict this to admins?
30383038
iferr:=q.authorizeContext(ctx,policy.ActionUpdate,rbac.ResourceNotificationTemplate);err!=nil {
30393039
return database.NotificationTemplate{},err
30403040
}
3041-
returnq.db.UpdateNotificationTemplateMethodById(ctx,arg)
3041+
returnq.db.UpdateNotificationTemplateMethodByID(ctx,arg)
30423042
}
30433043

30443044
func (q*querier)UpdateOAuth2ProviderAppByID(ctx context.Context,arg database.UpdateOAuth2ProviderAppByIDParams) (database.OAuth2ProviderApp,error) {

‎coderd/database/dbauthz/dbauthz_test.go‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"cdr.dev/slog"
1717

1818
"github.com/coder/coder/v2/coderd/database/db2sdk"
19+
"github.com/coder/coder/v2/coderd/notifications"
1920
"github.com/coder/coder/v2/coderd/rbac/policy"
2021
"github.com/coder/coder/v2/codersdk"
2122

@@ -2555,6 +2556,10 @@ func (s *MethodTestSuite) TestSystemFunctions() {
25552556
AgentID:uuid.New(),
25562557
}).Asserts(tpl,policy.ActionCreate)
25572558
}))
2559+
}
2560+
2561+
func (s*MethodTestSuite)TestNotifications() {
2562+
// System functions
25582563
s.Run("AcquireNotificationMessages",s.Subtest(func(db database.Store,check*expects) {
25592564
// TODO: update this test once we have a specific role for notifications
25602565
check.Args(database.AcquireNotificationMessagesParams{}).Asserts(rbac.ResourceSystem,policy.ActionUpdate)
@@ -2590,6 +2595,40 @@ func (s *MethodTestSuite) TestSystemFunctions() {
25902595
Limit:10,
25912596
}).Asserts(rbac.ResourceSystem,policy.ActionRead)
25922597
}))
2598+
2599+
// Notification templates
2600+
s.Run("GetNotificationTemplateByID",s.Subtest(func(db database.Store,check*expects) {
2601+
user:=dbgen.User(s.T(),db, database.User{})
2602+
check.Args(user.ID).Asserts(rbac.ResourceNotificationTemplate,policy.ActionRead).
2603+
Errors(dbmem.ErrUnimplemented)
2604+
}))
2605+
s.Run("GetNotificationTemplatesByKind",s.Subtest(func(db database.Store,check*expects) {
2606+
check.Args(database.NotificationTemplateKindSystem).
2607+
Asserts(rbac.ResourceNotificationTemplate,policy.ActionRead).
2608+
Errors(dbmem.ErrUnimplemented)
2609+
}))
2610+
s.Run("UpdateNotificationTemplateMethodByID",s.Subtest(func(db database.Store,check*expects) {
2611+
check.Args(database.UpdateNotificationTemplateMethodByIDParams{
2612+
Method: database.NullNotificationMethod{NotificationMethod:database.NotificationMethodWebhook,Valid:true},
2613+
ID:notifications.TemplateWorkspaceDormant,
2614+
}).Asserts(rbac.ResourceNotificationTemplate,policy.ActionUpdate).
2615+
Errors(dbmem.ErrUnimplemented)
2616+
}))
2617+
2618+
// Notification preferences
2619+
s.Run("GetUserNotificationPreferences",s.Subtest(func(db database.Store,check*expects) {
2620+
user:=dbgen.User(s.T(),db, database.User{})
2621+
check.Args(user.ID).
2622+
Asserts(rbac.ResourceNotificationPreference.WithOwner(user.ID.String()),policy.ActionRead)
2623+
}))
2624+
s.Run("UpdateUserNotificationPreferences",s.Subtest(func(db database.Store,check*expects) {
2625+
user:=dbgen.User(s.T(),db, database.User{})
2626+
check.Args(database.UpdateUserNotificationPreferencesParams{
2627+
UserID:user.ID,
2628+
NotificationTemplateIds: []uuid.UUID{notifications.TemplateWorkspaceAutoUpdated,notifications.TemplateWorkspaceDeleted},
2629+
Disableds: []bool{true,false},
2630+
}).Asserts(rbac.ResourceNotificationPreference.WithOwner(user.ID.String()),policy.ActionUpdate)
2631+
}))
25932632
}
25942633

25952634
func (s*MethodTestSuite)TestOAuth2ProviderApps() {

‎coderd/database/dbmem/dbmem.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2710,11 +2710,11 @@ func (q *FakeQuerier) GetNotificationMessagesByStatus(_ context.Context, arg dat
27102710
returnout,nil
27112711
}
27122712

2713-
func (*FakeQuerier)GetNotificationTemplateById(_ context.Context,_ uuid.UUID) (database.NotificationTemplate,error) {
2713+
func (*FakeQuerier)GetNotificationTemplateByID(_ context.Context,_ uuid.UUID) (database.NotificationTemplate,error) {
27142714
return database.NotificationTemplate{},ErrUnimplemented
27152715
}
27162716

2717-
func (q*FakeQuerier)GetNotificationTemplatesByKind(ctx context.Context,kind database.NotificationTemplateKind) ([]database.NotificationTemplate,error) {
2717+
func (*FakeQuerier)GetNotificationTemplatesByKind(_ context.Context,_ database.NotificationTemplateKind) ([]database.NotificationTemplate,error) {
27182718
returnnil,ErrUnimplemented
27192719
}
27202720

@@ -7546,7 +7546,7 @@ func (q *FakeQuerier) UpdateMemberRoles(_ context.Context, arg database.UpdateMe
75467546
return database.OrganizationMember{},sql.ErrNoRows
75477547
}
75487548

7549-
func (*FakeQuerier)UpdateNotificationTemplateMethodById(_ context.Context,_ database.UpdateNotificationTemplateMethodByIdParams) (database.NotificationTemplate,error) {
7549+
func (*FakeQuerier)UpdateNotificationTemplateMethodByID(_ context.Context,_ database.UpdateNotificationTemplateMethodByIDParams) (database.NotificationTemplate,error) {
75507550
return database.NotificationTemplate{},ErrUnimplemented
75517551
}
75527552

‎coderd/database/dbmetrics/dbmetrics.go‎

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/dbmock/dbmock.go‎

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/querier.go‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries.sql.go‎

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/database/queries/notifications.sql‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,13 @@ ON CONFLICT (user_id, notification_template_id) DO UPDATE
157157
SET disabled=EXCLUDED.disabled,
158158
updated_at=CURRENT_TIMESTAMP;
159159

160-
-- name:UpdateNotificationTemplateMethodById :one
160+
-- name:UpdateNotificationTemplateMethodByID :one
161161
UPDATE notification_templates
162162
SET method=sqlc.narg('method')::notification_method
163163
WHERE id= @id::uuid
164164
RETURNING*;
165165

166-
-- name:GetNotificationTemplateById :one
166+
-- name:GetNotificationTemplateByID :one
167167
SELECT*
168168
FROM notification_templates
169169
WHERE id= @id::uuid;

‎coderd/rbac/object_gen.go‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/rbac/policy/policy.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ var RBACPermissions = map[string]PermissionDefinition{
263263
},
264264
"notification_preference": {
265265
Actions:map[Action]ActionDefinition{
266-
ActionRead:actDef("readownnotification preferences"),
267-
ActionUpdate:actDef("updateownnotification preferences"),
266+
ActionRead:actDef("read notification preferences"),
267+
ActionUpdate:actDef("update notification preferences"),
268268
},
269269
},
270270
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp