|
4 | 4 | "context"
|
5 | 5 | "encoding/json"
|
6 | 6 | "fmt"
|
7 |
| - "slices" |
8 | 7 | "sync"
|
9 | 8 | "testing"
|
10 | 9 |
|
@@ -1055,51 +1054,24 @@ func TestAuthorizeScope(t *testing.T) {
|
1055 | 1054 | },
|
1056 | 1055 | )
|
1057 | 1056 |
|
1058 |
| - // This scope can only create workspaces |
1059 | 1057 | meID := uuid.New()
|
1060 | 1058 | user = Subject{
|
1061 | 1059 | ID: meID.String(),
|
1062 | 1060 | Roles: Roles{
|
1063 | 1061 | must(RoleByName(RoleMember())),
|
1064 | 1062 | must(RoleByName(ScopedRoleOrgMember(defOrg))),
|
1065 | 1063 | },
|
1066 |
| - Scope: Scope{ |
1067 |
| - Role: Role{ |
1068 |
| - Identifier: RoleIdentifier{Name: "no_personal_data"}, |
1069 |
| - DisplayName: "No Personal Data", |
1070 |
| - Site: append( |
1071 |
| - // Workspace dormancy and workspace are omitted. |
1072 |
| - // Workspace is specifically handled based on the opts.NoOwnerWorkspaceExec |
1073 |
| - allPermsExcept(ResourceUser), |
1074 |
| - // This adds back in the Workspace permissions. |
1075 |
| - Permissions(map[string][]policy.Action{ |
1076 |
| - ResourceUser.Type: {policy.ActionRead}, |
1077 |
| - })...), |
1078 |
| - Org: map[string][]Permission{}, |
1079 |
| - User: []Permission{}, |
1080 |
| - }, |
1081 |
| - // Empty string allow_list is allowed for actions like 'create' |
1082 |
| - AllowIDList: []string{meID.String()}, |
1083 |
| - }, |
| 1064 | + Scope: must(ScopeNoUserData.Expand()), |
1084 | 1065 | }
|
1085 |
| - |
1086 | 1066 | testAuthorize(t, "ReadPersonalUser", user,
|
1087 |
| - // All these cases will fail because a resource ID is set. |
1088 | 1067 | cases(func(c authTestCase) authTestCase {
|
1089 |
| - c.actions = slices.DeleteFunc(ResourceUser.AvailableActions(), func(action policy.Action) bool { |
1090 |
| - return action == policy.ActionRead |
1091 |
| - }) |
| 1068 | + c.actions = ResourceUser.AvailableActions() |
1092 | 1069 | c.allow = false
|
1093 | 1070 | c.resource.ID = meID.String()
|
1094 | 1071 | return c
|
1095 | 1072 | }, []authTestCase{
|
1096 | 1073 | {resource: ResourceUser.WithOwner(meID.String()).InOrg(defOrg).WithID(meID)},
|
1097 | 1074 | }),
|
1098 |
| - |
1099 |
| - // Test create allowed by scope: |
1100 |
| - []authTestCase{ |
1101 |
| - {resource: ResourceUser.WithOwner(meID.String()).InOrg(defOrg).WithID(meID), actions: []policy.Action{policy.ActionRead}, allow: true}, |
1102 |
| - }, |
1103 | 1075 | )
|
1104 | 1076 | }
|
1105 | 1077 |
|
|
0 commit comments