Skip to content

Commit a27d6f3

Browse files
andinuxclaude
andcommitted
fix(e2e): skip token-auth test when no curl CLI is available
The android emulator images ship no curl binary, so minting the gateway token via popen(curl) read an empty response and the test failed. Probe for the curl CLI first and report SKIPPED when it is missing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 2a28552 commit a27d6f3

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

test/integration.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,29 @@ int integration_network_init(sqlite3 *db, const char *database_id, char *network
336336
// Fixed, obviously-synthetic user id ("e2e test") used for every minted token.
337337
#define TOKEN_TEST_USER_ID "e2e7e57e-0000-4000-8000-000000000001"
338338

339+
// Some platforms that run the tests have no curl CLI (e.g. Android emulator images).
340+
int curl_cli_available (void) {
341+
#ifdef _WIN32
342+
FILE *pipe = popen("curl --version 2>nul", "r");
343+
#else
344+
FILE *pipe = popen("curl --version 2>/dev/null", "r");
345+
#endif
346+
if (!pipe) return 0;
347+
char buffer[64];
348+
size_t nread = fread(buffer, 1, sizeof(buffer), pipe);
349+
pclose(pipe);
350+
return nread > 0;
351+
}
352+
339353
// Mint a user token from the gateway (POST /v2/tokens) via the curl CLI: this binary
340354
// is built without networking, HTTP lives only in the loaded extension.
341-
// Returns TEST_SKIPPED when the gateway address or apikey is not configured.
355+
// Returns TEST_SKIPPED when the gateway address or apikey is not configured,
356+
// or when there is no curl CLI to mint the token with.
342357
int fetch_gateway_token (char *token, size_t token_len) {
343358
const char *gateway = getenv("INTEGRATION_TEST_WEBLITE_ADDRESS");
344359
const char *apikey = getenv("INTEGRATION_TEST_APIKEY");
345360
if (!gateway || !*gateway || !apikey || !*apikey) return TEST_SKIPPED;
361+
if (!curl_cli_available()) return TEST_SKIPPED;
346362

347363
// expire the token in 24h so repeated runs don't leave live credentials behind
348364
time_t expires_time = time(NULL) + 24*60*60;

0 commit comments

Comments
 (0)