59 lines
2.0 KiB
TypeScript
59 lines
2.0 KiB
TypeScript
import { test, expect } from '@playwright/test'
|
|
|
|
/**
|
|
* E2E tests for Zoo IAM — zoo.id login portal + shared iam.hanzo.ai backend.
|
|
*
|
|
* Zoo tenant is multi-tenant on the shared Casdoor backend at iam.hanzo.ai.
|
|
* zoo.id and id.zoo.network proxy through.
|
|
*/
|
|
|
|
const SHARED_IAM = 'https://iam.hanzo.ai'
|
|
const ZOO_ID_URLS = ['https://zoo.id', 'https://id.zoo.network']
|
|
|
|
test.describe('Zoo IAM — Reach', () => {
|
|
for (const url of ZOO_ID_URLS) {
|
|
test(`${url}`, async ({ request }) => {
|
|
try {
|
|
const res = await request.get(url, { timeout: 10_000 })
|
|
console.log(` ${url}: ${res.status()}`)
|
|
expect([200, 301, 302, 307, 308]).toContain(res.status())
|
|
} catch (e) {
|
|
// DNS not yet provisioned
|
|
test.skip(true, `${url} DNS not yet provisioned: ${e}`)
|
|
}
|
|
})
|
|
}
|
|
})
|
|
|
|
test.describe('Zoo IAM — Shared Backend', () => {
|
|
test('shared IAM serves OIDC well-known', async ({ request }) => {
|
|
const res = await request.get(`${SHARED_IAM}/.well-known/openid-configuration`, { timeout: 15_000 })
|
|
expect(res.status()).toBe(200)
|
|
const json = await res.json() as { issuer: string; jwks_uri: string }
|
|
expect(json.issuer).toBeTruthy()
|
|
expect(json.jwks_uri).toBeTruthy()
|
|
})
|
|
|
|
test('shared IAM serves JWKS', async ({ request }) => {
|
|
const res = await request.get(`${SHARED_IAM}/.well-known/jwks`, { timeout: 10_000 })
|
|
expect(res.status()).toBe(200)
|
|
const json = await res.json() as { keys: unknown[] }
|
|
expect(json.keys?.length).toBeGreaterThan(0)
|
|
})
|
|
|
|
test('OAuth authorize endpoint accepts zoo client_id', async ({ request }) => {
|
|
const params = new URLSearchParams({
|
|
client_id: 'app-zoo',
|
|
response_type: 'code',
|
|
scope: 'openid profile email',
|
|
redirect_uri: 'https://zoo.id/callback',
|
|
state: 'e2e-smoke',
|
|
})
|
|
const res = await request.get(`${SHARED_IAM}/oauth/authorize?${params}`, {
|
|
maxRedirects: 0, timeout: 15_000,
|
|
})
|
|
console.log(` zoo authorize: ${res.status()}`)
|
|
expect([200, 302, 303, 307, 308]).toContain(res.status())
|
|
})
|
|
})
|