mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
test(etapi): port basic-auth
This commit is contained in:
parent
26fcc4fb24
commit
4ed30e0624
@ -1,34 +0,0 @@
|
||||
POST {{triliumHost}}/etapi/auth/login
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"password": "1234"
|
||||
}
|
||||
|
||||
> {%
|
||||
client.assert(response.status === 201);
|
||||
|
||||
client.global.set("testAuthToken", response.body.authToken);
|
||||
%}
|
||||
|
||||
###
|
||||
|
||||
GET {{triliumHost}}/etapi/notes/root
|
||||
Authorization: {{testAuthToken}}
|
||||
|
||||
> {% client.assert(response.status === 200); %}
|
||||
|
||||
###
|
||||
|
||||
POST {{triliumHost}}/etapi/auth/logout
|
||||
Authorization: {{testAuthToken}}
|
||||
Content-Type: application/json
|
||||
|
||||
> {% client.assert(response.status === 204); %}
|
||||
|
||||
###
|
||||
|
||||
GET {{triliumHost}}/etapi/notes/root
|
||||
Authorization: {{testAuthToken}}
|
||||
|
||||
> {% client.assert(response.status === 401); %}
|
@ -38,4 +38,17 @@ describe("basic-auth", () => {
|
||||
.auth("wrong", token, { "type": "basic"})
|
||||
.expect(401);
|
||||
});
|
||||
|
||||
it("logs out", async () => {
|
||||
await supertest(app)
|
||||
.post("/etapi/auth/logout")
|
||||
.auth(USER, token, { "type": "basic"})
|
||||
.expect(204);
|
||||
|
||||
// Ensure we can't access it anymore
|
||||
await supertest(app)
|
||||
.get("/etapi/notes/root")
|
||||
.auth(USER, token, { "type": "basic"})
|
||||
.expect(401);
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user