Files
orca/src/main/github/github-api-repository-validation.test.ts
T
OrcaWinandOrcaWin 4687e90a16 [comment audit] Continue main-process comment cleanup (#32946)
* [comment audit] Shorten daemon, hook, and emulator comments [skip ci]

* [comment audit] Shorten VM, conversation, SQLite, and theme-import comments [skip ci]

* [comment audit] Tighten Git execution and source-control comment contracts [skip ci]

* [comment audit] Clarify repository probes and maintenance comments [skip ci]

* [comment audit] Shorten status, diff-cache, and checkout comments [skip ci]

* [comment audit] Clarify worktree lifecycle and WSL routing comments [skip ci]

* [comment audit] Shorten forge identity and review-refresh comments [skip ci]

* [comment audit] Tighten hosted-review client comment contracts [skip ci]

* [comment audit] Clarify GitLab compatibility and review comments [skip ci]

* [comment audit] Tighten hook ownership and watchdog rationale [skip ci]

* [comment audit] Condense host and integration compatibility comments [skip ci]

* [comment audit] Clarify IPC authority and remote-routing rationale [skip ci]

* [comment audit] Finalize file-import and containment comment cleanup

* [comment audit] Fix stale Jira type imports blocking full CI

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-10-23 16:27:37 -07:00

45 lines
1.9 KiB
TypeScript

// Authenticated REST overrides must reject path-shaped slugs while accepting Enterprise managed-user suffixes.
import { describe, expect, it } from 'vitest'
import { isValidGitHubApiRepository } from './github-api-repository-validation'
describe('isValidGitHubApiRepository', () => {
it('accepts plain and Enterprise Managed User owners', () => {
expect(isValidGitHubApiRepository({ owner: 'acme', repo: 'orca' })).toBe(true)
expect(isValidGitHubApiRepository({ owner: 'octocat_acme', repo: 'level5' })).toBe(true)
})
it('rejects leading underscore, hyphen, dot, and path-shaped owners', () => {
expect(isValidGitHubApiRepository({ owner: '_acme', repo: 'orca' })).toBe(false)
expect(isValidGitHubApiRepository({ owner: '-acme', repo: 'orca' })).toBe(false)
expect(isValidGitHubApiRepository({ owner: '.acme', repo: 'orca' })).toBe(false)
expect(isValidGitHubApiRepository({ owner: 'a/b', repo: 'orca' })).toBe(false)
})
it('rejects reserved and path-shaped repos', () => {
expect(isValidGitHubApiRepository({ owner: 'acme', repo: '.' })).toBe(false)
expect(isValidGitHubApiRepository({ owner: 'acme', repo: '..' })).toBe(false)
expect(isValidGitHubApiRepository({ owner: 'acme', repo: 'a/b' })).toBe(false)
})
it.each([42, false, null, {}])('rejects a non-string repository host: %j', (host) => {
expect(isValidGitHubApiRepository({ owner: 'acme', repo: 'orca', host })).toBe(false)
})
it.each([undefined, 'github.com', 'github.enterprise.test:8443'])(
'accepts supported legacy or explicit repository host types: %j',
(host) => {
expect(isValidGitHubApiRepository({ owner: 'acme', repo: 'orca', host })).toBe(true)
}
)
it.each([
null,
'acme/orca',
{ owner: 42, repo: 'orca' },
{ owner: 'acme', repo: 42 },
{ owner: 'acme' }
])('rejects malformed runtime repository identities: %j', (repository) => {
expect(isValidGitHubApiRepository(repository)).toBe(false)
})
})