refac: debt on role backend
This commit is contained in:
1 parent
de142f6c5f
commit
a043f7f41a
130 files changed
+3591
-512
No files matched your search
@@ -249,7 +249,7 @@ func TestRolesPermissionsEnforcementAPIKeyScope(t *testing.T) {
|
||||
repo.fail.failNext("Get")
|
||||
uc := useCases.NewRevokeAPIKeyUseCase(repo, apiKeyUnitClock, discardRecorder)
|
||||
|
||||
err := uc.RevokeAPIKey(testCtx, 2, stored.ID, role.NewGrantSet(nil))
|
||||
err := uc.RevokeAPIKey(testCtx, 2, stored.ID, role.GrantSet{})
|
||||
|
||||
if !errors.Is(err, role.ErrMissingPermission) {
|
||||
t.Errorf("expected a missing permission, got %v", err)
|
||||
@@ -272,7 +272,7 @@ func TestRolesPermissionsEnforcementAPIKeyScope(t *testing.T) {
|
||||
|
||||
t.Run("A list with no apikeys.view grant is refused by the use case as well", func(t *testing.T) {
|
||||
uc := useCases.NewListAPIKeysUseCase(newMockAPIKeyRepo(), apiKeyUnitUsers(), apiKeyUnitClock)
|
||||
if _, err := uc.ListAPIKeys(2, role.NewGrantSet(nil)); !errors.Is(err, role.ErrMissingPermission) {
|
||||
if _, err := uc.ListAPIKeys(2, role.GrantSet{}); !errors.Is(err, role.ErrMissingPermission) {
|
||||
t.Errorf("expected a missing permission, got %v", err)
|
||||
}
|
||||
})
|
||||
@@ -305,8 +305,8 @@ func TestRolesPermissionsEnforcementAuthorScope(t *testing.T) {
|
||||
{"own edits its linked author", authorsEditOwnGrants, 4, author.Patch{Bio: &bio}, nil, false},
|
||||
{"own cannot edit another author", authorsEditOwnGrants, 5, author.Patch{Bio: &bio}, author.ErrAuthorRights, false},
|
||||
{"own cannot unlink", authorsEditOwnGrants, 4, author.Patch{UserID: author.Nullable[uint32]{Set: true}}, author.ErrAuthorRights, false},
|
||||
{"none is refused", role.NewGrantSet(nil), 4, author.Patch{Bio: &bio}, role.ErrMissingPermission, false},
|
||||
{"none is refused before any lookup", role.NewGrantSet(nil), 999, author.Patch{Bio: &bio}, role.ErrMissingPermission, false},
|
||||
{"none is refused", role.GrantSet{}, 4, author.Patch{Bio: &bio}, role.ErrMissingPermission, false},
|
||||
{"none is refused before any lookup", role.GrantSet{}, 999, author.Patch{Bio: &bio}, role.ErrMissingPermission, false},
|
||||
}
|
||||
for _, row := range rows {
|
||||
t.Run(row.name, func(t *testing.T) {
|
||||
@@ -329,8 +329,8 @@ func TestRolesPermissionsEnforcementAuthorScope(t *testing.T) {
|
||||
|
||||
t.Run("user_email on authors needs users.view", func(t *testing.T) {
|
||||
for name, grants := range map[string]role.GrantSet{
|
||||
"with users.view": role.NewGrantSet([]role.Grant{scopedGrant(role.KeyUsersView, role.ScopeAll)}),
|
||||
"without users.view": role.NewGrantSet(nil),
|
||||
"with users.view": unlockedGrantSet(role.KeyUsersView + "=all"),
|
||||
"without users.view": role.GrantSet{},
|
||||
} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
authors := plainAuthors()
|
||||
|
||||
Reference in new issue
Block a user