70bf21e064
Deploy (to testing) and Test Playground Preview Worker / Deploy Playground Preview Worker (testing) (push) Has been skipped
Deploy Workers Shared Staging / Deploy Workers Shared Staging (push) Failing after 0s
Prerelease / build (push) Has been skipped
Handle Changesets / Handle Changesets (push) Has been cancelled
Semgrep OSS scan / semgrep-oss (push) Has been cancelled
33 lines
981 B
TypeScript
33 lines
981 B
TypeScript
import { getAuthUrlFromEnv } from "@cloudflare/workers-auth";
|
|
import { fetch } from "undici";
|
|
import { describe, it } from "vitest";
|
|
import { getClientIdFromEnv } from "../src/user/auth-variables";
|
|
import {
|
|
generateAuthUrl,
|
|
OAUTH_CALLBACK_URL,
|
|
} from "../src/user/generate-auth-url";
|
|
import { DefaultScopeKeys } from "../src/user/user";
|
|
|
|
describe("auth scopes", () => {
|
|
it("default OAuth scopes are accepted by the Cloudflare backend", async ({
|
|
expect,
|
|
}) => {
|
|
const url = generateAuthUrl({
|
|
authUrl: getAuthUrlFromEnv(),
|
|
clientId: getClientIdFromEnv(),
|
|
scopes: DefaultScopeKeys,
|
|
stateQueryParam: "test-state",
|
|
codeChallenge: "test-code-challenge",
|
|
redirectUri: OAUTH_CALLBACK_URL,
|
|
});
|
|
|
|
const response = await fetch(url, { redirect: "manual" });
|
|
|
|
expect(response.status).toBe(302);
|
|
|
|
const location = response.headers.get("location");
|
|
expect(location).toEqual(expect.any(String));
|
|
expect(location).not.toContain("error=invalid_scope");
|
|
});
|
|
});
|