Files
what-to-eat/test/yunlefunSsoConfig.test.ts
T
toor 76a5d71252 refactor: 只保留 Web,移除 Capacitor 原生壳
删除 android/、ios/ 两个 Capacitor 原生工程与 capacitor.config.ts、
ionic.config.json,以及 scripts/android、scripts/ios.sh 构建脚本;
根与 apps/web 的 @capacitor/* 依赖和相关 npm scripts 一并移除。

Web 侧去掉原生分支:登录只走云乐坊容器授权面板或顶层重定向,
暗色模式不再改原生状态栏,移除 Android 物理返回键处理。

保留 @nuxtjs/ionic(Web UI 框架)、云乐坊 window.ylf 桥接与 PWA。

决策记录见 docs/decisions/0004-web-only.md。
2026-10-21 12:27:50 +08:00

67 lines
2.0 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { resolveYunlefunSsoConfig } from '../apps/web/app/utils/yunlefunSsoConfig'
const validConfig = {
clientId: 'cook-web',
cloudbaseEnv: 'yunlefun-8g7ybcxc7345c490',
exchangeUrl: 'https://api.yunle.fun/sso-ticket',
redirectUri: 'https://cook.yunyoujun.cn/auth/callback',
redirectUris: 'https://cook.yunyoujun.cn/auth/callback,https://cook.yunle.fun/auth/callback',
scope: 'identity:bootstrap',
ssoOrigin: 'https://www.yunle.fun',
}
describe('resolveYunlefunSsoConfig', () => {
it('accepts the exact registered production web origin', () => {
expect(resolveYunlefunSsoConfig(validConfig, {
currentOrigin: 'https://cook.yunyoujun.cn',
})).toEqual({
ok: true,
config: {
cloudbaseEnv: 'yunlefun-8g7ybcxc7345c490',
exchange: {
exchangeUrl: 'https://api.yunle.fun/sso-ticket',
},
redirect: {
clientId: 'cook-web',
redirectUri: 'https://cook.yunyoujun.cn/auth/callback',
scope: ['identity:bootstrap'],
ssoOrigin: 'https://www.yunle.fun',
},
},
})
})
it('selects the registered callback for the current production web origin', () => {
expect(resolveYunlefunSsoConfig(validConfig, {
currentOrigin: 'https://cook.yunle.fun',
})).toMatchObject({
ok: true,
config: {
redirect: {
clientId: 'cook-web',
redirectUri: 'https://cook.yunle.fun/auth/callback',
},
},
})
})
it('fails closed on an unregistered HTTP development origin', () => {
expect(resolveYunlefunSsoConfig(validConfig, {
currentOrigin: 'http://127.0.0.1:4173',
})).toEqual({
ok: false,
message: '当前域名尚未登记为登录回跳地址',
})
})
it('fails closed on an unregistered HTTPS origin', () => {
expect(resolveYunlefunSsoConfig(validConfig, {
currentOrigin: 'https://cook.example.com',
})).toEqual({
ok: false,
message: '当前域名尚未登记为登录回跳地址',
})
})
})