mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 17:17:38 +00:00
Unify owner validation across project pickers and repository overrides. Preserve EMU usernames in API and auth-status branch-prefix resolution, with regression coverage. Co-authored-by: Neil <neil@stably.ai>
51 lines
1.8 KiB
TypeScript
51 lines
1.8 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { parseGitHubProjectInput } from './github-project-reference'
|
|
|
|
describe('parseGitHubProjectInput', () => {
|
|
it('keeps legacy owner/number input hostless', () => {
|
|
expect(parseGitHubProjectInput('Acme/42')).toEqual({ owner: 'Acme', number: 42 })
|
|
})
|
|
|
|
it('preserves GitHub Enterprise hosts and view numbers', () => {
|
|
expect(
|
|
parseGitHubProjectInput('https://GitHub.Acme-Corp.com:8443/orgs/Acme/projects/42/views/7')
|
|
).toEqual({
|
|
owner: 'Acme',
|
|
number: 42,
|
|
host: 'github.acme-corp.com:8443',
|
|
viewNumber: 7
|
|
})
|
|
})
|
|
|
|
it('accepts Enterprise Managed User owners (`_<shortcode>` suffix)', () => {
|
|
expect(parseGitHubProjectInput('octocat_acme/1')).toEqual({ owner: 'octocat_acme', number: 1 })
|
|
expect(parseGitHubProjectInput('https://github.com/users/octocat_acme/projects/1')).toEqual({
|
|
owner: 'octocat_acme',
|
|
number: 1,
|
|
host: 'github.com'
|
|
})
|
|
expect(parseGitHubProjectInput('_acme/1')).toBeNull()
|
|
expect(parseGitHubProjectInput('https://github.com/orgs/_acme/projects/1')).toBeNull()
|
|
})
|
|
|
|
it('accepts github.com user Project URLs', () => {
|
|
expect(parseGitHubProjectInput('http://github.com/users/octocat/projects/3')).toEqual({
|
|
owner: 'octocat',
|
|
number: 3,
|
|
host: 'github.com'
|
|
})
|
|
})
|
|
|
|
it('rejects credentials, invalid routes, and unsafe integers', () => {
|
|
for (const input of [
|
|
'https://user:token@github.acme.test/orgs/acme/projects/1',
|
|
'https://github.acme.test/acme/projects/1',
|
|
'https://github.acme.test/orgs/acme/projects/1/files',
|
|
'https://github.acme.test/orgs/acme/projects/9007199254740992',
|
|
'https://github.acme.test/orgs/acme/projects/1/views/0'
|
|
]) {
|
|
expect(parseGitHubProjectInput(input)).toBeNull()
|
|
}
|
|
})
|
|
})
|