Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

test(cli): exercise the installer extraction-failure branch in the install e2e

jkomynoba4fa222abd5
diff --git a/ts/e2e-tests/cli/install/e2e.test.ts b/ts/e2e-tests/cli/install/e2e.test.ts
index 33c02b136..9d38ed180 100644
--- a/ts/e2e-tests/cli/install/e2e.test.ts
+++ b/ts/e2e-tests/cli/install/e2e.test.ts
@@ -174,14 +174,33 @@ test "$(zsh -ilc 'composio --version')" = 98.0.0
if (config.mode === 'local') {
describe('local failure handling', () => {
it(
- 'rejects a corrupted release archive before creating the entry point',
+ 'rejects an archive that fails checksum verification before extraction',
async () => {
const result = await run(`
set -eu
-if curl -fsSL "$INSTALL_BASE_URL/install" | COMPOSIO_GITHUB_URL="$INSTALL_BASE_URL/corrupt" sh -s -- "$E2E_RELEASE_TAG"; then
+if output=$(curl -fsSL "$INSTALL_BASE_URL/install" | COMPOSIO_GITHUB_URL="$INSTALL_BASE_URL/checksum-mismatch" sh -s -- "$E2E_RELEASE_TAG" 2>&1); then
+ echo 'mismatched archive unexpectedly installed' >&2
+ exit 1
+fi
+printf '%s\n' "$output" | grep -F 'Checksum mismatch'
+test ! -e "$HOME/.local/bin/composio"
+`);
+ assertSuccess(result);
+ },
+ timeout
+ );
+
+ it(
+ 'rejects a corrupted archive at extraction before creating the entry point',
+ async () => {
+ const result = await run(`
+set -eu
+if output=$(curl -fsSL "$INSTALL_BASE_URL/install" | COMPOSIO_GITHUB_URL="$INSTALL_BASE_URL/corrupt" sh -s -- "$E2E_RELEASE_TAG" 2>&1); then
echo 'corrupted archive unexpectedly installed' >&2
exit 1
fi
+printf '%s\n' "$output" | grep -F 'Checksum verified'
+printf '%s\n' "$output" | grep -F 'Failed to extract archive'
test ! -e "$HOME/.local/bin/composio"
`);
assertSuccess(result);
diff --git a/ts/e2e-tests/cli/install/release-server.ts b/ts/e2e-tests/cli/install/release-server.ts
index cd97d4784..0d1545d8a 100644
--- a/ts/e2e-tests/cli/install/release-server.ts
+++ b/ts/e2e-tests/cli/install/release-server.ts
@@ -7,6 +7,16 @@ const ARCHIVE_BY_ARCH = {
x64: 'composio-linux-x64.zip',
} as const;
+/**
+ * Body served in place of the release archive under the failure-mode prefixes.
+ *
+ * - `/corrupt/...` also serves a checksums.txt that matches this body, so the
+ * installer passes checksum verification and fails at extraction.
+ * - `/checksum-mismatch/...` keeps the genuine checksums.txt, so the installer
+ * fails at checksum verification before extraction.
+ */
+const CORRUPT_ARCHIVE_BODY = 'not a zip archive\n';
+
export interface InstallReleaseServer {
baseUrl: string;
platform: 'linux/amd64' | 'linux/arm64';
@@ -64,8 +74,11 @@ export function startInstallReleaseServer(options: {
}
if (url.pathname.includes('/releases/download/') && url.pathname.endsWith(archiveName)) {
- if (url.pathname.startsWith('/corrupt/')) {
- return new Response('not a zip archive\n', {
+ if (
+ url.pathname.startsWith('/corrupt/') ||
+ url.pathname.startsWith('/checksum-mismatch/')
+ ) {
+ return new Response(CORRUPT_ARCHIVE_BODY, {
headers: { 'content-type': 'application/zip' },
});
}
@@ -75,6 +88,14 @@ export function startInstallReleaseServer(options: {
}
if (url.pathname.includes('/releases/download/') && url.pathname.endsWith('checksums.txt')) {
+ if (url.pathname.startsWith('/corrupt/')) {
+ const corruptDigest = new Bun.CryptoHasher('sha256')
+ .update(CORRUPT_ARCHIVE_BODY)
+ .digest('hex');
+ return new Response(`${corruptDigest} ${archiveName}\n`, {
+ headers: { 'content-type': 'text/plain; charset=utf-8' },
+ });
+ }
return new Response(readFileSync(checksumsPath), {
headers: { 'content-type': 'text/plain; charset=utf-8' },
});