mirror of
https://github.com/outline/outline.git
synced 2026-11-21 13:34:02 +03:00
34 lines
903 B
TypeScript
34 lines
903 B
TypeScript
import { http, HttpResponse } from "msw";
|
|
import { server } from "@server/test/msw";
|
|
import OAuthClient from "./oauth";
|
|
|
|
class MinimalOAuthClient extends OAuthClient {
|
|
endpoints = {
|
|
authorize: "http://example.com/authorize",
|
|
token: "http://example.com/token",
|
|
userinfo: "http://example.com/userinfo",
|
|
};
|
|
}
|
|
|
|
describe("userInfo", () => {
|
|
it("should work with empty-body 401 Unauthorized responses", async () => {
|
|
server.use(
|
|
http.get(
|
|
"http://example.com/userinfo",
|
|
() =>
|
|
new HttpResponse(null, { status: 401, statusText: "unauthorized" })
|
|
)
|
|
);
|
|
|
|
const client = new MinimalOAuthClient("clientid", "clientsecret");
|
|
try {
|
|
expect.assertions(1);
|
|
await client.userInfo("token");
|
|
} catch (e) {
|
|
expect(e instanceof Error && "id" in e ? e.id : undefined).toBe(
|
|
"authentication_required"
|
|
);
|
|
}
|
|
});
|
|
});
|