Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ insta-cmd = "0.7"
jiff = { version = "0.2.37", default-features = false, features = ["alloc"] }
openssl-sys = "0.9"
reqwest = { version = "0.13", default-features = false, features = ["charset", "h2", "http2", "json"] }
rand = "0.10"
regex = "1.12"
rustls = { version = "0.23", default-features = false }
rustls-pki-types = "1.13"
Expand Down
1 change: 0 additions & 1 deletion upki-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ tracing-subscriber.workspace = true
jiff.workspace = true
insta.workspace = true
insta-cmd.workspace = true
rand.workspace = true
regex.workspace = true
tempfile.workspace = true
tiny_http.workspace = true
Expand Down
20 changes: 11 additions & 9 deletions upki-cli/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use insta::assert_snapshot;
use insta::internals::SettingsBindDropGuard;
use insta_cmd::assert_cmd_snapshot;
use jiff::fmt::rfc2822::DateTimeParser;
use rand::RngExt;
use tempfile::TempDir;

#[test]
Expand Down Expand Up @@ -548,16 +547,13 @@ fn upki() -> Command {
}

fn http_server(root: &str, conditional: bool) -> (TestHttpServer, SettingsBindDropGuard) {
let port = rand::rng().random_range(4000..12000);
let server = TestHttpServer::new(("127.0.0.1", 0), Path::new(root), conditional).unwrap();

// add a filter eliding the (random) port in logs
// add a filter eliding the (OS-assigned) port in logs
let mut current_filters = insta::Settings::clone_current();
current_filters.add_filter(&format!(":{port}/"), ":[PORT]/");
current_filters.add_filter(&format!(":{}/", server.port), ":[PORT]/");

(
TestHttpServer::new(("127.0.0.1", port), Path::new(root), conditional).unwrap(),
current_filters.bind_to_scope(),
)
(server, current_filters.bind_to_scope())
}

fn list_dir(path: &Path) -> Vec<String> {
Expand Down Expand Up @@ -620,6 +616,7 @@ fn apply_common_filters() -> SettingsBindDropGuard {

pub struct TestHttpServer {
server: Arc<tiny_http::Server>,
port: u16,
url: String,
handle: Option<thread::JoinHandle<String>>,
}
Expand All @@ -631,6 +628,10 @@ impl TestHttpServer {
conditional: bool,
) -> Result<Self, Box<dyn Error + Send + Sync>> {
let server = Arc::new(tiny_http::Server::http(addr)?);
let addr = server
.server_addr()
.to_ip()
.ok_or("server is not listening on an IP address")?;

let thread_server = server.clone();
let server_root = server_root.to_owned();
Expand Down Expand Up @@ -669,7 +670,8 @@ impl TestHttpServer {

Ok(Self {
server,
url: format!("http://{}:{}/", addr.0, addr.1),
port: addr.port(),
url: format!("http://{addr}/"),
handle: Some(joiner),
})
}
Expand Down
Loading