This repository has been archived by the owner on Feb 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Merge branch 'develop' into web/feature/building-creation
- Loading branch information
Showing
3 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -831,6 +831,85 @@ describe("User tests", () => { | |
}); | ||
}); | ||
|
||
describe("Bugs", () => { | ||
describe("Issue 491: Student is able to make himself Admin", () => { | ||
describe("Requests to change permissions from users without administrator priviledges must be rejected", () => { | ||
test("Student's request must be rejected", async () => { | ||
runner.authLevel(AuthenticationLevel.STUDENT); | ||
await runner.patch({ | ||
url: "/user/1", | ||
data: { admin: true }, | ||
expectedResponse: forbiddenResponse, | ||
statusCode: 403, | ||
}); | ||
}); | ||
|
||
test("Superstudent's request must be rejected", async () => { | ||
runner.authLevel(AuthenticationLevel.SUPER_STUDENT); | ||
await runner.patch({ | ||
url: "/user/1", | ||
data: { admin: true }, | ||
expectedResponse: forbiddenResponse, | ||
statusCode: 403, | ||
}); | ||
}); | ||
|
||
test("Syndicus' request must be rejected", async () => { | ||
runner.authLevel(AuthenticationLevel.SYNDICUS); | ||
await runner.patch({ | ||
url: "/user/1", | ||
data: { admin: true }, | ||
expectedResponse: forbiddenResponse, | ||
statusCode: 403, | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
test("Administrator must be allowed to perform permission change", async () => { | ||
runner.authLevel(AuthenticationLevel.ADMINISTRATOR); | ||
await runner.patch({ | ||
url: "/user/1", | ||
data: { super_student: true }, | ||
expectedResponse: { | ||
id: 1, | ||
email: "[email protected]", | ||
first_name: "Dirk", | ||
last_name: "De Student", | ||
last_login: "2023-05-04T12:00:00.000Z", | ||
date_added: "2023-05-04T12:00:00.000Z", | ||
phone: "0123456789", | ||
address_id: 1, | ||
student: true, | ||
super_student: true, | ||
admin: false, | ||
deleted: false, | ||
address: { | ||
id: 1, | ||
street: "Wallaby Way", | ||
number: 42, | ||
city: "Sydney", | ||
zip_code: 2000, | ||
latitude: -33.865143, | ||
longitude: 151.2099, | ||
}, | ||
regions: [ | ||
{ | ||
id: 1, | ||
user_id: 1, | ||
region_id: 1, | ||
region: { | ||
id: 1, | ||
name: "Region 1", | ||
deleted: false, | ||
}, | ||
}, | ||
], | ||
}, | ||
}); | ||
}); | ||
}); | ||
|
||
afterAll(() => { | ||
app.close(); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters