mirror of
https://github.com/hanzo-apps/hanzo.ai.git
synced 2026-10-29 07:20:43 +00:00
hanzo.bot and cloud.hanzo.ai leave their /login for hanzo.ai, and hanzo.ai answers them from its session on arrival, so the /login?from=logout a sign-out lands on signed the person straight back in. That page draws the panel and leaves only on Continue. hanzo.team, Hanzo's workspace, now signs in here with its own request; it is answered on arrival like the other Hanzo sites, instead of with the sheet.
28 lines
1.4 KiB
TypeScript
28 lines
1.4 KiB
TypeScript
import { test, expect } from '@playwright/test'
|
||
import { asker, ours } from '../../lib/auth/asker'
|
||
|
||
// "Continue as" names who asked: a site by its host, a native app as one.
|
||
test('a site on the web is named by its host', () => {
|
||
expect(asker('https://platform.hanzo.ai/auth/callback')).toBe('platform.hanzo.ai')
|
||
expect(asker('https://studio.hanzo.ai/callback')).toBe('studio.hanzo.ai')
|
||
})
|
||
|
||
test('a native app, a loopback port or nothing names no site', () => {
|
||
expect(asker('hanzo://oauth/hanzo')).toBeNull()
|
||
expect(asker('http://127.0.0.1:8765/callback')).toBeNull()
|
||
expect(asker('https://localhost:3000/auth/callback')).toBeNull()
|
||
expect(asker(undefined)).toBeNull()
|
||
expect(asker('not a url')).toBeNull()
|
||
})
|
||
|
||
// A Hanzo site on the web is answered on arrival; anything else gets the sheet.
|
||
test('Hanzo’s own web sites are ours', () => {
|
||
for (const cb of ['https://platform.hanzo.ai/auth/callback', 'https://studio.hanzo.ai/callback', 'https://admin.hanzo.ai/auth/callback', 'https://hanzo.bot/auth/callback', 'https://hanzo.team/auth/callback'])
|
||
expect(ours(cb), cb).toBe(true)
|
||
})
|
||
|
||
test('a native app, a lookalike or another site is not', () => {
|
||
for (const cb of ['hanzo://oauth/hanzo', 'http://platform.hanzo.ai/auth/callback', 'https://hanzo.ai.evil.com/cb', 'https://evilhanzo.ai/cb', 'https://example.com/cb', undefined])
|
||
expect(ours(cb), String(cb)).toBe(false)
|
||
})
|