verify-config-source-ownership.spec.ts 1.2 KB

123456789101112131415161718192021222324252627282930
  1. import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
  2. import { tmpdir } from 'node:os'
  3. import { join } from 'node:path'
  4. import { afterEach, describe, expect, it } from 'vitest'
  5. import { collectConfigSourceOwnershipViolations } from './verify-config-source-ownership.ts'
  6. const roots: string[] = []
  7. afterEach(() => {
  8. for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true })
  9. })
  10. describe('configuration source ownership gate', () => {
  11. it('rejects inline endpoints in shipped bundle patches', () => {
  12. const root = mkdtempSync(join(tmpdir(), 'dsh-config-source-ownership-'))
  13. roots.push(root)
  14. const directory = join(root, 'packages/subagent/subagent-claude-code')
  15. mkdirSync(directory, { recursive: true })
  16. writeFileSync(
  17. join(directory, 'cordis.patch.yml'),
  18. 'config:\n baseURL: !!js process.env.DEEPSEEK_SEARCH_BASE_URL\n',
  19. )
  20. expect(collectConfigSourceOwnershipViolations(root)).toEqual([
  21. 'packages/subagent/subagent-claude-code/cordis.patch.yml:2: inlines a credential or endpoint from the environment.'
  22. + ' The adapter resolves apiKeyEnv through ctx.credentials and the endpoint through the'
  23. + ' environment snapshot; inlining here bypasses both ladders.',
  24. ])
  25. })
  26. })