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

Commit27c1592

Browse files
committed
rename inbox notifications
fix rbac roles
1 parent3bb9c57 commit27c1592

File tree

4 files changed

+65
-4
lines changed

4 files changed

+65
-4
lines changed

‎coderd/database/dbauthz/dbauthz_test.go

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4495,6 +4495,7 @@ func (s *MethodTestSuite) TestNotifications() {
44954495
Title:"test title",
44964496
Content:"test content notification",
44974497
Icon:"test icon",
4498+
Actions:json.RawMessage("{}"),
44984499
})
44994500

45004501
check.Args(u.ID).Asserts(rbac.ResourceInboxNotification.WithID(notifID).WithOwner(u.ID.String()),policy.ActionRead).Returns([]database.InboxNotification{notif})
@@ -4517,6 +4518,7 @@ func (s *MethodTestSuite) TestNotifications() {
45174518
Title:"test title",
45184519
Content:"test content notification",
45194520
Icon:"test icon",
4521+
Actions:json.RawMessage("{}"),
45204522
})
45214523

45224524
check.Args(u.ID).Asserts(rbac.ResourceInboxNotification.WithID(notifID).WithOwner(u.ID.String()),policy.ActionRead).Returns([]database.InboxNotification{notif})
@@ -4542,6 +4544,7 @@ func (s *MethodTestSuite) TestNotifications() {
45424544
Title:"test title",
45434545
Content:"test content notification",
45444546
Icon:"test icon",
4547+
Actions:json.RawMessage("{}"),
45454548
})
45464549

45474550
check.Args(database.FetchInboxNotificationsByUserIDFilteredByTemplatesAndTargetsParams{
@@ -4571,6 +4574,7 @@ func (s *MethodTestSuite) TestNotifications() {
45714574
Title:"test title",
45724575
Content:"test content notification",
45734576
Icon:"test icon",
4577+
Actions:json.RawMessage("{}"),
45744578
})
45754579

45764580
check.Args(database.FetchUnreadInboxNotificationsByUserIDFilteredByTemplatesAndTargetsParams{
@@ -4600,14 +4604,34 @@ func (s *MethodTestSuite) TestNotifications() {
46004604
Title:"test title",
46014605
Content:"test content notification",
46024606
Icon:"test icon",
4607+
Actions:json.RawMessage("{}"),
46034608
})
46044609

46054610
check.Args(notifID).Asserts(rbac.ResourceInboxNotification.WithID(notifID).WithOwner(u.ID.String()),policy.ActionRead).Returns(notif)
46064611
}))
46074612

4608-
s.Run("InsertInboxNotification",s.Subtest(func(_ database.Store,check*expects) {
4609-
owner:= uuid.UUID{}
4610-
check.Args(database.InsertInboxNotificationParams{}).Asserts(rbac.ResourceInboxNotification.WithOwner(owner.String()),policy.ActionCreate)
4613+
s.Run("InsertInboxNotification",s.Subtest(func(db database.Store,check*expects) {
4614+
u:=dbgen.User(s.T(),db, database.User{})
4615+
o:=dbgen.Organization(s.T(),db, database.Organization{})
4616+
tpl:=dbgen.Template(s.T(),db, database.Template{
4617+
OrganizationID:o.ID,
4618+
CreatedBy:u.ID,
4619+
})
4620+
4621+
notifID:=uuid.New()
4622+
4623+
targets:= []uuid.UUID{u.ID,tpl.ID}
4624+
4625+
check.Args(database.InsertInboxNotificationParams{
4626+
ID:notifID,
4627+
UserID:u.ID,
4628+
TemplateID:tpl.ID,
4629+
Targets:targets,
4630+
Title:"test title",
4631+
Content:"test content notification",
4632+
Icon:"test icon",
4633+
Actions:json.RawMessage("{}"),
4634+
}).Asserts(rbac.ResourceInboxNotification.WithOwner(u.ID.String()),policy.ActionCreate)
46114635
}))
46124636

46134637
s.Run("SetInboxNotificationAsRead",s.Subtest(func(db database.Store,check*expects) {
@@ -4631,6 +4655,7 @@ func (s *MethodTestSuite) TestNotifications() {
46314655
Title:"test title",
46324656
Content:"test content notification",
46334657
Icon:"test icon",
4658+
Actions:json.RawMessage("{}"),
46344659
})
46354660

46364661
notif.ReadAt= sql.NullTime{Time:readAt,Valid:true}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
DROPTABLE IF EXISTSnotifications_inbox;
1+
DROPTABLE IF EXISTSinbox_notifications;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
INSERT INTO
2+
inbox_notifications (
3+
id,
4+
user_id,
5+
template_id,
6+
targets,
7+
title,
8+
content,
9+
icon,
10+
actions,
11+
read_at,
12+
created_at
13+
)
14+
VALUES (
15+
'68b396aa-7f53-4bf1-b8d8-4cbf5fa244e5',-- uuid
16+
'45e89705-e09d-4850-bcec-f9a937f5d78d',-- uuid
17+
'193590e9-918f-4ef9-be47-04625f49c4c3',-- uuid
18+
ARRAY[]::UUID[],-- uuid[]
19+
'Test Notification',
20+
'This is a test notification',
21+
'https://test.coder.com/favicon.ico',
22+
'{}',
23+
'2024-01-01 00:00:00',
24+
'2024-01-01 00:00:00'
25+
);

‎coderd/rbac/roles_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,17 @@ func TestRolePermissions(t *testing.T) {
354354
false: {setOtherOrg,setOrgNotMe,templateAdmin,userAdmin},
355355
},
356356
},
357+
{
358+
Name:"InboxNotification",
359+
Actions: []policy.Action{
360+
policy.ActionCreate,policy.ActionRead,policy.ActionUpdate,
361+
},
362+
Resource:rbac.ResourceInboxNotification.WithID(uuid.New()).InOrg(orgID).WithOwner(currentUser.String()),
363+
AuthorizeMap:map[bool][]hasAuthSubjects{
364+
true: {owner,orgMemberMe,orgAdmin},
365+
false: {setOtherOrg,orgUserAdmin,orgTemplateAdmin,orgAuditor,templateAdmin,userAdmin,memberMe},
366+
},
367+
},
357368
{
358369
Name:"UserData",
359370
Actions: []policy.Action{policy.ActionReadPersonal,policy.ActionUpdatePersonal},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp