Add new test for client configuration
This commit is contained in:
41
src/test/client_invalid_tls_root_certificate_file.rs
Normal file
41
src/test/client_invalid_tls_root_certificate_file.rs
Normal file
@ -0,0 +1,41 @@
|
||||
use crate::tcp_relay_client::client_config::ClientConfig;
|
||||
use crate::test::pki::Pki;
|
||||
use crate::test::{get_port_number, PortsAllocation, LOCALHOST_IP};
|
||||
|
||||
const VALID_TOKEN: &str = "AvalidTOKEN";
|
||||
|
||||
fn port(index: u16) -> u16 {
|
||||
get_port_number(PortsAllocation::TestsWithoutPortOpened, index)
|
||||
}
|
||||
|
||||
#[tokio::test()]
|
||||
async fn invalid_file_type() {
|
||||
let _ = env_logger::builder().is_test(true).try_init();
|
||||
|
||||
let pki = Pki::load();
|
||||
|
||||
crate::tcp_relay_client::run_app(ClientConfig {
|
||||
token: Some(VALID_TOKEN.to_string()),
|
||||
relay_url: format!("https://{}:{}", LOCALHOST_IP, port(0)),
|
||||
listen_address: LOCALHOST_IP.to_string(),
|
||||
root_certificate: Some(pki.expired_client_key.file_path()),
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
.unwrap_err();
|
||||
}
|
||||
|
||||
#[tokio::test()]
|
||||
async fn non_existing_file() {
|
||||
let _ = env_logger::builder().is_test(true).try_init();
|
||||
|
||||
crate::tcp_relay_client::run_app(ClientConfig {
|
||||
token: Some(VALID_TOKEN.to_string()),
|
||||
relay_url: format!("https://{}:{}", LOCALHOST_IP, port(0)),
|
||||
listen_address: LOCALHOST_IP.to_string(),
|
||||
root_certificate: Some("/bad/path/to/file".to_string()),
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
.unwrap_err();
|
||||
}
|
@ -24,13 +24,14 @@ mod dummy_tcp_sockets;
|
||||
mod pki;
|
||||
mod test_files_utils;
|
||||
|
||||
mod client_invalid_tls_root_certificate_file;
|
||||
mod client_try_tls_while_there_is_no_tls;
|
||||
mod invalid_token_file;
|
||||
mod invalid_with_token_auth;
|
||||
mod server_invalid_tls_config_invalid_cert;
|
||||
mod server_invalid_tls_config_invalid_key;
|
||||
mod server_invalid_tls_config_invalid_paths;
|
||||
mod server_invalid_tls_config_missing_key;
|
||||
mod server_invalid_token_file;
|
||||
mod valid_token_with_custom_increment;
|
||||
mod valid_with_multiple_token_auth;
|
||||
mod valid_with_token_auth;
|
||||
|
Reference in New Issue
Block a user