feat: Replace owner checks with scope checks (no-changelog) (#7846)

Github issue / Community forum post (link here to close automatically):
This commit is contained in:
Val
2023-11-29 14:48:36 +00:00
committed by GitHub
parent d5762a7539
commit 1cb92ffe16
26 changed files with 136 additions and 78 deletions

View File

@@ -362,7 +362,6 @@ describe('PATCH /users/:id/role', () => {
let authlessAgent: SuperAgentTest;
const {
NO_MEMBER,
MISSING_NEW_ROLE_KEY,
MISSING_NEW_ROLE_VALUE,
NO_ADMIN_ON_OWNER,
@@ -372,6 +371,8 @@ describe('PATCH /users/:id/role', () => {
NO_ADMIN_IF_UNLICENSED,
} = UsersController.ERROR_MESSAGES.CHANGE_ROLE;
const UNAUTHORIZED = 'Unauthorized';
beforeAll(async () => {
await testDb.truncate(['User']);
@@ -406,7 +407,7 @@ describe('PATCH /users/:id/role', () => {
});
expect(response.statusCode).toBe(403);
expect(response.body.message).toBe(NO_MEMBER);
expect(response.body.message).toBe(UNAUTHORIZED);
});
test('should fail to demote owner to admin', async () => {
@@ -415,7 +416,7 @@ describe('PATCH /users/:id/role', () => {
});
expect(response.statusCode).toBe(403);
expect(response.body.message).toBe(NO_MEMBER);
expect(response.body.message).toBe(UNAUTHORIZED);
});
test('should fail to demote admin to member', async () => {
@@ -424,7 +425,7 @@ describe('PATCH /users/:id/role', () => {
});
expect(response.statusCode).toBe(403);
expect(response.body.message).toBe(NO_MEMBER);
expect(response.body.message).toBe(UNAUTHORIZED);
});
test('should fail to promote other member to owner', async () => {
@@ -433,7 +434,7 @@ describe('PATCH /users/:id/role', () => {
});
expect(response.statusCode).toBe(403);
expect(response.body.message).toBe(NO_MEMBER);
expect(response.body.message).toBe(UNAUTHORIZED);
});
test('should fail to promote other member to admin', async () => {
@@ -442,7 +443,7 @@ describe('PATCH /users/:id/role', () => {
});
expect(response.statusCode).toBe(403);
expect(response.body.message).toBe(NO_MEMBER);
expect(response.body.message).toBe(UNAUTHORIZED);
});
test('should fail to promote self to admin', async () => {
@@ -451,7 +452,7 @@ describe('PATCH /users/:id/role', () => {
});
expect(response.statusCode).toBe(403);
expect(response.body.message).toBe(NO_MEMBER);
expect(response.body.message).toBe(UNAUTHORIZED);
});
test('should fail to promote self to owner', async () => {
@@ -460,7 +461,7 @@ describe('PATCH /users/:id/role', () => {
});
expect(response.statusCode).toBe(403);
expect(response.body.message).toBe(NO_MEMBER);
expect(response.body.message).toBe(UNAUTHORIZED);
});
});