Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 03:37 UTC
| 1 | import { describe, expect, test } from 'bun:test'; |
| 2 | import { Option } from 'effect'; |
| 3 | import { |
| 4 | normalizeArtifactDigest, |
| 5 | reuseCandidate, |
| 6 | verifyArchive, |
| 7 | verifyCandidateFiles, |
| 8 | } from '../scripts/sdk-release/artifacts'; |
| 9 | import { runRelease } from './sdk-release-harness'; |
| 10 | |
| 11 | const head = 'b'.repeat(40); |
| 12 | const base = 'a'.repeat(40); |
| 13 | const files = [{ name: 'package.tgz', sha256: 'a'.repeat(64), size: 4 }]; |
| 14 | const artifact = { |
| 15 | id: 42, |
| 16 | name: 'sdk-candidate-typescript', |
| 17 | digest: `sha256:${'b'.repeat(64)}`, |
| 18 | expired: false, |
| 19 | expires_at: '2026-12-01T00:00:00Z', |
| 20 | workflow_run: { id: 8, head_sha: head }, |
| 21 | created_at: '2026-11-01T00:00:00Z', |
| 22 | }; |
| 23 | describe('immutable candidates', () => { |
| 24 | test('native upload and REST digests normalize without accepting malformed hashes', async () => { |
| 25 | const raw = 'a'.repeat(64); |
| 26 | expect(await runRelease(normalizeArtifactDigest(raw))).toBe(`sha256:${raw}`); |
| 27 | expect(await runRelease(normalizeArtifactDigest(`sha256:${raw}`))).toBe(`sha256:${raw}`); |
| 28 | await expect(runRelease(normalizeArtifactDigest(`sha256:${raw.slice(1)}`))).rejects.toThrow(); |
| 29 | await expect(runRelease(normalizeArtifactDigest(`md5:${raw}`))).rejects.toThrow(); |
| 30 | }); |
| 31 | test('reuses IDs only from the original source and producer', async () => { |
| 32 | const reused = await runRelease( |
| 33 | reuseCandidate([artifact], artifact.name, 8, head, Date.parse('2026-11-03')) |
| 34 | ); |
| 35 | expect(Option.getOrUndefined(reused)?.id).toBe(42); |
| 36 | await expect(runRelease(reuseCandidate([artifact], artifact.name, 9, head))).rejects.toThrow( |
| 37 | 'Candidate source or producer does not match' |
| 38 | ); |
| 39 | await expect(runRelease(reuseCandidate([artifact], artifact.name, 8, base))).rejects.toThrow( |
| 40 | 'Candidate source or producer does not match' |
| 41 | ); |
| 42 | await expect( |
| 43 | runRelease(reuseCandidate([{ ...artifact, expired: true }], artifact.name, 8, head)) |
| 44 | ).rejects.toThrow('Original candidate unavailable'); |
| 45 | }); |
| 46 | test('archive digest and every file checksum fail closed', async () => { |
| 47 | await expect(runRelease(verifyArchive(new Uint8Array([1]), artifact.digest))).rejects.toThrow( |
| 48 | 'Actions artifact archive digest mismatch' |
| 49 | ); |
| 50 | await expect( |
| 51 | runRelease( |
| 52 | verifyCandidateFiles(new Map([['package.tgz', new Uint8Array([1, 2, 3, 4])]]), files) |
| 53 | ) |
| 54 | ).rejects.toThrow('Candidate checksum mismatch: package.tgz'); |
| 55 | }); |
| 56 | }); |