1
0
mirror of https://github.com/pocket-id/pocket-id.git synced 2026-02-12 11:28:32 +00:00

refactor: add formatter to Playwright tests

This commit is contained in:
Elias Schneider
2025-06-27 23:33:26 +02:00
parent d070b9a778
commit 73e7e0b1c5
22 changed files with 1581 additions and 1764 deletions

View File

@@ -1,6 +1,10 @@
import type { Page } from '@playwright/test';
export async function getUserCode(page: Page, clientId: string, clientSecret: string): Promise<string> {
export async function getUserCode(
page: Page,
clientId: string,
clientSecret: string
): Promise<string> {
return page.request
.post('/api/oidc/device/authorize', {
headers: {
@@ -16,25 +20,31 @@ export async function getUserCode(page: Page, clientId: string, clientSecret: st
.then((r) => r.user_code);
}
export async function exchangeCode(page: Page, params: Record<string,string>): Promise<{access_token?: string, token_type?: string, expires_in?: number, error?: string}> {
export async function exchangeCode(
page: Page,
params: Record<string, string>
): Promise<{ access_token?: string; token_type?: string; expires_in?: number; error?: string }> {
return page.request
.post('/api/oidc/token', {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
form: params,
form: params
})
.then((r) => r.json());
}
export async function getClientAssertion(page: Page, data: {issuer: string, audience: string, subject: string}): Promise<string> {
export async function getClientAssertion(
page: Page,
data: { issuer: string; audience: string; subject: string }
): Promise<string> {
return page.request
.post('/api/externalidp/sign', {
data: {
iss: data.issuer,
aud: data.audience,
sub: data.subject,
},
sub: data.subject
}
})
.then((r) => r.text());
}
}