-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #467 from MrBrax/develop-ts
2023-10-09
- Loading branch information
Showing
44 changed files
with
1,529 additions
and
1,060 deletions.
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
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
426 changes: 213 additions & 213 deletions
426
server/.yarn/releases/yarn-3.6.1.cjs → client-vue/.yarn/releases/yarn-3.6.4.cjs
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
402 changes: 201 additions & 201 deletions
402
client-vue/.yarn/releases/yarn-3.6.1.cjs → server/.yarn/releases/yarn-3.6.3.cjs
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import request from "supertest"; | ||
import { getApp } from "../app"; | ||
|
||
const app = getApp(); | ||
|
||
describe("Auth Controller", () => { | ||
describe("POST /auth/login", () => { | ||
it("should return 400 if already authenticated", async () => { | ||
const agent = request.agent(app); | ||
await agent.post("/api/v0/auth/login").send({ password: "test" }); | ||
const response = await agent | ||
.post("/api/v0/auth/login") | ||
.send({ password: "test" }); | ||
expect(response.status).toBe(400); | ||
expect(response.body.authenticated).toBe(true); | ||
expect(response.body.message).toBe( | ||
"You are already authenticated." | ||
); | ||
}); | ||
|
||
it("should return 400 if no password set", async () => { | ||
const response = await request(app) | ||
.post("/api/v0/auth/login") | ||
.send({ password: "" }); | ||
expect(response.status).toBe(400); | ||
expect(response.body.authenticated).toBe(false); | ||
expect(response.body.message).toBe("No password set."); | ||
}); | ||
|
||
it("should return 401 if password is incorrect", async () => { | ||
const response = await request(app) | ||
.post("/api/v0/auth/login") | ||
.send({ password: "wrong" }); | ||
expect(response.status).toBe(401); | ||
expect(response.body.authenticated).toBe(false); | ||
expect(response.body.message).toBe("Incorrect password."); | ||
}); | ||
|
||
it("should return 200 if password is correct", async () => { | ||
const response = await request(app) | ||
.post("/api/v0/auth/login") | ||
.send({ password: "test" }); | ||
expect(response.status).toBe(200); | ||
expect(response.body.authenticated).toBe(true); | ||
expect(response.body.message).toBe("Login successful."); | ||
}); | ||
}); | ||
|
||
describe("POST /auth/logout", () => { | ||
it("should return 200 if logged out successfully", async () => { | ||
const agent = request.agent(app); | ||
await agent.post("/api/v0/auth/login").send({ password: "test" }); | ||
const response = await agent.post("/api/v0/auth/logout"); | ||
expect(response.status).toBe(200); | ||
expect(response.body.authenticated).toBe(false); | ||
expect(response.body.message).toBe("Logout successful."); | ||
}); | ||
}); | ||
|
||
describe("GET /auth/check", () => { | ||
it("should return 200 if not password protected", async () => { | ||
const response = await request(app).get("/api/v0/auth/check"); | ||
expect(response.status).toBe(200); | ||
expect(response.body.authentication).toBe(false); | ||
expect(response.body.authenticated).toBe(false); | ||
expect(response.body.message).toBe("No password protection."); | ||
}); | ||
|
||
it("should return 200 if authenticated", async () => { | ||
const agent = request.agent(app); | ||
await agent.post("/api/v0/auth/login").send({ password: "test" }); | ||
const response = await agent.get("/api/v0/auth/check"); | ||
expect(response.status).toBe(200); | ||
expect(response.body.authentication).toBe(true); | ||
expect(response.body.authenticated).toBe(true); | ||
expect(response.body.guest_mode).toBe(false); | ||
}); | ||
|
||
it("should return 200 if not authenticated", async () => { | ||
const response = await request(app).get("/api/v0/auth/check"); | ||
expect(response.status).toBe(200); | ||
expect(response.body.authentication).toBe(true); | ||
expect(response.body.authenticated).toBe(false); | ||
expect(response.body.guest_mode).toBe(false); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.