mirror of
https://github.com/iflytek/skillhub.git
synced 2026-11-14 09:01:16 +00:00
Safely transport bounded JSON using existing image tools, generate isolated exact proxy routes with verified HTTPS, and wire Compose and Helm with closed defaults. Refs #989 Signed-off-by: 千乘妍 (Xiaoyaner) <258399167+xiaoyaner0201@users.noreply.github.com>
40 lines
1 KiB
TypeScript
40 lines
1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { validateBasePath } from './base-path-config'
|
|
|
|
describe('validateBasePath', () => {
|
|
it.each(['/skillhub/', '/foo.bar/', '/a_b~c/'])('accepts %s', (value) => {
|
|
expect(validateBasePath(value)).toBe(value)
|
|
})
|
|
|
|
it('accepts root deployment', () => {
|
|
expect(validateBasePath('/')).toBe('/')
|
|
})
|
|
|
|
it.each([
|
|
'//cdn.example/',
|
|
'/foo//bar/',
|
|
'/foo/../bar/',
|
|
'/foo/./bar/',
|
|
'/foo bar/',
|
|
'skillhub/',
|
|
'/skillhub',
|
|
])('rejects unsafe or malformed value %s', (value) => {
|
|
expect(() => validateBasePath(value)).toThrow(/VITE_BASE_PATH/)
|
|
})
|
|
|
|
it.each([
|
|
'/api/',
|
|
'/oauth2/',
|
|
'/login/',
|
|
'/assets/',
|
|
'/registry/',
|
|
'/nginx-health/',
|
|
'/.well-known/',
|
|
'/runtime-config.js/',
|
|
'/api/nested/',
|
|
'/_skillhub-analytics/',
|
|
'/_skillhub-analytics/nested/',
|
|
])('rejects reserved first segment %s', (value) => {
|
|
expect(() => validateBasePath(value)).toThrow(/reserved by the SkillHub server/)
|
|
})
|
|
})
|