Skip to content

Commit ed32ecd

Browse files
committed
Add CI debugging improvements and increase test timeouts
- Add detailed error reporting for exit code propagation test - Create certificate generation debug script for OpenSSL compatibility testing - Increase test timeouts from 10s to 15s to handle CI load - Add certificate debug script to CI pipeline These changes will help diagnose: 1. macOS exit code propagation failures 2. Linux OpenSSL 3.0.13 certificate compatibility issues 3. Weak mode timeout failures in CI
1 parent ccd2827 commit ed32ecd

4 files changed

Lines changed: 91 additions & 7 deletions

File tree

.github/workflows/tests.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ jobs:
7979
chmod +x scripts/debug_tls_env.sh
8080
./scripts/debug_tls_env.sh
8181
sudo ./scripts/debug_tls_env.sh
82-
echo "=== End TLS Debug ==="
82+
echo ""
83+
echo "=== Testing Certificate Generation ==="
84+
chmod +x scripts/debug_cert_generation.sh
85+
./scripts/debug_cert_generation.sh || true
86+
echo "=== End Debug ==="
8387
8488
- name: Run Linux jail integration tests (with sudo)
8589
run: |

scripts/debug_cert_generation.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
# Debug script to test certificate generation and validation
3+
4+
set -e
5+
6+
echo "=== Certificate Generation Debug ==="
7+
echo "Date: $(date)"
8+
echo "OpenSSL version: $(openssl version)"
9+
10+
# Create temp directory for testing
11+
TEMP_DIR=$(mktemp -d)
12+
trap "rm -rf $TEMP_DIR" EXIT
13+
14+
echo ""
15+
echo "Testing certificate generation and validation..."
16+
17+
# Generate a test certificate using OpenSSL directly
18+
cd "$TEMP_DIR"
19+
20+
# Generate CA key
21+
openssl ecparam -genkey -name prime256v1 -out ca-key.pem 2>/dev/null
22+
23+
# Generate CA certificate
24+
openssl req -new -x509 -key ca-key.pem -out ca-cert.pem -days 365 \
25+
-subj "/C=US/O=httpjail/CN=httpjail CA" 2>/dev/null
26+
27+
# Generate server key
28+
openssl ecparam -genkey -name prime256v1 -out server-key.pem 2>/dev/null
29+
30+
# Generate server CSR
31+
openssl req -new -key server-key.pem -out server.csr \
32+
-subj "/CN=test.example.com" 2>/dev/null
33+
34+
# Sign server certificate
35+
openssl x509 -req -in server.csr -CA ca-cert.pem -CAkey ca-key.pem \
36+
-CAcreateserial -out server-cert.pem -days 365 \
37+
-extfile <(echo "subjectAltName=DNS:test.example.com") 2>/dev/null
38+
39+
echo "Certificates generated successfully"
40+
41+
# Verify the certificate chain
42+
echo ""
43+
echo "Verifying certificate chain..."
44+
openssl verify -CAfile ca-cert.pem server-cert.pem
45+
46+
# Check certificate details
47+
echo ""
48+
echo "Server certificate details:"
49+
openssl x509 -in server-cert.pem -text -noout | grep -E "Subject:|Issuer:|Not Before:|Not After:|Signature Algorithm:" || true
50+
51+
# Test with curl
52+
echo ""
53+
echo "Testing with curl..."
54+
# Create a simple HTTPS server response file
55+
cat > server-chain.pem <<EOF
56+
$(cat server-cert.pem)
57+
$(cat ca-cert.pem)
58+
EOF
59+
60+
# Try to parse with OpenSSL 3.0
61+
echo ""
62+
echo "Parsing certificate with OpenSSL..."
63+
openssl x509 -in server-cert.pem -noout -dates
64+
65+
echo ""
66+
echo "=== Certificate generation test completed successfully ==="

tests/common/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ impl HttpjailCommand {
7575
// Ensure httpjail is built
7676
let httpjail_path = build_httpjail()?;
7777

78-
// Always add timeout for tests (10 seconds default)
78+
// Always add timeout for tests (15 seconds default for CI environment)
7979
self.args.insert(0, "--timeout".to_string());
80-
self.args.insert(1, "10".to_string());
80+
self.args.insert(1, "15".to_string());
8181

8282
// Add weak mode if requested
8383
if self.weak_mode {

tests/system_integration.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ pub trait JailTestPlatform {
2222
/// Helper to create httpjail command with standard test settings
2323
pub fn httpjail_cmd() -> Command {
2424
let mut cmd = Command::cargo_bin("httpjail").unwrap();
25-
// Add timeout for all tests
26-
cmd.arg("--timeout").arg("10");
25+
// Add timeout for all tests (15 seconds for CI environment)
26+
cmd.arg("--timeout").arg("15");
2727
// No need to specify ports - they'll be auto-assigned
2828
cmd
2929
}
@@ -225,10 +225,24 @@ pub fn test_jail_exit_code_propagation<P: JailTestPlatform>() {
225225

226226
let output = cmd.output().expect("Failed to execute httpjail");
227227

228+
let exit_code = output.status.code();
229+
let stderr = String::from_utf8_lossy(&output.stderr);
230+
let stdout = String::from_utf8_lossy(&output.stdout);
231+
232+
// Add debugging output
233+
if exit_code != Some(42) {
234+
eprintln!("[{}] Exit code propagation failed", P::platform_name());
235+
eprintln!(" Expected: 42, Got: {:?}", exit_code);
236+
eprintln!(" Stdout: {}", stdout);
237+
eprintln!(" Stderr: {}", stderr);
238+
}
239+
228240
assert_eq!(
229-
output.status.code(),
241+
exit_code,
230242
Some(42),
231-
"Exit code should be propagated"
243+
"Exit code should be propagated. Got {:?}, stderr: {}",
244+
exit_code,
245+
stderr
232246
);
233247
}
234248

0 commit comments

Comments
 (0)