MCPcopy Create free account
hub / github.com/deepclause/agentvm / test

Function test

test/network/ssl.test.js:20–279  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18}
19
20async function test() {
21 console.log("=== SSL/TLS Connection Tests ===\n");
22
23 const vm = new AgentVM({ network: true, debug: false });
24 let passed = 0;
25 let failed = 0;
26 let skipped = 0;
27
28 try {
29 await withTimeout(vm.start(), 15000);
30 console.log("VM Started with network enabled.\n");
31
32 // Check if curl is available
33 console.log("Checking curl availability...");
34 let res = await withTimeout(vm.exec("which curl"), 10000);
35 if (res.exitCode !== 0) {
36 console.log("curl not found, skipping SSL tests\n");
37 process.exit(0);
38 }
39 console.log("curl found at:", res.stdout.trim(), "\n");
40
41 // Test 1: Basic HTTPS GET request
42 console.log("Test 1: Basic HTTPS GET request");
43 let start = Date.now();
44 res = await withTimeout(
45 vm.exec("curl -s https://httpbin.org/get"),
46 90000
47 );
48 let elapsed = Date.now() - start;
49 if (res.exitCode === 0 && res.stdout.includes('"url"')) {
50 console.log(` PASS (${elapsed}ms)\n`);
51 passed++;
52 } else {
53 console.log(` FAIL (${elapsed}ms): exitCode=${res.exitCode}`);
54 console.log(` stdout: ${res.stdout.slice(0, 500)}`);
55 console.log(` stderr: ${res.stderr.slice(0, 500)}\n`);
56 failed++;
57 }
58
59 // Test 2: HTTPS with verbose TLS info
60 console.log("Test 2: HTTPS with TLS info (curl -v)");
61 start = Date.now();
62 res = await withTimeout(
63 vm.exec("curl -sv https://httpbin.org/get 2>&1 | grep -E '(SSL|TLS|subject|issuer)' | head -5 || echo 'TLS check done'"),
64 30000
65 );
66 elapsed = Date.now() - start;
67 if (res.exitCode === 0 && (res.stdout.includes('SSL') || res.stdout.includes('TLS') || res.stdout.includes('TLS check done'))) {
68 console.log(` PASS (${elapsed}ms) - TLS connection info retrieved\n`);
69 if (res.stdout.includes('SSL') || res.stdout.includes('TLS')) {
70 console.log(` Details: ${res.stdout.trim().split('\n').slice(0, 3).join(', ')}\n`);
71 }
72 passed++;
73 } else {
74 console.log(` FAIL (${elapsed}ms): ${res.stderr || res.stdout}\n`);
75 failed++;
76 }
77

Callers 1

ssl.test.jsFile · 0.70

Calls 4

startMethod · 0.95
execMethod · 0.95
stopMethod · 0.95
withTimeoutFunction · 0.70

Tested by

no test coverage detected