@@ -389,7 +389,9 @@ func TestAuthorizeDomain(t *testing.T) {
389
389
{resource :ResourceWorkspace .AnyOrganization ().WithOwner (user .ID ),actions :ResourceWorkspace .AvailableActions (),allow :true },
390
390
{resource :ResourceTemplate .AnyOrganization (),actions : []policy.Action {policy .ActionCreate },allow :false },
391
391
392
- {resource :ResourceWorkspace .WithOwner (user .ID ),actions :ResourceWorkspace .AvailableActions (),allow :true },
392
+ // ResourceWorkspace WITHOUT an organization. Should never happen in prod. The default member role omits these
393
+ // permissions.
394
+ {resource :ResourceWorkspace .WithOwner (user .ID ),actions :ResourceWorkspace .AvailableActions (),allow :false },
393
395
394
396
{resource :ResourceWorkspace .All (),actions :ResourceWorkspace .AvailableActions (),allow :false },
395
397
@@ -455,6 +457,7 @@ func TestAuthorizeDomain(t *testing.T) {
455
457
Scope :must (ExpandScope (ScopeAll )),
456
458
Roles :Roles {
457
459
must (RoleByName (ScopedRoleOrgAdmin (defOrg ))),
460
+ must (RoleByName (ScopedRoleOrgMember (defOrg ))),
458
461
must (RoleByName (RoleMember ())),
459
462
},
460
463
}
@@ -469,7 +472,8 @@ func TestAuthorizeDomain(t *testing.T) {
469
472
{resource :ResourceWorkspace .InOrg (defOrg ),actions :workspaceExceptConnect ,allow :true },
470
473
{resource :ResourceWorkspace .InOrg (defOrg ),actions :workspaceConnect ,allow :false },
471
474
472
- {resource :ResourceWorkspace .WithOwner (user .ID ),actions :ResourceWorkspace .AvailableActions (),allow :true },
475
+ // Workspace is not in any organization, will never happen in prod.
476
+ {resource :ResourceWorkspace .WithOwner (user .ID ),actions :ResourceWorkspace .AvailableActions (),allow :false },
473
477
474
478
{resource :ResourceWorkspace .All (),actions :ResourceWorkspace .AvailableActions (),allow :false },
475
479
@@ -546,7 +550,8 @@ func TestAuthorizeDomain(t *testing.T) {
546
550
{resource :ResourceWorkspace .InOrg (defOrg ).WithOwner (user .ID ),allow :true },
547
551
{resource :ResourceWorkspace .InOrg (defOrg ),allow :false },
548
552
549
- {resource :ResourceWorkspace .WithOwner (user .ID ),allow :true },
553
+ // Workspace with no ownership will never happen in prod.
554
+ {resource :ResourceWorkspace .WithOwner (user .ID ),allow :false },
550
555
551
556
{resource :ResourceWorkspace .All (),allow :false },
552
557
@@ -640,6 +645,13 @@ func TestAuthorizeDomain(t *testing.T) {
640
645
Action :policy .ActionRead ,
641
646
}},
642
647
},
648
+ OrgMember :map [string ][]Permission {
649
+ defOrg .String (): {{
650
+ Negate :false ,
651
+ ResourceType :"*" ,
652
+ Action :policy .ActionRead ,
653
+ }},
654
+ },
643
655
User : []Permission {
644
656
{
645
657
Negate :false ,
@@ -1145,10 +1157,14 @@ func TestAuthorizeScope(t *testing.T) {
1145
1157
ResourceWorkspace .Type : {policy .ActionRead },
1146
1158
}),
1147
1159
},
1160
+ OrgMember :map [string ][]Permission {
1161
+ defOrg .String ():Permissions (map [string ][]policy.Action {
1162
+ ResourceWorkspace .Type : {policy .ActionRead },
1163
+ }),
1164
+ },
1148
1165
User :Permissions (map [string ][]policy.Action {
1149
1166
ResourceUser .Type : {policy .ActionRead },
1150
1167
}),
1151
- OrgMember :nil ,
1152
1168
},
1153
1169
AllowIDList : []AllowListElement {AllowListAll ()},
1154
1170
},