Skip to content

Build your personal knowledge base with Trilium Notes

test(etapi): port basic-auth

Elian Doran4ed30e062445
diff --git a/_regroup/test-etapi/logout.http b/_regroup/test-etapi/logout.http
deleted file mode 100644
index 9bd7355e03..0000000000
--- a/_regroup/test-etapi/logout.http
+++ /dev/null
@@ -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); %}
diff --git a/apps/server/spec/etapi/basic-auth.spec.ts b/apps/server/spec/etapi/basic-auth.spec.ts
index b3fbc837d5..6518c7a12d 100644
--- a/apps/server/spec/etapi/basic-auth.spec.ts
+++ b/apps/server/spec/etapi/basic-auth.spec.ts
@@ -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);
+ });
});