🐛Fixed bug with ability to log in with revoked session

This commit is contained in:
Anton SHEPILOV
2024-05-29 22:27:03 +02:00
committed by Anton Shepilov
parent d44174b7b1
commit 9026900005
4 changed files with 46 additions and 10 deletions
@@ -61,7 +61,8 @@ describe("The /backchannel_logout API", () => {
// Verify the session is removed from the database
const deletedSession = await currentUser.dbService.getSessionById(currentUser.session);
expect(deletedSession).toBeNull();
expect(deletedSession).not.toBeNull();
expect(deletedSession.revoked_at).toBeGreaterThan(0);
});
it("should create a session on login", async () => {
@@ -82,6 +83,35 @@ describe("The /backchannel_logout API", () => {
expect(response.statusCode).toBe(401);
});
it("should receive 401 after logout and try to login one more time with the same token", async () => {
//when
await currentUser.logout();
//then
const response = await currentUser.login(currentUser.session);
expect(response.statusCode).toBe(401);
});
it("should receive 401 after logout successfully after logout", async () => {
//given
const myDriveId = "user_" + currentUser.user.id;
let response = await currentUser.getDocument(myDriveId);
expect(response.statusCode).toBe(200);
//when
await currentUser.logout();
//then
response = await currentUser.login(currentUser.session);
expect(response.statusCode).toBe(401);
currentUser.jwt = await currentUser.doLogin();
response = await currentUser.getDocument(myDriveId);
expect(response.statusCode).toBe(200);
});
it("should be able to log-in several times by having multiple sessions", async () => {
// Perform a second login
const newUserSession = await UserApi.getInstance(platform);