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
jkomyno committed
Aug 3, 2026 at 20:25 UTC
ba4fa222abd5e0b6a94cae1cbf1429db98ffc772
2 files changed
+44
-4
ts/e2e-tests/cli/install/e2e.test.ts
+21
-2
@@ -174,14 +174,33 @@ test "$(zsh -ilc 'composio --version')" = 98.0.0
174
if (config.mode === 'local') {
175
describe('local failure handling', () => {
176
it(
177
- 'rejects a corrupted release archive before creating the entry point',
177
+ 'rejects an archive that fails checksum verification before extraction',
178
async () => {
179
const result = await run(`
180
set -eu
181
-if curl -fsSL "$INSTALL_BASE_URL/install" | COMPOSIO_GITHUB_URL="$INSTALL_BASE_URL/corrupt" sh -s -- "$E2E_RELEASE_TAG"; then
181
+if output=$(curl -fsSL "$INSTALL_BASE_URL/install" | COMPOSIO_GITHUB_URL="$INSTALL_BASE_URL/checksum-mismatch" sh -s -- "$E2E_RELEASE_TAG" 2>&1); then
182
+ echo 'mismatched archive unexpectedly installed' >&2
183
+ exit 1
184
+fi
185
+printf '%s\n' "$output" | grep -F 'Checksum mismatch'
186
+test ! -e "$HOME/.local/bin/composio"
187
+`);
188
+ assertSuccess(result);
189
+ },
190
+ timeout
191
+ );
192
+
193
+ it(
194
+ 'rejects a corrupted archive at extraction before creating the entry point',
195
+ async () => {
196
+ const result = await run(`
197
+set -eu
198
+if output=$(curl -fsSL "$INSTALL_BASE_URL/install" | COMPOSIO_GITHUB_URL="$INSTALL_BASE_URL/corrupt" sh -s -- "$E2E_RELEASE_TAG" 2>&1); then
199
echo 'corrupted archive unexpectedly installed' >&2
200
exit 1
201
fi
202
+printf '%s\n' "$output" | grep -F 'Checksum verified'
203
+printf '%s\n' "$output" | grep -F 'Failed to extract archive'
204
test ! -e "$HOME/.local/bin/composio"
205
`);
206
assertSuccess(result);
ts/e2e-tests/cli/install/release-server.ts
+23
-2
@@ -7,6 +7,16 @@ const ARCHIVE_BY_ARCH = {
7
x64: 'composio-linux-x64.zip',
8
} as const;
9
10
+/**
11
+ * Body served in place of the release archive under the failure-mode prefixes.
12
+ *
13
+ * - `/corrupt/...` also serves a checksums.txt that matches this body, so the
14
+ * installer passes checksum verification and fails at extraction.
15
+ * - `/checksum-mismatch/...` keeps the genuine checksums.txt, so the installer
16
+ * fails at checksum verification before extraction.
17
+ */
18
+const CORRUPT_ARCHIVE_BODY = 'not a zip archive\n';
19
+
20
export interface InstallReleaseServer {
21
baseUrl: string;
22
platform: 'linux/amd64' | 'linux/arm64';
@@ -64,8 +74,11 @@ export function startInstallReleaseServer(options: {
74
}
75
76
if (url.pathname.includes('/releases/download/') && url.pathname.endsWith(archiveName)) {
67
- if (url.pathname.startsWith('/corrupt/')) {
68
- return new Response('not a zip archive\n', {
77
+ if (
78
+ url.pathname.startsWith('/corrupt/') ||
79
+ url.pathname.startsWith('/checksum-mismatch/')
80
+ ) {
81
+ return new Response(CORRUPT_ARCHIVE_BODY, {
82
headers: { 'content-type': 'application/zip' },
83
});
84
}
@@ -75,6 +88,14 @@ export function startInstallReleaseServer(options: {
88
}
89
90
if (url.pathname.includes('/releases/download/') && url.pathname.endsWith('checksums.txt')) {
91
+ if (url.pathname.startsWith('/corrupt/')) {
92
+ const corruptDigest = new Bun.CryptoHasher('sha256')
93
+ .update(CORRUPT_ARCHIVE_BODY)
94
+ .digest('hex');
95
+ return new Response(`${corruptDigest} ${archiveName}\n`, {
96
+ headers: { 'content-type': 'text/plain; charset=utf-8' },
97
+ });
98
+ }
99
return new Response(readFileSync(checksumsPath), {
100
headers: { 'content-type': 'text/plain; charset=utf-8' },
101
});