From 63b6933cefc2c4bd438aa335072c177bfe2e8388 Mon Sep 17 00:00:00 2001 From: Sam Greenbury Date: Mon, 13 Jan 2025 18:03:51 +0000 Subject: [PATCH] Add assert that port 8081 is not in use --- Cargo.toml | 1 + README.md | 2 +- crates/trustchain-http/Cargo.toml | 1 + crates/trustchain-http/tests/attestation.rs | 7 ++++++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2f0ffb06..3e0ef574 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,6 +45,7 @@ log = "0.4" mockall = "0.11.4" mongodb = "2.3.1" petgraph = "0.6" +port_check = "0.2.1" ps_sig = { git = "https://github.com/alan-turing-institute/RSS.git", rev = "ec9386e125d87c5f54898b34fbe0883b3b36ffd4" } qrcode = "0.12.0" rand = "0.8" diff --git a/README.md b/README.md index 27c3edf9..7eb30e6d 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ cargo build ``` Install the Trustchain CLI with: ```shell -cargo install --path trustchain-cli +cargo install --path crates/trustchain-cli ``` ## Usage Guide diff --git a/crates/trustchain-http/Cargo.toml b/crates/trustchain-http/Cargo.toml index 1f38faef..a52cc3ac 100644 --- a/crates/trustchain-http/Cargo.toml +++ b/crates/trustchain-http/Cargo.toml @@ -44,4 +44,5 @@ trustchain-ion = { path = "../trustchain-ion" } axum-test-helper = { workspace = true } itertools = { workspace = true } mockall = { workspace = true } +port_check = { workspace = true } tempfile = { workspace = true } diff --git a/crates/trustchain-http/tests/attestation.rs b/crates/trustchain-http/tests/attestation.rs index 8ef1c6d0..310655b0 100644 --- a/crates/trustchain-http/tests/attestation.rs +++ b/crates/trustchain-http/tests/attestation.rs @@ -1,4 +1,5 @@ -/// Integration test for attestation challenge-response process. +//! Integration test for attestation challenge-response process. +use port_check::is_port_reachable; use tokio::runtime::Runtime; use trustchain_core::verifier::Verifier; use trustchain_http::attestation_encryption_utils::{josekit_to_ssi_jwk, ssi_to_josekit_jwk}; @@ -27,6 +28,10 @@ pub trait AttestationUtils { fn init_http() { init(); + assert!( + !is_port_reachable("127.0.0.1:8081"), + "Port 8081 is required for Challenge-Response integration test but 8081 is already in use." + ); let http_config = HTTPConfig { host: "127.0.0.1".parse().unwrap(), port: 8081,