@@ -16,6 +16,7 @@ import (
16
16
"cdr.dev/slog"
17
17
18
18
"github.com/coder/coder/v2/coderd/database/db2sdk"
19
+ "github.com/coder/coder/v2/coderd/notifications"
19
20
"github.com/coder/coder/v2/coderd/rbac/policy"
20
21
"github.com/coder/coder/v2/codersdk"
21
22
@@ -2555,6 +2556,10 @@ func (s *MethodTestSuite) TestSystemFunctions() {
2555
2556
AgentID : uuid .New (),
2556
2557
}).Asserts (tpl , policy .ActionCreate )
2557
2558
}))
2559
+ }
2560
+
2561
+ func (s * MethodTestSuite ) TestNotifications () {
2562
+ // System functions
2558
2563
s .Run ("AcquireNotificationMessages" , s .Subtest (func (db database.Store , check * expects ) {
2559
2564
// TODO: update this test once we have a specific role for notifications
2560
2565
check .Args (database.AcquireNotificationMessagesParams {}).Asserts (rbac .ResourceSystem , policy .ActionUpdate )
@@ -2590,6 +2595,40 @@ func (s *MethodTestSuite) TestSystemFunctions() {
2590
2595
Limit : 10 ,
2591
2596
}).Asserts (rbac .ResourceSystem , policy .ActionRead )
2592
2597
}))
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
+ }))
2593
2632
}
2594
2633
2595
2634
func (s * MethodTestSuite ) TestOAuth2ProviderApps () {
0 commit comments