Skip to content

Commit be0bc62

Browse files
committed
resolve more issues
1 parent 4670ca5 commit be0bc62

8 files changed

Lines changed: 70 additions & 444 deletions

File tree

.github/workflows/tests.yml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,24 @@ jobs:
2424
- name: Setup Rust cache
2525
uses: Swatinem/rust-cache@v2
2626

27+
- name: Install nextest
28+
uses: taiki-e/install-action@nextest
29+
2730
- name: Build
2831
run: cargo build --verbose
2932

3033
- name: Run unit tests
31-
run: cargo test --bins --verbose
34+
run: cargo nextest run --bins --verbose
3235

3336
- name: Run smoke tests
34-
run: cargo test --test smoke_test --verbose
37+
run: cargo nextest run --test smoke_test --verbose
3538

3639
- name: Run macOS integration tests (with sudo)
3740
run: |
3841
# The tests require root privileges for PF rules on macOS
3942
# GitHub Actions provides passwordless sudo on macOS runners
40-
# Use -E to preserve environment and full path to cargo
41-
sudo -E $(which cargo) test --test macos_integration --verbose
43+
# Use -E to preserve environment and full path to cargo and nextest
44+
sudo -E $(which cargo) nextest run --test macos_integration --verbose
4245
4346
test-linux:
4447
name: Linux Tests
@@ -58,17 +61,17 @@ jobs:
5861
- name: Setup Rust cache
5962
uses: Swatinem/rust-cache@v2
6063

64+
- name: Install nextest
65+
uses: taiki-e/install-action@nextest
66+
6167
- name: Build
6268
run: cargo build --verbose
6369

6470
- name: Run unit tests
65-
run: cargo test --bins --verbose
71+
run: cargo nextest run --bins --verbose
6672

6773
- name: Run smoke tests
68-
run: cargo test --test smoke_test --verbose
69-
70-
- name: Run jail integration tests
71-
run: cargo test --test jail_integration --verbose
74+
run: cargo nextest run --test smoke_test --verbose
7275

7376
- name: Debug TLS environment
7477
run: |
@@ -83,8 +86,8 @@ jobs:
8386
# Ensure ip netns support is available
8487
sudo ip netns list || true
8588
# Run the Linux-specific jail tests with root privileges
86-
# Use full path to cargo since sudo doesn't preserve PATH
87-
sudo -E $(which cargo) test --test linux_integration --verbose
89+
# Use full path to cargo and nextest since sudo doesn't preserve PATH
90+
sudo -E $(which cargo) nextest run --test linux_integration --verbose
8891
8992
test-weak:
9093
name: Weak Mode Integration Tests (Linux)
@@ -101,11 +104,14 @@ jobs:
101104
- name: Setup Rust cache
102105
uses: Swatinem/rust-cache@v2
103106

107+
- name: Install nextest
108+
uses: taiki-e/install-action@nextest
109+
104110
- name: Build
105111
run: cargo build --verbose
106112

107113
- name: Run weak mode integration tests
108-
run: cargo test --test weak_integration --verbose
114+
run: cargo nextest run --test weak_integration --verbose
109115

110116
clippy:
111117
name: Clippy

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ A cross-platform tool for monitoring and restricting HTTP/HTTPS requests from pr
1919
- [ ] Expand test cases to include WebSockets
2020
- [ ] Add Linux support with parity with macOS
2121
- [ ] Add robust firewall cleanup mechanism for Linux and macOS
22+
- [ ] Support/test concurrent jailing across macOS and Linux
2223

2324
## Quick Start
2425

src/tls.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::fs;
77
use std::num::NonZeroUsize;
88
use std::path::PathBuf;
99
use std::sync::{Arc, RwLock};
10-
use tracing::{debug, info, warn};
10+
use tracing::{debug, info};
1111

1212
const CERT_CACHE_SIZE: usize = 1024;
1313

@@ -224,11 +224,6 @@ impl CertificateManager {
224224
cert_der.len()
225225
);
226226

227-
// Validate the certificate can be parsed (this might catch ASN.1 issues early)
228-
if let Err(e) = rustls::pki_types::CertificateDer::try_from(cert_der.as_ref()) {
229-
warn!("Generated certificate has encoding issues: {}", e);
230-
}
231-
232227
// Also include CA cert in chain
233228
let ca_cert_der = self.ca_cert.der().clone();
234229
// ca_cert_der is already the correct type
@@ -289,14 +284,12 @@ impl CertificateManager {
289284
Some(PathBuf::from("/root/.config/httpjail/ca-cert.pem")),
290285
];
291286

292-
for path_option in &possible_paths {
293-
if let Some(path) = path_option {
294-
if path.exists() {
295-
ca_path = Utf8PathBuf::try_from(path.clone())
296-
.context("CA cert path is not valid UTF-8")?;
297-
debug!("Found CA certificate at alternate location: {}", ca_path);
298-
break;
299-
}
287+
for path in possible_paths.iter().flatten() {
288+
if path.exists() {
289+
ca_path = Utf8PathBuf::try_from(path.clone())
290+
.context("CA cert path is not valid UTF-8")?;
291+
debug!("Found CA certificate at alternate location: {}", ca_path);
292+
break;
300293
}
301294
}
302295

tests/common/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![allow(dead_code)] // These are utility functions used across different test modules
22

33
use std::process::Command;
4+
use std::str::FromStr;
45

56
/// Build httpjail binary and return the path
67
pub fn build_httpjail() -> Result<String, String> {

0 commit comments

Comments
 (0)