23 lines
851 B
TypeScript
23 lines
851 B
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import { shouldAttachStoredAuthorization } from "./auth-request-policy";
|
|
|
|
test("public login mutations do not inherit a previously stored account token", () => {
|
|
for (const url of [
|
|
"https://gateway.invalid/web/api/v1/auth/login/token?token=external",
|
|
"/api/v1/auth/login/username",
|
|
"/api/v1/auth/login/local",
|
|
"/api/v1/auth/register",
|
|
"/api/v1/auth/initialize",
|
|
]) {
|
|
assert.equal(shouldAttachStoredAuthorization(url), false, url);
|
|
}
|
|
});
|
|
|
|
test("authenticated account endpoints continue to receive the stored token", () => {
|
|
assert.equal(shouldAttachStoredAuthorization("/api/v1/auth/me"), true);
|
|
assert.equal(shouldAttachStoredAuthorization("/api/v1/auth/users"), true);
|
|
assert.equal(shouldAttachStoredAuthorization("/api/agents"), true);
|
|
});
|