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:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user