Add end2end tests #2
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,3 @@
|
|||||||
target
|
target
|
||||||
.idea
|
.idea
|
||||||
*.crt
|
|
||||||
*.key
|
|
||||||
pki
|
pki
|
||||||
|
20
Cargo.lock
generated
20
Cargo.lock
generated
@ -1042,6 +1042,15 @@ dependencies = [
|
|||||||
"windows-sys",
|
"windows-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mktemp"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "975de676448231fcde04b9149d2543077e166b78fc29eae5aa219e7928410da2"
|
||||||
|
dependencies = [
|
||||||
|
"uuid",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nom"
|
name = "nom"
|
||||||
version = "7.1.1"
|
version = "7.1.1"
|
||||||
@ -1602,7 +1611,9 @@ dependencies = [
|
|||||||
"futures",
|
"futures",
|
||||||
"hyper-rustls",
|
"hyper-rustls",
|
||||||
"log",
|
"log",
|
||||||
|
"mktemp",
|
||||||
"pem",
|
"pem",
|
||||||
|
"rand",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"rustls",
|
"rustls",
|
||||||
"rustls-pemfile",
|
"rustls-pemfile",
|
||||||
@ -1872,6 +1883,15 @@ version = "0.7.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
|
checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "uuid"
|
||||||
|
version = "0.8.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version_check"
|
name = "version_check"
|
||||||
version = "0.9.4"
|
version = "0.9.4"
|
||||||
|
@ -25,3 +25,7 @@ hyper-rustls = { version = "0.23.0", features = ["rustls-native-certs"] }
|
|||||||
bytes = "1.2.1"
|
bytes = "1.2.1"
|
||||||
rustls-pemfile = "1.0.1"
|
rustls-pemfile = "1.0.1"
|
||||||
rustls = "0.20.6"
|
rustls = "0.20.6"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
rand = "0.8.5"
|
||||||
|
mktemp = "0.4.1"
|
@ -50,10 +50,10 @@ pub fn parse_pem_private_key(privkey: &[u8]) -> Result<PrivateKey, Box<dyn Error
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use crate::cert_utils::{parse_pem_certificates, parse_pem_private_key};
|
use crate::base::cert_utils::{parse_pem_certificates, parse_pem_private_key};
|
||||||
|
|
||||||
const SAMPLE_CERT: &[u8] = include_bytes!("../samples/TCPTunnelTest.crt");
|
const SAMPLE_CERT: &[u8] = include_bytes!("samples/TCPTunnelTest.crt");
|
||||||
const SAMPLE_KEY: &[u8] = include_bytes!("../samples/TCPTunnelTest.key");
|
const SAMPLE_KEY: &[u8] = include_bytes!("samples/TCPTunnelTest.key");
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_valid_cert() {
|
fn parse_valid_cert() {
|
||||||
|
12
src/base/err_utils.rs
Normal file
12
src/base/err_utils.rs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
use std::fmt::Display;
|
||||||
|
use std::io::ErrorKind;
|
||||||
|
|
||||||
|
/// Encapsulate errors in [`std::io::Error`] with a message
|
||||||
|
pub fn encpasulate_error<E: Display, F: ToString>(e: E, msg: F) -> std::io::Error {
|
||||||
|
std::io::Error::new(ErrorKind::Other, format!("{}:\n* {}", msg.to_string(), e))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Create a new [`std::io::Error`]
|
||||||
|
pub fn new_err(msg: &str) -> std::io::Error {
|
||||||
|
std::io::Error::new(ErrorKind::Other, msg.to_string())
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
pub mod cert_utils;
|
pub mod cert_utils;
|
||||||
|
pub mod err_utils;
|
||||||
mod structs;
|
mod structs;
|
||||||
|
|
||||||
pub use structs::{RelayedPort, RemoteConfig};
|
pub use structs::{RelayedPort, RemoteConfig};
|
||||||
|
29
src/base/samples/TCPTunnelTest.crt
Normal file
29
src/base/samples/TCPTunnelTest.crt
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIE8DCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADAYMRYwFAYDVQQDEw1UQ1BU
|
||||||
|
dW5uZWxUZXN0MB4XDTIyMDkwMTA2MzMyMFoXDTI0MDMwMTA2MzMxOFowGDEWMBQG
|
||||||
|
A1UEAxMNVENQVHVubmVsVGVzdDCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
|
||||||
|
ggIBALqh3EXg3TYq5TwZPjOX35bM7kol+fLlwjLaXCTx/lTXU0hTFsIa0kFCiPsT
|
||||||
|
Vhm5nwhDLxnAARagc74gUHfhr6meMbsje2NzylmCpW1As1s1xo2n8oNi2YsqIA9A
|
||||||
|
HWQWsihf7fPlyZOgBIwUQBsLd6ujpwbvaEhwBArS+peVYuB3zDbuNBJ2lqdvD5fa
|
||||||
|
8aCyoPyseaJcaMMJ3R2W/8OYrUsJECKgg26A8zxF55RdvjJcBONG0kRlNsrxS6uO
|
||||||
|
9dnQ8kyvUReluPgTEfZm/M54dCi9VvKVRKA/5md/+SQWwQhPyIig3+XXeYQNoUN6
|
||||||
|
YXvlWw704VBg/hDBqrY42LjpS/FyMGsp4cHVCMXBLwRNHWPfik6w3rNTpFp7h4Mm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mHOTr8430PebYc/G5BA+XjOgpFQ3vu8trIA/3Dbuyc
|
||||||
|
ggz1abiDnBmp+I66AYV+Ker81maM6CQU+03WKHbHZyJWr74SKuILY1knys/fXJvT
|
||||||
|
UZRMhmaQqxc1QcWVOkWLv0RcAhEjwIX0+36NUC1W35JfrRpHtmqIiJH9kjcjr94w
|
||||||
|
5sjM2EUFmMC5z0zjF9cSYKSHLSI=
|
||||||
|
-----END CERTIFICATE-----
|
51
src/base/samples/TCPTunnelTest.key
Normal file
51
src/base/samples/TCPTunnelTest.key
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIIJKAIBAAKCAgEAuqHcReDdNirlPBk+M5fflszuSiX58uXCMtpcJPH+VNdTSFMW
|
||||||
|
whrSQUKI+xNWGbmfCEMvGcABFqBzviBQd+GvqZ4xuyN7Y3PKWYKlbUCzWzXGjafy
|
||||||
|
g2LZiyogD0AdZBayKF/t8+XJk6AEjBRAGwt3q6OnBu9oSHAECtL6l5Vi4HfMNu40
|
||||||
|
EnaWp28Pl9rxoLKg/Kx5olxowwndHZb/w5itSwkQIqCDboDzPEXnlF2+MlwE40bS
|
||||||
|
RGU2yvFLq4712dDyTK9RF6W4+BMR9mb8znh0KL1W8pVEoD/mZ3/5JBbBCE/IiKDf
|
||||||
|
5dd5hA2hQ3phe+VbDvThUGD+EMGqtjjYuOlL8XIwaynhwdUIxcEvBE0dY9+KTrDe
|
||||||
|
s1OkWnuHgyZ59/FfZX/G4GvchyJVyyZ4PheZ+nSjqDejlU8rgohHn9v5op7u4vz/
|
||||||
|
2FNMtKpambz6TRugTv3r+Bvx6DIQvAGs+yt0ZAiIg/YBzqbneJO0S1x4g6YwH63u
|
||||||
|
ZQ+RAeyIugIt5GbZ1s9YQrPaY7x85WNVhP2fFj3aX8C966SxO6LkZnbPhlWnWbqk
|
||||||
|
DFWNV/4v9KAwyQR9whRbpdvwFr4phEJz/lTxeTPboXzR2GMZ16V51Ok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h0l4gNBl68pO02SmLawzI9ORD7/divB0OUjcu9UOscuSp/p5qTa
|
||||||
|
aYvKJMZYS/2Ts4yP0/FbQkxW2EQ/W1dtSlhW3I19J21hJnrJwglIhkPHlfZnsAuS
|
||||||
|
JNvsabMhfv4ogLVO1dFUWEIDyA3jgDKUR6me1mssWFy3hH32OqJD6kjFcsBT7WKz
|
||||||
|
D66Z0hV4gvGgbDlb/7/Edi/eGcZgRIaM9n5Zwe2ex71kZOU+cTr5liMrjxZYhJQv
|
||||||
|
vZt9ebAqLo00H7SOXFySksPHuUunniDhAoIBAFH3wC6kW3RLX7vuKqgZMLIR93ey
|
||||||
|
bJKwFFwBk7Jc4PT47sp7B8Vi58DOl4eFzktYhn5lh/YN9K/Tj1zLSEqJqxO+SBO+
|
||||||
|
irArxdHaUzQ1lzeRpvYxP3cB5ZBBDHvZCtNkmqfnGCxQtvoxuCt9m8brpfPAmZaW
|
||||||
|
8jrLNrWqvkxJE9GFfmZ8R+pTIFCBDRC6E2RuHFrQK5NCr717zDJ/OPe5GDmWp48d
|
||||||
|
GiPu+CUqew2yt9XQw7Ol+QVY6NVyqDAZR34jIc3/TtsISfYahN0zAxUHtW3BdAOF
|
||||||
|
HOfvisKnygWsUi7efFAVfRop5UUeoxDqGh/UvFy0JsUbFfeRynTH7FIwBSA=
|
||||||
|
-----END RSA PRIVATE KEY-----
|
@ -1,3 +1,6 @@
|
|||||||
mod base;
|
mod base;
|
||||||
pub mod tcp_relay_client;
|
pub mod tcp_relay_client;
|
||||||
pub mod tcp_relay_server;
|
pub mod tcp_relay_server;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test;
|
||||||
|
11
src/main.rs
11
src/main.rs
@ -36,3 +36,14 @@ async fn main() -> std::io::Result<()> {
|
|||||||
SubCommands::Client(c) => tcp_over_http::tcp_relay_client::run_app(c).await,
|
SubCommands::Client(c) => tcp_over_http::tcp_relay_client::run_app(c).await,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use crate::CliArgs;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn verify_cli() {
|
||||||
|
use clap::CommandFactory;
|
||||||
|
CliArgs::command().debug_assert()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
|
use crate::base::err_utils::encpasulate_error;
|
||||||
use bytes::BufMut;
|
use bytes::BufMut;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
/// TCP relay client
|
/// TCP relay client
|
||||||
#[derive(Parser, Debug, Clone)]
|
#[derive(Parser, Debug, Clone, Default)]
|
||||||
#[clap(author, version, about, long_about = None)]
|
#[clap(author, version, about, long_about = None)]
|
||||||
pub struct ClientConfig {
|
pub struct ClientConfig {
|
||||||
/// Access token
|
/// Access token
|
||||||
@ -21,41 +22,37 @@ pub struct ClientConfig {
|
|||||||
#[clap(short = 'c', long)]
|
#[clap(short = 'c', long)]
|
||||||
pub root_certificate: Option<String>,
|
pub root_certificate: Option<String>,
|
||||||
|
|
||||||
#[clap(skip)]
|
|
||||||
_root_certificate_cache: Option<Vec<u8>>,
|
|
||||||
|
|
||||||
/// TLS certificate for TLS authentication.
|
/// TLS certificate for TLS authentication.
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
pub tls_cert: Option<String>,
|
pub tls_cert: Option<String>,
|
||||||
|
|
||||||
#[clap(skip)]
|
|
||||||
_tls_cert_cache: Option<Vec<u8>>,
|
|
||||||
|
|
||||||
/// TLS key for TLS authentication.
|
/// TLS key for TLS authentication.
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
pub tls_key: Option<String>,
|
pub tls_key: Option<String>,
|
||||||
|
|
||||||
|
#[clap(skip)]
|
||||||
|
pub _keys_cache: KeysCache,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Parser, Debug, Clone, Default)]
|
||||||
|
pub struct KeysCache {
|
||||||
|
#[clap(skip)]
|
||||||
|
_root_certificate_cache: Option<Vec<u8>>,
|
||||||
|
#[clap(skip)]
|
||||||
|
_tls_cert_cache: Option<Vec<u8>>,
|
||||||
#[clap(skip)]
|
#[clap(skip)]
|
||||||
_tls_key_cache: Option<Vec<u8>>,
|
_tls_key_cache: Option<Vec<u8>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ClientConfig {
|
impl ClientConfig {
|
||||||
/// Load certificates and put them in cache
|
/// Load certificates and put them in cache
|
||||||
pub fn load_certificates(&mut self) {
|
pub fn load_certificates(&mut self) -> std::io::Result<()> {
|
||||||
self._root_certificate_cache = self
|
self._keys_cache = KeysCache {
|
||||||
.root_certificate
|
_root_certificate_cache: load_pem_file(&self.root_certificate, "root certificate")?,
|
||||||
.as_ref()
|
_tls_cert_cache: load_pem_file(&self.tls_cert, "client certificate")?,
|
||||||
.map(|c| std::fs::read(c).expect("Failed to read root certificate!"));
|
_tls_key_cache: load_pem_file(&self.tls_key, "client key")?,
|
||||||
|
};
|
||||||
self._tls_cert_cache = self
|
Ok(())
|
||||||
.tls_cert
|
|
||||||
.as_ref()
|
|
||||||
.map(|c| std::fs::read(c).expect("Failed to read client certificate!"));
|
|
||||||
|
|
||||||
self._tls_key_cache = self
|
|
||||||
.tls_key
|
|
||||||
.as_ref()
|
|
||||||
.map(|c| std::fs::read(c).expect("Failed to read client key!"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get client token, returning a dummy token if none was specified
|
/// Get client token, returning a dummy token if none was specified
|
||||||
@ -65,12 +62,15 @@ impl ClientConfig {
|
|||||||
|
|
||||||
/// Get root certificate content
|
/// Get root certificate content
|
||||||
pub fn get_root_certificate(&self) -> Option<Vec<u8>> {
|
pub fn get_root_certificate(&self) -> Option<Vec<u8>> {
|
||||||
self._root_certificate_cache.clone()
|
self._keys_cache._root_certificate_cache.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get client certificate & key pair, if available
|
/// Get client certificate & key pair, if available
|
||||||
pub fn get_client_keypair(&self) -> Option<(&Vec<u8>, &Vec<u8>)> {
|
pub fn get_client_keypair(&self) -> Option<(&Vec<u8>, &Vec<u8>)> {
|
||||||
if let (Some(cert), Some(key)) = (&self._tls_cert_cache, &self._tls_key_cache) {
|
if let (Some(cert), Some(key)) = (
|
||||||
|
&self._keys_cache._tls_cert_cache,
|
||||||
|
&self._keys_cache._tls_key_cache,
|
||||||
|
) {
|
||||||
Some((cert, key))
|
Some((cert, key))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@ -88,9 +88,19 @@ impl ClientConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn load_pem_file(path: &Option<String>, name: &str) -> std::io::Result<Option<Vec<u8>>> {
|
||||||
|
Ok(match path {
|
||||||
|
None => None,
|
||||||
|
Some(p) => Some(
|
||||||
|
std::fs::read(p)
|
||||||
|
.map_err(|e| encpasulate_error(e, format!("Failed to load {}!", name)))?,
|
||||||
|
),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use crate::client_config::ClientConfig;
|
use crate::tcp_relay_client::client_config::ClientConfig;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn verify_cli() {
|
fn verify_cli() {
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
extern crate core;
|
extern crate core;
|
||||||
|
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
use std::io::ErrorKind;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use futures::future::join_all;
|
use futures::future::join_all;
|
||||||
use reqwest::{Certificate, Identity};
|
use reqwest::{Certificate, Identity};
|
||||||
|
|
||||||
|
use crate::base::err_utils::{encpasulate_error, new_err};
|
||||||
use crate::base::RemoteConfig;
|
use crate::base::RemoteConfig;
|
||||||
use crate::tcp_relay_client::client_config::ClientConfig;
|
use crate::tcp_relay_client::client_config::ClientConfig;
|
||||||
use crate::tcp_relay_client::relay_client::relay_client;
|
use crate::tcp_relay_client::relay_client::relay_client;
|
||||||
@ -27,7 +29,8 @@ async fn get_server_config(conf: &ClientConfig) -> Result<RemoteConfig, Box<dyn
|
|||||||
|
|
||||||
// Specify client certificate, if any
|
// Specify client certificate, if any
|
||||||
if let Some(kp) = conf.get_merged_client_keypair() {
|
if let Some(kp) = conf.get_merged_client_keypair() {
|
||||||
let identity = Identity::from_pem(&kp).expect("Failed to load certificates for reqwest!");
|
let identity = Identity::from_pem(&kp)
|
||||||
|
.map_err(|e| encpasulate_error(e, "Failed to load certificates for reqwest!"))?;
|
||||||
client = client.identity(identity).use_rustls_tls();
|
client = client.identity(identity).use_rustls_tls();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,11 +42,13 @@ async fn get_server_config(conf: &ClientConfig) -> Result<RemoteConfig, Box<dyn
|
|||||||
.send()
|
.send()
|
||||||
.await?;
|
.await?;
|
||||||
if req.status().as_u16() != 200 {
|
if req.status().as_u16() != 200 {
|
||||||
log::error!(
|
Err(std::io::Error::new(
|
||||||
|
ErrorKind::Other,
|
||||||
|
format!(
|
||||||
"Could not retrieve configuration! (got status {})",
|
"Could not retrieve configuration! (got status {})",
|
||||||
req.status()
|
req.status()
|
||||||
);
|
),
|
||||||
std::process::exit(2);
|
))?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(req.json::<RemoteConfig>().await?)
|
Ok(req.json::<RemoteConfig>().await?)
|
||||||
@ -51,15 +56,14 @@ async fn get_server_config(conf: &ClientConfig) -> Result<RemoteConfig, Box<dyn
|
|||||||
|
|
||||||
/// Core logic of the application
|
/// Core logic of the application
|
||||||
pub async fn run_app(mut args: ClientConfig) -> std::io::Result<()> {
|
pub async fn run_app(mut args: ClientConfig) -> std::io::Result<()> {
|
||||||
args.load_certificates();
|
args.load_certificates()?;
|
||||||
let args = Arc::new(args);
|
let args = Arc::new(args);
|
||||||
|
|
||||||
// Check arguments coherence
|
// Check arguments coherence
|
||||||
if args.tls_cert.is_some() != args.tls_key.is_some() {
|
if args.tls_cert.is_some() != args.tls_key.is_some() {
|
||||||
log::error!(
|
return Err(new_err(
|
||||||
"If you specify one of TLS certificate / key, you must then specify the other!"
|
"If you specify one of TLS certificate / key, you must then specify the other!",
|
||||||
);
|
));
|
||||||
panic!();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if args.get_client_keypair().is_some() {
|
if args.get_client_keypair().is_some() {
|
||||||
@ -70,8 +74,11 @@ pub async fn run_app(mut args: ClientConfig) -> std::io::Result<()> {
|
|||||||
let remote_conf = match get_server_config(&args).await {
|
let remote_conf = match get_server_config(&args).await {
|
||||||
Ok(c) => c,
|
Ok(c) => c,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("Failed to fetch relay configuration from server! {}", e);
|
Err(std::io::Error::new(
|
||||||
panic!();
|
ErrorKind::Other,
|
||||||
|
format!("Failed to fetch relay configuration from server! {}", e),
|
||||||
|
))?;
|
||||||
|
unreachable!();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ use std::sync::Arc;
|
|||||||
use actix_web::web::Data;
|
use actix_web::web::Data;
|
||||||
use actix_web::{middleware, web, App, HttpRequest, HttpResponse, HttpServer, Responder};
|
use actix_web::{middleware, web, App, HttpRequest, HttpResponse, HttpServer, Responder};
|
||||||
|
|
||||||
|
use crate::base::err_utils::{encpasulate_error, new_err};
|
||||||
use crate::base::{cert_utils, RelayedPort};
|
use crate::base::{cert_utils, RelayedPort};
|
||||||
|
|
||||||
use crate::tcp_relay_server::relay_ws::relay_ws;
|
use crate::tcp_relay_server::relay_ws::relay_ws;
|
||||||
use crate::tcp_relay_server::server_config::ServerConfig;
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
use crate::tcp_relay_server::tls_cert_client_verifier::CustomCertClientVerifier;
|
use crate::tcp_relay_server::tls_cert_client_verifier::CustomCertClientVerifier;
|
||||||
@ -47,27 +47,30 @@ pub async fn config_route(req: HttpRequest, data: Data<Arc<ServerConfig>>) -> im
|
|||||||
pub async fn run_app(mut config: ServerConfig) -> std::io::Result<()> {
|
pub async fn run_app(mut config: ServerConfig) -> std::io::Result<()> {
|
||||||
// Check if no port are to be forwarded
|
// Check if no port are to be forwarded
|
||||||
if config.ports.is_empty() {
|
if config.ports.is_empty() {
|
||||||
log::error!("No port to forward!");
|
return Err(new_err("No port to forward!"));
|
||||||
std::process::exit(2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read tokens from file, if any
|
// Read tokens from file, if any
|
||||||
if let Some(file) = &config.tokens_file {
|
if let Some(file) = &config.tokens_file {
|
||||||
std::fs::read_to_string(file)
|
std::fs::read_to_string(file)
|
||||||
.expect("Failed to read tokens file!")
|
.map_err(|e| encpasulate_error(e, "Failed to read tokens file!"))?
|
||||||
.split('\n')
|
.split('\n')
|
||||||
.filter(|l| !l.is_empty())
|
.filter(|l| !l.is_empty())
|
||||||
.for_each(|t| config.tokens.push(t.to_string()));
|
.for_each(|t| config.tokens.push(t.to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if !config.has_auth() {
|
if !config.has_auth() {
|
||||||
log::error!("No authentication method specified!");
|
return Err(new_err("No authentication method specified!"));
|
||||||
std::process::exit(3);
|
}
|
||||||
|
|
||||||
|
if config.tls_cert.is_some() != config.tls_key.is_some() {
|
||||||
|
return Err(new_err("Incomplete server TLS configuration!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.has_tls_client_auth() && !config.has_tls_config() {
|
if config.has_tls_client_auth() && !config.has_tls_config() {
|
||||||
log::error!("Cannot provide client auth without TLS configuration!");
|
return Err(new_err(
|
||||||
panic!();
|
"Cannot provide client auth without TLS configuration!",
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let args = Arc::new(config);
|
let args = Arc::new(config);
|
||||||
@ -75,22 +78,24 @@ pub async fn run_app(mut config: ServerConfig) -> std::io::Result<()> {
|
|||||||
// Load TLS configuration, if any
|
// Load TLS configuration, if any
|
||||||
let tls_config = if let (Some(cert), Some(key)) = (&args.tls_cert, &args.tls_key) {
|
let tls_config = if let (Some(cert), Some(key)) = (&args.tls_cert, &args.tls_key) {
|
||||||
// Load TLS certificate & private key
|
// Load TLS certificate & private key
|
||||||
let cert_file = std::fs::read(cert).expect("Failed to read certificate file");
|
let cert_file = std::fs::read(cert)
|
||||||
let key_file = std::fs::read(key).expect("Failed to read server private key");
|
.map_err(|e| encpasulate_error(e, "Failed to read certificate file"))?;
|
||||||
|
let key_file = std::fs::read(key)
|
||||||
|
.map_err(|e| encpasulate_error(e, "Failed to read server private key"))?;
|
||||||
|
|
||||||
// Get certificates chain
|
// Get certificates chain
|
||||||
let cert_chain =
|
let cert_chain = cert_utils::parse_pem_certificates(&cert_file)
|
||||||
cert_utils::parse_pem_certificates(&cert_file).expect("Failed to extract certificates");
|
.map_err(|e| encpasulate_error(e, "Failed to extract certificates"))?;
|
||||||
|
|
||||||
// Get private key
|
// Get private key
|
||||||
let key =
|
let key = cert_utils::parse_pem_private_key(&key_file)
|
||||||
cert_utils::parse_pem_private_key(&key_file).expect("Failed to extract private key!");
|
.map_err(|e| encpasulate_error(e, "Failed to extract private key!"))?;
|
||||||
|
|
||||||
let config = rustls::ServerConfig::builder().with_safe_defaults();
|
let config = rustls::ServerConfig::builder().with_safe_defaults();
|
||||||
|
|
||||||
let config = match args.has_tls_client_auth() {
|
let config = match args.has_tls_client_auth() {
|
||||||
true => config
|
true => config
|
||||||
.with_client_cert_verifier(Arc::new(CustomCertClientVerifier::new(args.clone()))),
|
.with_client_cert_verifier(Arc::new(CustomCertClientVerifier::new(args.clone())?)),
|
||||||
false => config.with_no_client_auth(),
|
false => config.with_no_client_auth(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ impl ServerConfig {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use crate::server_config::ServerConfig;
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn verify_cli() {
|
fn verify_cli() {
|
||||||
|
@ -7,7 +7,7 @@ use rustls::{Certificate, DistinguishedNames, Error, RootCertStore};
|
|||||||
use x509_parser::prelude::{CertificateRevocationList, FromDer, X509Certificate};
|
use x509_parser::prelude::{CertificateRevocationList, FromDer, X509Certificate};
|
||||||
|
|
||||||
use crate::base::cert_utils::parse_pem_certificates;
|
use crate::base::cert_utils::parse_pem_certificates;
|
||||||
|
use crate::base::err_utils::{encpasulate_error, new_err};
|
||||||
use crate::tcp_relay_server::server_config::ServerConfig;
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
|
|
||||||
pub struct CustomCertClientVerifier {
|
pub struct CustomCertClientVerifier {
|
||||||
@ -16,21 +16,28 @@ pub struct CustomCertClientVerifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CustomCertClientVerifier {
|
impl CustomCertClientVerifier {
|
||||||
pub fn new(conf: Arc<ServerConfig>) -> Self {
|
pub fn new(conf: Arc<ServerConfig>) -> std::io::Result<Self> {
|
||||||
// Build root certifications list
|
// Build root certifications list
|
||||||
let cert_path = conf
|
let cert_path = conf
|
||||||
.tls_client_auth_root_cert
|
.tls_client_auth_root_cert
|
||||||
.as_deref()
|
.as_deref()
|
||||||
.expect("No root certificates for client authentication provided!");
|
.expect("No root certificates for client authentication provided!");
|
||||||
let cert_file = std::fs::read(cert_path)
|
let cert_file = std::fs::read(cert_path).map_err(|e| {
|
||||||
.expect("Failed to read root certificates for client authentication!");
|
encpasulate_error(
|
||||||
|
e,
|
||||||
|
"Failed to read root certificates for client authentication!",
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
|
||||||
let root_certs = parse_pem_certificates(&cert_file)
|
let root_certs = parse_pem_certificates(&cert_file).map_err(|e| {
|
||||||
.expect("Failed to read root certificates for server authentication!");
|
encpasulate_error(
|
||||||
|
e,
|
||||||
|
"Failed to read root certificates for server authentication!",
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
|
||||||
if root_certs.is_empty() {
|
if root_certs.is_empty() {
|
||||||
log::error!("No certificates found for client authentication!");
|
return Err(new_err("No certificates found for client authentication!"));
|
||||||
panic!();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut store = RootCertStore::empty();
|
let mut store = RootCertStore::empty();
|
||||||
@ -42,19 +49,21 @@ impl CustomCertClientVerifier {
|
|||||||
|
|
||||||
// Parse CRL file (if any)
|
// Parse CRL file (if any)
|
||||||
let crl = if let Some(crl_file) = &conf.tls_revocation_list {
|
let crl = if let Some(crl_file) = &conf.tls_revocation_list {
|
||||||
let crl_file = std::fs::read(crl_file).expect("Failed to open / read CRL file!");
|
let crl_file = std::fs::read(crl_file)
|
||||||
|
.map_err(|e| encpasulate_error(e, "Failed to open / read CRL file!"))?;
|
||||||
|
|
||||||
let parsed_crl = pem::parse(crl_file).expect("Failed to decode CRL file!");
|
let parsed_crl = pem::parse(crl_file)
|
||||||
|
.map_err(|e| encpasulate_error(e, "Failed to decode CRL file!"))?;
|
||||||
|
|
||||||
Some(parsed_crl.contents)
|
Some(parsed_crl.contents)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
Self {
|
Ok(Self {
|
||||||
upstream_cert_verifier: Box::new(AllowAnyAuthenticatedClient::new(store)),
|
upstream_cert_verifier: Box::new(AllowAnyAuthenticatedClient::new(store)),
|
||||||
crl,
|
crl,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
159
src/test/client_invalid_tls_configuration.rs
Normal file
159
src/test/client_invalid_tls_configuration.rs
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
use tokio::task;
|
||||||
|
|
||||||
|
use crate::tcp_relay_client::client_config::ClientConfig;
|
||||||
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
|
use crate::test::{BAD_PATH, get_port_number, LOCALHOST_IP, PortsAllocation};
|
||||||
|
use crate::test::dummy_tcp_sockets::wait_for_port;
|
||||||
|
use crate::test::pki::Pki;
|
||||||
|
use crate::test::test_files_utils::create_temp_file_with_random_content;
|
||||||
|
|
||||||
|
fn port(index: u16) -> u16 {
|
||||||
|
get_port_number(PortsAllocation::ClientInvalidTlsConfiguration, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test()]
|
||||||
|
async fn random_file_for_cert() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
let random_file = create_temp_file_with_random_content();
|
||||||
|
|
||||||
|
crate::tcp_relay_client::run_app(ClientConfig {
|
||||||
|
token: Some("token".to_string()),
|
||||||
|
relay_url: format!("https://{}:{}", LOCALHOST_IP, port(0)),
|
||||||
|
listen_address: LOCALHOST_IP.to_string(),
|
||||||
|
tls_cert: Some(random_file.to_string_lossy().to_string()),
|
||||||
|
tls_key: Some(pki.valid_client_key.file_path()),
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test()]
|
||||||
|
async fn random_file_for_key() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
let random_file = create_temp_file_with_random_content();
|
||||||
|
|
||||||
|
crate::tcp_relay_client::run_app(ClientConfig {
|
||||||
|
token: Some("token".to_string()),
|
||||||
|
relay_url: format!("https://{}:{}", LOCALHOST_IP, port(0)),
|
||||||
|
listen_address: LOCALHOST_IP.to_string(),
|
||||||
|
tls_cert: Some(pki.valid_client_crt.file_path()),
|
||||||
|
tls_key: Some(random_file.to_string_lossy().to_string()),
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test()]
|
||||||
|
async fn bad_pem_file_for_cert() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
crate::tcp_relay_client::run_app(ClientConfig {
|
||||||
|
token: Some("token".to_string()),
|
||||||
|
relay_url: format!("https://{}:{}", LOCALHOST_IP, port(0)),
|
||||||
|
listen_address: LOCALHOST_IP.to_string(),
|
||||||
|
tls_cert: Some(pki.root_ca_crl.file_path()),
|
||||||
|
tls_key: Some(pki.valid_client_key.file_path()),
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test()]
|
||||||
|
async fn bad_pem_file_for_key() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
crate::tcp_relay_client::run_app(ClientConfig {
|
||||||
|
token: Some("token".to_string()),
|
||||||
|
relay_url: format!("https://{}:{}", LOCALHOST_IP, port(0)),
|
||||||
|
listen_address: LOCALHOST_IP.to_string(),
|
||||||
|
tls_cert: Some(pki.valid_client_crt.file_path()),
|
||||||
|
tls_key: Some(pki.root_ca_crl.file_path()),
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test()]
|
||||||
|
async fn non_existing_cert() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
crate::tcp_relay_client::run_app(ClientConfig {
|
||||||
|
token: Some("token".to_string()),
|
||||||
|
relay_url: format!("https://{}:{}", LOCALHOST_IP, port(0)),
|
||||||
|
listen_address: LOCALHOST_IP.to_string(),
|
||||||
|
tls_cert: Some(BAD_PATH.to_string()),
|
||||||
|
tls_key: Some(pki.valid_client_key.file_path()),
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test()]
|
||||||
|
async fn non_existing_key() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
crate::tcp_relay_client::run_app(ClientConfig {
|
||||||
|
token: Some("token".to_string()),
|
||||||
|
relay_url: format!("https://{}:{}", LOCALHOST_IP, port(0)),
|
||||||
|
listen_address: LOCALHOST_IP.to_string(),
|
||||||
|
tls_cert: Some(pki.valid_client_crt.file_path()),
|
||||||
|
tls_key: Some(BAD_PATH.to_string()),
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test()]
|
||||||
|
async fn unmatched_key_cert_pair() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
let local_set = task::LocalSet::new();
|
||||||
|
local_set
|
||||||
|
.run_until(async move {
|
||||||
|
// Start server relay
|
||||||
|
task::spawn_local(crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec!["dqsd".to_string()],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: Some(pki.localhost_crt.file_path()),
|
||||||
|
tls_key: Some(pki.localhost_key.file_path()),
|
||||||
|
tls_client_auth_root_cert: Some(pki.root_ca_crt.file_path()),
|
||||||
|
tls_revocation_list: None,
|
||||||
|
}));
|
||||||
|
wait_for_port(port(0)).await;
|
||||||
|
|
||||||
|
crate::tcp_relay_client::run_app(ClientConfig {
|
||||||
|
token: Some("token".to_string()),
|
||||||
|
relay_url: format!("https://localhost:{}", port(0)),
|
||||||
|
listen_address: LOCALHOST_IP.to_string(),
|
||||||
|
tls_cert: Some(pki.valid_client_crt.file_path()),
|
||||||
|
tls_key: Some(pki.revoked_client_key.file_path()),
|
||||||
|
root_certificate: Some(pki.root_ca_crt.file_path()),
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}).await;
|
||||||
|
}
|
59
src/test/client_invalid_tls_root_certificate_file.rs
Normal file
59
src/test/client_invalid_tls_root_certificate_file.rs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
use crate::tcp_relay_client::client_config::ClientConfig;
|
||||||
|
use crate::test::{BAD_PATH, get_port_number, LOCALHOST_IP, PortsAllocation};
|
||||||
|
use crate::test::pki::Pki;
|
||||||
|
use crate::test::test_files_utils::create_temp_file_with_random_content;
|
||||||
|
|
||||||
|
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_string()),
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test()]
|
||||||
|
async fn random_file() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let random_file = create_temp_file_with_random_content();
|
||||||
|
|
||||||
|
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(random_file.to_string_lossy().to_string()),
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
55
src/test/client_try_tls_while_there_is_no_tls.rs
Normal file
55
src/test/client_try_tls_while_there_is_no_tls.rs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
use tokio::task;
|
||||||
|
|
||||||
|
use crate::tcp_relay_client::client_config::ClientConfig;
|
||||||
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
|
use crate::test::dummy_tcp_sockets::{wait_for_port, DummyTCPServer};
|
||||||
|
use crate::test::{get_port_number, PortsAllocation, LOCALHOST_IP};
|
||||||
|
|
||||||
|
const VALID_TOKEN: &str = "AvalidTOKEN";
|
||||||
|
|
||||||
|
fn port(index: u16) -> u16 {
|
||||||
|
get_port_number(PortsAllocation::ClientTryTLSWhileThereIsNoTLS, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test()]
|
||||||
|
async fn test() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
// Start internal service
|
||||||
|
let local_server = DummyTCPServer::start(port(1)).await;
|
||||||
|
tokio::spawn(async move {
|
||||||
|
local_server.loop_conn_square_operations().await;
|
||||||
|
});
|
||||||
|
|
||||||
|
let local_set = task::LocalSet::new();
|
||||||
|
local_set
|
||||||
|
.run_until(async move {
|
||||||
|
wait_for_port(port(1)).await;
|
||||||
|
|
||||||
|
// Start server relay
|
||||||
|
task::spawn_local(crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![VALID_TOKEN.to_string()],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: None,
|
||||||
|
tls_key: None,
|
||||||
|
tls_client_auth_root_cert: None,
|
||||||
|
tls_revocation_list: None,
|
||||||
|
}));
|
||||||
|
wait_for_port(port(0)).await;
|
||||||
|
|
||||||
|
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: None,
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
}
|
339
src/test/dummy_tcp_sockets.rs
Normal file
339
src/test/dummy_tcp_sockets.rs
Normal file
@ -0,0 +1,339 @@
|
|||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use rand::Rng;
|
||||||
|
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||||
|
use tokio::net::{TcpListener, TcpStream};
|
||||||
|
use tokio::time;
|
||||||
|
|
||||||
|
use crate::test::LOCALHOST_IP;
|
||||||
|
|
||||||
|
pub struct DummyTCPServer(TcpListener);
|
||||||
|
|
||||||
|
impl DummyTCPServer {
|
||||||
|
pub async fn start(port: u16) -> Self {
|
||||||
|
let addr = format!("{}:{}", LOCALHOST_IP, port);
|
||||||
|
println!("[DUMMY TCP] Listen on {}", addr);
|
||||||
|
let listener = TcpListener::bind(addr)
|
||||||
|
.await
|
||||||
|
.expect("Failed to bind dummy TCP listener!");
|
||||||
|
Self(listener)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Receive chunk of data from following connection
|
||||||
|
pub async fn read_next_connection(&self) -> Vec<u8> {
|
||||||
|
let (mut conn, _addr) = self
|
||||||
|
.0
|
||||||
|
.accept()
|
||||||
|
.await
|
||||||
|
.expect("Could not open next connection!");
|
||||||
|
|
||||||
|
let mut buff = Vec::with_capacity(100);
|
||||||
|
conn.read_to_end(&mut buff).await.unwrap();
|
||||||
|
|
||||||
|
buff
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Receive chunk of data from following connection
|
||||||
|
pub async fn read_then_write_next_connection(&self, to_send: &[u8]) -> Vec<u8> {
|
||||||
|
let (mut conn, _addr) = self
|
||||||
|
.0
|
||||||
|
.accept()
|
||||||
|
.await
|
||||||
|
.expect("Could not open next connection!");
|
||||||
|
|
||||||
|
let mut buff: [u8; 100] = [0; 100];
|
||||||
|
let size = conn.read(&mut buff).await.unwrap();
|
||||||
|
|
||||||
|
conn.write_all(to_send).await.unwrap();
|
||||||
|
|
||||||
|
buff[0..size].to_vec()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Receive chunk of data from following connection
|
||||||
|
pub async fn write_next_connection(&self, to_send: &[u8]) {
|
||||||
|
let (mut conn, _addr) = self
|
||||||
|
.0
|
||||||
|
.accept()
|
||||||
|
.await
|
||||||
|
.expect("Could not open next connection!");
|
||||||
|
|
||||||
|
conn.write_all(to_send).await.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Perform complex exchange: receive numbers from client and respond with their square
|
||||||
|
pub async fn next_conn_square_operations(&self) {
|
||||||
|
let (mut conn, _addr) = self
|
||||||
|
.0
|
||||||
|
.accept()
|
||||||
|
.await
|
||||||
|
.expect("Could not open next connection!");
|
||||||
|
|
||||||
|
let mut buff: [u8; 100] = [0; 100];
|
||||||
|
loop {
|
||||||
|
let size = conn.read(&mut buff).await.unwrap();
|
||||||
|
if size == 0 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
let content = String::from_utf8_lossy(&buff[0..size])
|
||||||
|
.to_string()
|
||||||
|
.parse::<i64>()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
conn.write_all((content * content).to_string().as_bytes())
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn loop_conn_square_operations(&self) {
|
||||||
|
loop {
|
||||||
|
self.next_conn_square_operations().await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Perform complex exchange: receive numbers from client and respond with their value + a given number
|
||||||
|
pub async fn next_conn_add_operations(&self, inc: i32) {
|
||||||
|
let (mut conn, _addr) = self
|
||||||
|
.0
|
||||||
|
.accept()
|
||||||
|
.await
|
||||||
|
.expect("Could not open next connection!");
|
||||||
|
|
||||||
|
let mut buff: [u8; 100] = [0; 100];
|
||||||
|
loop {
|
||||||
|
let size = conn.read(&mut buff).await.unwrap();
|
||||||
|
if size == 0 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
let content = String::from_utf8_lossy(&buff[0..size])
|
||||||
|
.to_string()
|
||||||
|
.parse::<i64>()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
conn.write_all((content + inc as i64).to_string().as_bytes())
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn loop_next_conn_add_operations(&self, inc: i32) {
|
||||||
|
loop {
|
||||||
|
self.next_conn_add_operations(inc).await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn dummy_tcp_client_read_conn(port: u16) -> Vec<u8> {
|
||||||
|
let mut socket = TcpStream::connect(format!("127.0.0.1:{}", port))
|
||||||
|
.await
|
||||||
|
.expect("Failed to connect to dummy TCP server!");
|
||||||
|
|
||||||
|
let mut buff: [u8; 100] = [0; 100];
|
||||||
|
let size = socket.read(&mut buff).await.unwrap();
|
||||||
|
|
||||||
|
buff[0..size].to_vec()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn dummy_tcp_client_write_then_read_conn(port: u16, data: &[u8]) -> Vec<u8> {
|
||||||
|
let mut socket = TcpStream::connect(format!("127.0.0.1:{}", port))
|
||||||
|
.await
|
||||||
|
.expect("Failed to connect to dummy TCP server!");
|
||||||
|
|
||||||
|
socket.write_all(data).await.unwrap();
|
||||||
|
|
||||||
|
let mut buff: [u8; 100] = [0; 100];
|
||||||
|
let size = socket.read(&mut buff).await.unwrap();
|
||||||
|
|
||||||
|
buff[0..size].to_vec()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn dummy_tcp_client_write_conn(port: u16, data: &[u8]) {
|
||||||
|
let mut socket = TcpStream::connect(format!("127.0.0.1:{}", port))
|
||||||
|
.await
|
||||||
|
.expect("Failed to connect to dummy TCP server!");
|
||||||
|
|
||||||
|
socket.write_all(data).await.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn dummy_tcp_client_square_root_requests(port: u16, num_exchanges: usize) {
|
||||||
|
let mut socket = TcpStream::connect(format!("127.0.0.1:{}", port))
|
||||||
|
.await
|
||||||
|
.expect("Failed to connect to dummy TCP server!");
|
||||||
|
|
||||||
|
let mut rng = rand::thread_rng();
|
||||||
|
let mut buff: [u8; 100] = [0; 100];
|
||||||
|
|
||||||
|
for _ in 0..num_exchanges {
|
||||||
|
let num = rng.gen::<i32>() % 100;
|
||||||
|
socket.write_all(num.to_string().as_bytes()).await.unwrap();
|
||||||
|
|
||||||
|
let size = socket.read(&mut buff).await.unwrap();
|
||||||
|
|
||||||
|
if size == 0 {
|
||||||
|
panic!("Got empty response!");
|
||||||
|
}
|
||||||
|
|
||||||
|
let got = String::from_utf8_lossy(&buff[0..size])
|
||||||
|
.to_string()
|
||||||
|
.parse::<i64>()
|
||||||
|
.unwrap();
|
||||||
|
println!("{} * {} = {} (based on server response)", num, num, got);
|
||||||
|
assert_eq!((num * num) as i64, got);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn dummy_tcp_client_additions_requests(port: u16, inc: i32, num_exchanges: usize) {
|
||||||
|
let mut socket = TcpStream::connect(format!("127.0.0.1:{}", port))
|
||||||
|
.await
|
||||||
|
.expect("Failed to connect to dummy TCP server!");
|
||||||
|
|
||||||
|
let mut rng = rand::thread_rng();
|
||||||
|
let mut buff: [u8; 100] = [0; 100];
|
||||||
|
|
||||||
|
for _ in 0..num_exchanges {
|
||||||
|
let num = rng.gen::<i32>() % 100;
|
||||||
|
socket.write_all(num.to_string().as_bytes()).await.unwrap();
|
||||||
|
|
||||||
|
let size = socket.read(&mut buff).await.unwrap();
|
||||||
|
|
||||||
|
if size == 0 {
|
||||||
|
panic!("Got empty response!");
|
||||||
|
}
|
||||||
|
|
||||||
|
let got = String::from_utf8_lossy(&buff[0..size])
|
||||||
|
.to_string()
|
||||||
|
.parse::<i64>()
|
||||||
|
.unwrap();
|
||||||
|
println!("{} + {} = {} (based on server response)", num, inc, got);
|
||||||
|
assert_eq!((num + inc) as i64, got);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Check whether a given port is open or not
|
||||||
|
pub async fn is_port_open(port: u16) -> bool {
|
||||||
|
match TcpStream::connect(("127.0.0.1", port)).await {
|
||||||
|
Ok(_) => true,
|
||||||
|
Err(_) => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Wait for a port to become available
|
||||||
|
pub async fn wait_for_port(port: u16) {
|
||||||
|
for _ in 0..50 {
|
||||||
|
if is_port_open(port).await {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
time::sleep(Duration::from_millis(10)).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
eprintln!("Port {} did not open in time!", port);
|
||||||
|
std::process::exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
mod test {
|
||||||
|
use crate::test::dummy_tcp_sockets::{
|
||||||
|
dummy_tcp_client_additions_requests, dummy_tcp_client_read_conn,
|
||||||
|
dummy_tcp_client_square_root_requests, dummy_tcp_client_write_conn,
|
||||||
|
dummy_tcp_client_write_then_read_conn, DummyTCPServer,
|
||||||
|
};
|
||||||
|
use crate::test::{get_port_number, PortsAllocation};
|
||||||
|
|
||||||
|
fn port(index: u16) -> u16 {
|
||||||
|
get_port_number(PortsAllocation::DummyTCPServer, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn socket_read_from_server() {
|
||||||
|
const DATA: &[u8] = "Hello world!!!".as_bytes();
|
||||||
|
|
||||||
|
let listener = DummyTCPServer::start(port(0)).await;
|
||||||
|
let handle = tokio::spawn(async move {
|
||||||
|
listener.write_next_connection(DATA).await;
|
||||||
|
});
|
||||||
|
let data = dummy_tcp_client_read_conn(port(0)).await;
|
||||||
|
assert_eq!(data, DATA);
|
||||||
|
|
||||||
|
handle.await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn socket_write_to_server() {
|
||||||
|
const DATA: &[u8] = "Hello world 2".as_bytes();
|
||||||
|
|
||||||
|
let listener = DummyTCPServer::start(port(1)).await;
|
||||||
|
tokio::spawn(async move {
|
||||||
|
dummy_tcp_client_write_conn(port(1), DATA).await;
|
||||||
|
});
|
||||||
|
let data = listener.read_next_connection().await;
|
||||||
|
assert_eq!(data, DATA);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn socket_read_and_write_to_server() {
|
||||||
|
const DATA_1: &[u8] = "Hello world 3a".as_bytes();
|
||||||
|
const DATA_2: &[u8] = "Hello world 3b".as_bytes();
|
||||||
|
|
||||||
|
let listener = DummyTCPServer::start(port(2)).await;
|
||||||
|
let handle = tokio::spawn(async move {
|
||||||
|
println!("client handle");
|
||||||
|
let data = dummy_tcp_client_write_then_read_conn(port(2), DATA_1).await;
|
||||||
|
assert_eq!(data, DATA_2);
|
||||||
|
});
|
||||||
|
let h2 = tokio::spawn(async move {
|
||||||
|
println!("server handle");
|
||||||
|
let data = listener.read_then_write_next_connection(DATA_2).await;
|
||||||
|
assert_eq!(data, DATA_1);
|
||||||
|
});
|
||||||
|
|
||||||
|
handle.await.unwrap();
|
||||||
|
h2.await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn socket_dummy_root_calculator() {
|
||||||
|
let listener = DummyTCPServer::start(port(3)).await;
|
||||||
|
let handle = tokio::spawn(async move {
|
||||||
|
listener.next_conn_square_operations().await;
|
||||||
|
});
|
||||||
|
let data = dummy_tcp_client_write_then_read_conn(port(3), "5".as_bytes()).await;
|
||||||
|
assert_eq!(data, "25".as_bytes());
|
||||||
|
|
||||||
|
handle.await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn socket_dummy_root_calculator_multiple() {
|
||||||
|
let listener = DummyTCPServer::start(port(4)).await;
|
||||||
|
let handle = tokio::spawn(async move {
|
||||||
|
listener.next_conn_square_operations().await;
|
||||||
|
});
|
||||||
|
dummy_tcp_client_square_root_requests(port(4), 10).await;
|
||||||
|
|
||||||
|
handle.await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn socket_dummy_addition_calculator() {
|
||||||
|
let listener = DummyTCPServer::start(port(5)).await;
|
||||||
|
let handle = tokio::spawn(async move {
|
||||||
|
listener.next_conn_add_operations(4).await;
|
||||||
|
});
|
||||||
|
let data = dummy_tcp_client_write_then_read_conn(port(5), "5".as_bytes()).await;
|
||||||
|
assert_eq!(data, "9".as_bytes());
|
||||||
|
|
||||||
|
handle.await.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn socket_dummy_addition_calculator_multiple() {
|
||||||
|
let listener = DummyTCPServer::start(port(6)).await;
|
||||||
|
let handle = tokio::spawn(async move {
|
||||||
|
listener.next_conn_add_operations(7).await;
|
||||||
|
});
|
||||||
|
dummy_tcp_client_additions_requests(port(6), 7, 10).await;
|
||||||
|
|
||||||
|
handle.await.unwrap();
|
||||||
|
}
|
||||||
|
}
|
0
src/test/expired_certificate.rs
Normal file
0
src/test/expired_certificate.rs
Normal file
57
src/test/invalid_with_token_auth.rs
Normal file
57
src/test/invalid_with_token_auth.rs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
use tokio::task;
|
||||||
|
|
||||||
|
use crate::tcp_relay_client::client_config::ClientConfig;
|
||||||
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
|
use crate::test::dummy_tcp_sockets::{wait_for_port, DummyTCPServer};
|
||||||
|
use crate::test::{get_port_number, PortsAllocation, LOCALHOST_IP};
|
||||||
|
|
||||||
|
const VALID_TOKEN: &str = "AvalidTOKEN";
|
||||||
|
const INVALID_TOKEN: &str = "AnInvalidTOKEN";
|
||||||
|
|
||||||
|
fn port(index: u16) -> u16 {
|
||||||
|
get_port_number(PortsAllocation::InvalidWithTokenAuth, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test()]
|
||||||
|
async fn invalid_with_token_auth() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
tokio::spawn(async move {
|
||||||
|
// Start internal service
|
||||||
|
let local_server = DummyTCPServer::start(port(1)).await;
|
||||||
|
local_server.loop_conn_square_operations().await;
|
||||||
|
});
|
||||||
|
|
||||||
|
let local_set = task::LocalSet::new();
|
||||||
|
local_set
|
||||||
|
.run_until(async move {
|
||||||
|
wait_for_port(port(1)).await;
|
||||||
|
|
||||||
|
// Start server relay
|
||||||
|
task::spawn_local(crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![VALID_TOKEN.to_string()],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: None,
|
||||||
|
tls_key: None,
|
||||||
|
tls_client_auth_root_cert: None,
|
||||||
|
tls_revocation_list: None,
|
||||||
|
}));
|
||||||
|
wait_for_port(port(0)).await;
|
||||||
|
|
||||||
|
// Start client relay
|
||||||
|
crate::tcp_relay_client::run_app(ClientConfig {
|
||||||
|
token: Some(INVALID_TOKEN.to_string()),
|
||||||
|
relay_url: format!("http://{}:{}", LOCALHOST_IP, port(0)),
|
||||||
|
listen_address: LOCALHOST_IP.to_string(),
|
||||||
|
root_certificate: None,
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
}
|
54
src/test/mod.rs
Normal file
54
src/test/mod.rs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#[non_exhaustive]
|
||||||
|
enum PortsAllocation {
|
||||||
|
TestsWithoutPortOpened,
|
||||||
|
DummyTCPServer,
|
||||||
|
ValidWithTokenAuth,
|
||||||
|
ValidWithTLSAuth,
|
||||||
|
InvalidWithTokenAuth,
|
||||||
|
ValidWithMultipleTokenAuth,
|
||||||
|
ValidWithTokenFile,
|
||||||
|
ClientTryTLSWhileThereIsNoTLS,
|
||||||
|
ValidTokenWithCustomIncrement,
|
||||||
|
ValidWithTokenAuthMultiplePorts,
|
||||||
|
ValidWithTokenAuthAndServerTLS,
|
||||||
|
WithTokenAuthAndInvalidServerTLSBadCA,
|
||||||
|
WithTokenAuthAndInvalidServerTLSExpiredAndBadCN,
|
||||||
|
TlsAuthExpiredClientCertificate,
|
||||||
|
TlsAuthRevokedClientCertificate,
|
||||||
|
TlsAuthInvalidClientCertificate,
|
||||||
|
ClientInvalidTlsConfiguration,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_port_number(alloc: PortsAllocation, index: u16) -> u16 {
|
||||||
|
30000 + 20 * (alloc as u16) + index
|
||||||
|
}
|
||||||
|
|
||||||
|
const LOCALHOST_IP: &str = "127.0.0.1";
|
||||||
|
const BAD_PATH: &str = "/bad/path/to/key/file";
|
||||||
|
|
||||||
|
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 client_invalid_tls_configuration;
|
||||||
|
mod invalid_with_token_auth;
|
||||||
|
mod server_invalid_tls_config_invalid_cert;
|
||||||
|
mod server_invalid_tls_config_invalid_client_crl;
|
||||||
|
mod server_invalid_tls_config_invalid_client_root_cert;
|
||||||
|
mod server_invalid_tls_config_invalid_key;
|
||||||
|
mod server_invalid_token_file;
|
||||||
|
mod server_missing_auth;
|
||||||
|
mod tls_auth_expired_certificate;
|
||||||
|
mod tls_auth_invalid_certificate;
|
||||||
|
mod tls_auth_revoked_certificate;
|
||||||
|
mod valid_token_with_custom_increment;
|
||||||
|
mod valid_with_multiple_token_auth;
|
||||||
|
mod valid_with_tls_auth;
|
||||||
|
mod valid_with_token_auth;
|
||||||
|
mod valid_with_token_auth_and_server_tls;
|
||||||
|
mod valid_with_token_auth_multiple_ports;
|
||||||
|
mod valid_with_token_file;
|
||||||
|
mod with_token_auth_and_invalid_server_tls_bad_ca;
|
||||||
|
mod with_token_auth_and_invalid_server_tls_expired_and_bad_cn;
|
53
src/test/pki.rs
Normal file
53
src/test/pki.rs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
use mktemp::Temp;
|
||||||
|
|
||||||
|
use crate::test::test_files_utils::create_temp_file_with_content;
|
||||||
|
|
||||||
|
pub struct PemHolder(Temp);
|
||||||
|
|
||||||
|
impl PemHolder {
|
||||||
|
fn new(b: &[u8]) -> Self {
|
||||||
|
Self(create_temp_file_with_content(b))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn file_path(&self) -> String {
|
||||||
|
self.0.to_str().unwrap().to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Pki {
|
||||||
|
pub expired_client_key: PemHolder,
|
||||||
|
pub expired_client_crt: PemHolder,
|
||||||
|
pub localhost_crt: PemHolder,
|
||||||
|
pub localhost_key: PemHolder,
|
||||||
|
pub other_ca_crl: PemHolder,
|
||||||
|
pub other_ca_crt: PemHolder,
|
||||||
|
pub other_ca_key: PemHolder,
|
||||||
|
pub revoked_client_crt: PemHolder,
|
||||||
|
pub revoked_client_key: PemHolder,
|
||||||
|
pub root_ca_crl: PemHolder,
|
||||||
|
pub root_ca_crt: PemHolder,
|
||||||
|
pub root_ca_key: PemHolder,
|
||||||
|
pub valid_client_crt: PemHolder,
|
||||||
|
pub valid_client_key: PemHolder,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Pki {
|
||||||
|
pub fn load() -> Self {
|
||||||
|
Self {
|
||||||
|
expired_client_key: PemHolder::new(include_bytes!("test_pki/ExpiredClient.key")),
|
||||||
|
expired_client_crt: PemHolder::new(include_bytes!("test_pki/ExpiredClient.crt")),
|
||||||
|
localhost_crt: PemHolder::new(include_bytes!("test_pki/localhost.crt")),
|
||||||
|
localhost_key: PemHolder::new(include_bytes!("test_pki/localhost.key")),
|
||||||
|
other_ca_crl: PemHolder::new(include_bytes!("test_pki/OtherCA.crl")),
|
||||||
|
other_ca_crt: PemHolder::new(include_bytes!("test_pki/OtherCA.crt")),
|
||||||
|
other_ca_key: PemHolder::new(include_bytes!("test_pki/OtherCA.key")),
|
||||||
|
revoked_client_crt: PemHolder::new(include_bytes!("test_pki/RevokedClient.crt")),
|
||||||
|
revoked_client_key: PemHolder::new(include_bytes!("test_pki/RevokedClient.key")),
|
||||||
|
root_ca_crl: PemHolder::new(include_bytes!("test_pki/TCPTunnelTestCA.crl")),
|
||||||
|
root_ca_crt: PemHolder::new(include_bytes!("test_pki/TCPTunnelTestCA.crt")),
|
||||||
|
root_ca_key: PemHolder::new(include_bytes!("test_pki/TCPTunnelTestCA.key")),
|
||||||
|
valid_client_crt: PemHolder::new(include_bytes!("test_pki/ValidClient.crt")),
|
||||||
|
valid_client_key: PemHolder::new(include_bytes!("test_pki/ValidClient.key")),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
100
src/test/server_invalid_tls_config_invalid_cert.rs
Normal file
100
src/test/server_invalid_tls_config_invalid_cert.rs
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
|
use crate::test::pki::Pki;
|
||||||
|
use crate::test::test_files_utils::create_temp_file_with_random_content;
|
||||||
|
use crate::test::{get_port_number, PortsAllocation, BAD_PATH};
|
||||||
|
|
||||||
|
const TOKEN: &str = "mytok";
|
||||||
|
|
||||||
|
fn port(index: u16) -> u16 {
|
||||||
|
get_port_number(PortsAllocation::TestsWithoutPortOpened, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn unspecified() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![TOKEN.to_string()],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: None,
|
||||||
|
tls_key: Some(pki.localhost_key.file_path()),
|
||||||
|
tls_client_auth_root_cert: None,
|
||||||
|
tls_revocation_list: None,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn incorrect_pem_type() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![TOKEN.to_string()],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: Some(pki.root_ca_crl.file_path()),
|
||||||
|
tls_key: Some(pki.localhost_key.file_path()),
|
||||||
|
tls_client_auth_root_cert: None,
|
||||||
|
tls_revocation_list: None,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn random_contents() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
let random_file = create_temp_file_with_random_content();
|
||||||
|
|
||||||
|
crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![TOKEN.to_string()],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: Some(random_file.to_string_lossy().to_string()),
|
||||||
|
tls_key: Some(pki.localhost_key.file_path()),
|
||||||
|
tls_client_auth_root_cert: None,
|
||||||
|
tls_revocation_list: None,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn invalid_path() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![TOKEN.to_string()],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: Some(BAD_PATH.to_string()),
|
||||||
|
tls_key: Some(pki.localhost_key.file_path()),
|
||||||
|
tls_client_auth_root_cert: None,
|
||||||
|
tls_revocation_list: None,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
78
src/test/server_invalid_tls_config_invalid_client_crl.rs
Normal file
78
src/test/server_invalid_tls_config_invalid_client_crl.rs
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
|
use crate::test::pki::Pki;
|
||||||
|
use crate::test::test_files_utils::create_temp_file_with_random_content;
|
||||||
|
use crate::test::{get_port_number, PortsAllocation, BAD_PATH};
|
||||||
|
|
||||||
|
const TOKEN: &str = "mytok";
|
||||||
|
|
||||||
|
fn port(index: u16) -> u16 {
|
||||||
|
get_port_number(PortsAllocation::TestsWithoutPortOpened, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn bad_path() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![TOKEN.to_string()],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: Some(pki.localhost_crt.file_path()),
|
||||||
|
tls_key: Some(pki.localhost_key.file_path()),
|
||||||
|
tls_client_auth_root_cert: Some(pki.root_ca_crl.file_path()),
|
||||||
|
tls_revocation_list: Some(BAD_PATH.to_string()),
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn random_content() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
let random_file = create_temp_file_with_random_content();
|
||||||
|
|
||||||
|
crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![TOKEN.to_string()],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: Some(pki.localhost_crt.file_path()),
|
||||||
|
tls_key: Some(pki.localhost_key.file_path()),
|
||||||
|
tls_client_auth_root_cert: Some(pki.root_ca_crl.file_path()),
|
||||||
|
tls_revocation_list: Some(random_file.to_string_lossy().to_string()),
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn invalid_pem() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![TOKEN.to_string()],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: Some(pki.localhost_crt.file_path()),
|
||||||
|
tls_key: Some(pki.localhost_key.file_path()),
|
||||||
|
tls_client_auth_root_cert: Some(pki.root_ca_crl.file_path()),
|
||||||
|
tls_revocation_list: Some(pki.root_ca_crt.file_path()),
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
|
use crate::test::pki::Pki;
|
||||||
|
use crate::test::test_files_utils::create_temp_file_with_random_content;
|
||||||
|
use crate::test::{get_port_number, PortsAllocation, BAD_PATH};
|
||||||
|
|
||||||
|
const TOKEN: &str = "mytok";
|
||||||
|
|
||||||
|
fn port(index: u16) -> u16 {
|
||||||
|
get_port_number(PortsAllocation::TestsWithoutPortOpened, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn invalid_path() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![TOKEN.to_string()],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: Some(pki.localhost_crt.file_path()),
|
||||||
|
tls_key: Some(pki.localhost_key.file_path()),
|
||||||
|
tls_client_auth_root_cert: Some(BAD_PATH.to_string()),
|
||||||
|
tls_revocation_list: None,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn other_pem_file_type() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![TOKEN.to_string()],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: Some(pki.localhost_crt.file_path()),
|
||||||
|
tls_key: Some(pki.localhost_key.file_path()),
|
||||||
|
tls_client_auth_root_cert: Some(pki.root_ca_crl.file_path()),
|
||||||
|
tls_revocation_list: None,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn random_content() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
let random_file = create_temp_file_with_random_content();
|
||||||
|
|
||||||
|
crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![TOKEN.to_string()],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: Some(pki.localhost_crt.file_path()),
|
||||||
|
tls_key: Some(pki.localhost_key.file_path()),
|
||||||
|
tls_client_auth_root_cert: Some(random_file.to_string_lossy().to_string()),
|
||||||
|
tls_revocation_list: None,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
100
src/test/server_invalid_tls_config_invalid_key.rs
Normal file
100
src/test/server_invalid_tls_config_invalid_key.rs
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
|
use crate::test::pki::Pki;
|
||||||
|
use crate::test::test_files_utils::create_temp_file_with_random_content;
|
||||||
|
use crate::test::{get_port_number, PortsAllocation, BAD_PATH};
|
||||||
|
|
||||||
|
const TOKEN: &str = "mytok";
|
||||||
|
|
||||||
|
fn port(index: u16) -> u16 {
|
||||||
|
get_port_number(PortsAllocation::TestsWithoutPortOpened, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn invalid_pem_file_type() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![TOKEN.to_string()],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: Some(pki.root_ca_crt.file_path()),
|
||||||
|
tls_key: Some(pki.root_ca_crt.file_path()),
|
||||||
|
tls_client_auth_root_cert: None,
|
||||||
|
tls_revocation_list: None,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test()]
|
||||||
|
async fn unspecified() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![TOKEN.to_string()],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: Some(pki.root_ca_crt.file_path()),
|
||||||
|
tls_key: None,
|
||||||
|
tls_client_auth_root_cert: None,
|
||||||
|
tls_revocation_list: None,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn random_content() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
let random_content = create_temp_file_with_random_content();
|
||||||
|
|
||||||
|
crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![TOKEN.to_string()],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: Some(pki.root_ca_crt.file_path()),
|
||||||
|
tls_key: Some(random_content.to_string_lossy().to_string()),
|
||||||
|
tls_client_auth_root_cert: None,
|
||||||
|
tls_revocation_list: None,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn invalid_path() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![TOKEN.to_string()],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: Some(pki.localhost_crt.file_path()),
|
||||||
|
tls_key: Some(BAD_PATH.to_string()),
|
||||||
|
tls_client_auth_root_cert: None,
|
||||||
|
tls_revocation_list: None,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
28
src/test/server_invalid_token_file.rs
Normal file
28
src/test/server_invalid_token_file.rs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
|
use crate::test::{get_port_number, PortsAllocation};
|
||||||
|
|
||||||
|
const INVALID_TOKEN: &str = "/tmp/a/token/file/that/does/not/exists";
|
||||||
|
|
||||||
|
fn port(index: u16) -> u16 {
|
||||||
|
get_port_number(PortsAllocation::TestsWithoutPortOpened, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test()]
|
||||||
|
async fn test() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![],
|
||||||
|
tokens_file: Some(INVALID_TOKEN.to_string()),
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: None,
|
||||||
|
tls_key: None,
|
||||||
|
tls_client_auth_root_cert: None,
|
||||||
|
tls_revocation_list: None,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
71
src/test/server_missing_auth.rs
Normal file
71
src/test/server_missing_auth.rs
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
|
use crate::test::pki::Pki;
|
||||||
|
use crate::test::{get_port_number, PortsAllocation};
|
||||||
|
|
||||||
|
fn port(index: u16) -> u16 {
|
||||||
|
get_port_number(PortsAllocation::TestsWithoutPortOpened, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn with_tls_server() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: Some(pki.root_ca_crl.file_path()),
|
||||||
|
tls_key: Some(pki.localhost_key.file_path()),
|
||||||
|
tls_client_auth_root_cert: None,
|
||||||
|
tls_revocation_list: None,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn without_tls_server() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: None,
|
||||||
|
tls_key: None,
|
||||||
|
tls_client_auth_root_cert: None,
|
||||||
|
tls_revocation_list: None,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn tls_auth_without_tls_config() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: None,
|
||||||
|
tls_key: None,
|
||||||
|
tls_client_auth_root_cert: Some(pki.root_ca_crt.file_path()),
|
||||||
|
tls_revocation_list: None,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
}
|
17
src/test/test_files_utils.rs
Normal file
17
src/test/test_files_utils.rs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
use mktemp::Temp;
|
||||||
|
use rand::Rng;
|
||||||
|
|
||||||
|
/// Create a temporary file and feed it with some specified content
|
||||||
|
pub fn create_temp_file_with_content(content: &[u8]) -> Temp {
|
||||||
|
let temp = Temp::new_file().unwrap();
|
||||||
|
std::fs::write(&temp, content).unwrap();
|
||||||
|
temp
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Generate a temporary file with some random content
|
||||||
|
pub fn create_temp_file_with_random_content() -> Temp {
|
||||||
|
let random_bytes = rand::thread_rng().gen::<[u8; 10]>();
|
||||||
|
let temp = Temp::new_file().unwrap();
|
||||||
|
std::fs::write(&temp, random_bytes).unwrap();
|
||||||
|
temp
|
||||||
|
}
|
25
src/test/test_pki/ExpiredClient.crt
Normal file
25
src/test/test_pki/ExpiredClient.crt
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIELjCCAhagAwIBAgIRAOFWCcZCmPv3QHk6MwXfRogwDQYJKoZIhvcNAQELBQAw
|
||||||
|
GjEYMBYGA1UEAxMPVENQVHVubmVsVGVzdENBMB4XDTIyMDkwMjA3MDkxM1oXDTIy
|
||||||
|
MDkwMjA4MDkxM1owGDEWMBQGA1UEAxMNRXhwaXJlZENsaWVudDCCASIwDQYJKoZI
|
||||||
|
hvcNAQEBBQADggEPADCCAQoCggEBANDTInGsDJ4xq/pSnpeTDSE6B2Z//Had0WQk
|
||||||
|
Wl6z4k6W5t79xFwjmMa4cfJJijfgC1usbV2+BP0nh+dPxedTlItUhIW8Hjx2BM/r
|
||||||
|
q1OPvYNu0bB7zcmT+WHddDLdfsxjSMt53b4UMbcWscflLry7V6ahoXccnPKUyt4U
|
||||||
|
+ZcYaoyPAej32y5Ym8EB2Hv9lMoRVbF02mEoTcdanJdhP/y28NNm9ezMsiv1jtCq
|
||||||
|
aR1ipVj7XdCW3K+vVLWzdfw75+P9bS5uXcAZHVQsJk37nrtezH/6Zgum9OQYUmIx
|
||||||
|
TNzhEzZiKfUWa07l0l3SC81KVf1YVKfwO8pQKATLLaauqXIQWZ8CAwEAAaNxMG8w
|
||||||
|
DgYDVR0PAQH/BAQDAgO4MB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAd
|
||||||
|
BgNVHQ4EFgQUa/z5ULTQT52kxALqprqNhjhIcLswHwYDVR0jBBgwFoAU+53PiQbh
|
||||||
|
7KSQGc797M71fZg+JDUwDQYJKoZIhvcNAQELBQADggIBAF77OAeuaaW00zZfOuRb
|
||||||
|
9Eq6/MzS2kEUczFxkg6TZ3/cvx2tj9EQc7O5lRshbPmzjhGkRRLFBvnbL+wJrt93
|
||||||
|
YS0enQNSGkdivS/q66Vqf0ujL/FhAxZYW5Gc+f7lLt0VYHzp/ChU2ryYx9dH2AJD
|
||||||
|
AKl9vSqz/e5rUyQm/8lU1gNWbf7zb8rHA5WcHGWzTJGdz/pnUx1Mf29dtcAygzwz
|
||||||
|
8yWJI1Rb755tGzocSPULvVuQw4Pvnum0fLJusLLBU9BTZzCW2psXUOaTzjwzza5C
|
||||||
|
WedEPB+/Rtw4cwydEwoI0OvoDXezKcjo8bj8Dna4+UqBz85PFQFZKT23gYBuz4/A
|
||||||
|
8/G/3pvXKf8DTnIo9370qU9Ce0UlohCu0U3rRQDEiMiTxQgkhHn7CXe0quOem9yt
|
||||||
|
RUOXymAUz/IdB/Xu0jfuZUF4e6ObF9yULb1SzmHmsxUD7i2h+453KmsYpSDWp2CP
|
||||||
|
R9UOrhINirSOr1qRm5PCnMO8b+Th7TlhfQBY3u8VTn1l5F4fdzGiIGV5IZmGb1fV
|
||||||
|
b47WC7y3TdJ6i5fWVt2XtKQBQOjOLgPfZs5qW8GFHWrW1Z2otn6vrNMgquhV/9kd
|
||||||
|
9TzSFgbymCFKvGkHXZQ70Rqkb8Q5v3dz3VSFfqdE728hvp3GRHqZDSJhcR/FVahm
|
||||||
|
AKio0jBH1mENEttHndQhXQkE
|
||||||
|
-----END CERTIFICATE-----
|
27
src/test/test_pki/ExpiredClient.key
Normal file
27
src/test/test_pki/ExpiredClient.key
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIIEpAIBAAKCAQEA0NMicawMnjGr+lKel5MNIToHZn/8dp3RZCRaXrPiTpbm3v3E
|
||||||
|
XCOYxrhx8kmKN+ALW6xtXb4E/SeH50/F51OUi1SEhb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zPOeldv1jN5nTxxoW634RxuPd3NkCgYEA5Lm9cTMRHfPAvkIp1hsz
|
||||||
|
CFYqIhSgmQMXhgwMB2avJuKSn+15hVObsQ/IIZrp8TF9UYkMKPzwG/FAG7oloq8N
|
||||||
|
XGoEEaq1r/ZTnBchMGWR/CZalXNToDz1tl8nBIpXiNEUdOGaiHgmqQ4qzD5hVrJc
|
||||||
|
Vgyn1geXgGUdvIHHywUrXrECgYEAzrI77+k11Oyoojqm1ep+hKrMOJYO0+LZtnCM
|
||||||
|
B2ZpH0+IlAohvsskVSg7Z4UpfpbHKT9ExtWS/8SlNTAhnn2Y8K2666OU9itL9uPe
|
||||||
|
nvQwvsm4yoVMJFaOoGhrSXIiU0F6XaAgAgnPQ5ffyKvn2rFef8NWsb9/zCrIXdMv
|
||||||
|
yui+/FkCgYB9y+OJQ/CrkHC5zQqsG6PnKw7GZOII0fOrWdCUAJwCG0dv7cZJ03LQ
|
||||||
|
yONxAVdrzTGGOZTOD2vG0oG3XDie2O75qU8d/OUcdl7OqnIqupGUZMARnW0Xny6U
|
||||||
|
fpFdGYs8KeohUfw8LSf95VwJwSBb3zjaPPTR/ZZ+LI3k8wStXlOMiQ==
|
||||||
|
-----END RSA PRIVATE KEY-----
|
16
src/test/test_pki/OtherCA.crl
Normal file
16
src/test/test_pki/OtherCA.crl
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
-----BEGIN X509 CRL-----
|
||||||
|
MIICgTBrAgEBMA0GCSqGSIb3DQEBCwUAMBIxEDAOBgNVBAMTB090aGVyQ0EXDTIy
|
||||||
|
MDkwMjA3MTI0MloXDTQyMDkwMjA3MTI0MFowAKAjMCEwHwYDVR0jBBgwFoAUIdv7
|
||||||
|
GAAmusKCN710x76ODIzpFDswDQYJKoZIhvcNAQELBQADggIBAJ6PEWN9ZdK6V1Z+
|
||||||
|
qb1lE6UpDwee7Gvu+WmYLc/ySDy8zpt3er5bfJFEI5zLYRvR7C8I77QuHfm6ytny
|
||||||
|
AcjdZoqLoYn6JkEnbZFj9yddcYfwmo1bxc7YsGKqitQPwUA+Ou2mq9q8pSyAIAY3
|
||||||
|
d1cAKEqHZgnWm/7D4NZZ8lWGjjFz9hlwhP8jWKqRcGsL/RGylNW9wyroECGRg18R
|
||||||
|
YiFIqgXiWAG1CAZcbcv2yKlijSm2q8OgBG5mFMClm5yHEmyju4ZyRowySraSkMkc
|
||||||
|
1lZqOpxRFn59FNE278bm4RJfWFtprvO/1UONq46VIi49q3iykjowGS9enFhd2pDX
|
||||||
|
JGRiMze5+Y9+MRqB7CkpgWr85a6VB/eZHt1klZDXHVviTPBwf7Sps0u2j63ZgMKl
|
||||||
|
NZCG4oTyPguyNF+PF76xqwhGqJJB1zK63wizC+1go4It9vn22tg3/C2X1riWiKjN
|
||||||
|
XimlHyumq1DkRoulwo716m3/DgVbAQD+dfTmGA80QnCMAEpRG0rjBwwrsbuz7TSX
|
||||||
|
38YiBCBAbgM/L/XhVXzuki0Q5xrrcvH8bhxG6/j+gpAFdI3on2R3rHgWMXS8c9tw
|
||||||
|
4gqXuPr4Th3Rb3pwZEsWvUXG3vY/5d2Pq9gCGcEUo36CCaZzMCDh7yrJHd1zY5gT
|
||||||
|
e5zdMjCWD7b5jfM0GpSthrfh7cya
|
||||||
|
-----END X509 CRL-----
|
29
src/test/test_pki/OtherCA.crt
Normal file
29
src/test/test_pki/OtherCA.crt
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIE5DCCAsygAwIBAgIBATANBgkqhkiG9w0BAQsFADASMRAwDgYDVQQDEwdPdGhl
|
||||||
|
ckNBMB4XDTIyMDkwMjA3MTI0MloXDTQyMDkwMjA3MTI0MFowEjEQMA4GA1UEAxMH
|
||||||
|
T3RoZXJDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAM802FZEmSvZ
|
||||||
|
A+SfJNWBJsAt7SvWQBxxpzmP8joriDkULG4XCiJGAHY7MsNm6uAk/A2f3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7V8fVV+HcLj17bfgfP+ILbgxPhsc0Sqh719j0va
|
||||||
|
gptqzrLz1eSKjthwVrYh3RuJCBPJJKa51y54TKIqnDkrWEQc0YQf7K3wkJJQ7H6M
|
||||||
|
UELhZLVF2zjEltxcfDGUCHtxcWYApA6chwsDTNYoeb7KdTAmXgQS7JNTqLuvF773
|
||||||
|
nGCKQr6JYPwnQ7QOE7oWVEeINGZtSyKBb/+DpTacK0qaw7MymkJBlaRNHAGsTzfI
|
||||||
|
U0/tKLsi6ItXi8vY/wTxRt4qvlu4mFeGFoTNdTDib6rJKS4D6HoGeRglhefOpv4r
|
||||||
|
luaJ3MwANCTa0T5H/+vDN1NQTMJa6Iul6gKzDkX1vB1duenPpExAgnjm3QeNCvQ/
|
||||||
|
yqNCPEAyZBg83L6ZKCEHQWo3SM2nMwV6X+pS0FKCY/z+7EGH6A4FHriaksOnSNeD
|
||||||
|
HczdA3Kp8jCR9llFknwxvwvIzFbh73E0/KVifIfzmbKakIseohKRNF1kxhFaB+wR
|
||||||
|
DE1o4VTfHl8=
|
||||||
|
-----END CERTIFICATE-----
|
51
src/test/test_pki/OtherCA.key
Normal file
51
src/test/test_pki/OtherCA.key
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIIJKgIBAAKCAgEAzzTYVkSZK9kD5J8k1YEmwC3tK9ZAHHGnOY/yOiuIORQsbhcK
|
||||||
|
IkYAdjsyw2bq4CT8DZ/dM0SCGIu1t9C0kp84QLY0N7xj0ftsqj1xV6nZg5Ea5e4M
|
||||||
|
fh2RfigBhiApt1hJ4wfI6w6SkQbUUGUDivDvdG479oyoXbl7WJ0tZeCLl+TxJSJa
|
||||||
|
Af1PCx7wpxiDy/ekD9Jlyhm1zZKtKwkVkkKsQ49kwmlOKVbdJ3oqVn7WeI4DISSx
|
||||||
|
gTL4AJCz09TUfp52fpL6g3GkXbiLLc6uvi7eaJTjRIM607aq2u//q+VtdloiO7kr
|
||||||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lJoIWJX8/bw==
|
||||||
|
-----END RSA PRIVATE KEY-----
|
25
src/test/test_pki/RevokedClient.crt
Normal file
25
src/test/test_pki/RevokedClient.crt
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIELjCCAhagAwIBAgIRAMvrVtV8eUCAihX59TzwyVwwDQYJKoZIhvcNAQELBQAw
|
||||||
|
GjEYMBYGA1UEAxMPVENQVHVubmVsVGVzdENBMB4XDTIyMDkwMjA3MDcwN1oXDTQy
|
||||||
|
MDkwMjA3MDYxMlowGDEWMBQGA1UEAxMNUmV2b2tlZENsaWVudDCCASIwDQYJKoZI
|
||||||
|
hvcNAQEBBQADggEPADCCAQoCggEBAOJ0s0ukj6FaKVQW1rZ7fdT7CqFyBcbQ0yr9
|
||||||
|
nioaFIICJIiN/RsTROlwEtFBYoy68SP/9w+p4c0T+1QXr2T7JBljZ8I0RotPmUL9
|
||||||
|
Jy6fM5dD8m4GM44K4oz+Mk6JaVNOcY1+j670KLRJKLhX/gNTiiqFdmMXrLUdl2KF
|
||||||
|
3qrY2Jh4riygkO0xClKiL57m/8+tCDXI+cycftdfLMDOLkBPA7HCeVdahx2r6mHi
|
||||||
|
5tSlk+sMeXEJy7kR4w4zDUb/MwP1cQgnSMwtdGE4Xz2zSLwEk0P8xNUe7Qwwx605
|
||||||
|
syd/Y/lFDasoPeGgCqFvw/zgZE2D+6U8NbywZBAqa/Nd+UA0v+cCAwEAAaNxMG8w
|
||||||
|
DgYDVR0PAQH/BAQDAgO4MB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAd
|
||||||
|
BgNVHQ4EFgQUOJMPHK9liHjNrIt26DT1pWmat4EwHwYDVR0jBBgwFoAU+53PiQbh
|
||||||
|
7KSQGc797M71fZg+JDUwDQYJKoZIhvcNAQELBQADggIBAI7d1CIJGwwTATNv1ATl
|
||||||
|
UawbtuuV2dbasRA3C9kkG34UOmE8m9z01/rJiwXvF+57rbPMTZUvVhqOGajJNN7K
|
||||||
|
7+S1DDUNjea7snbJO4zsHT6OGV1vw/b0EI4OJKxuYRE5kkUEGPcWSoFbsUEyEXtt
|
||||||
|
Kl22TDOXCEYkvYW5vN2aJokyPl+rmCrzC6E207lkaKyDDBSBPYXxNApBkMMryxUO
|
||||||
|
1yqRxYrfayb0CW0JRHzI9dQNOPtpj3Pd8XKxC0liguTnPReoHC1scTp6GR9uP5TT
|
||||||
|
MlBPuAudcRNd4Kcz4vqBNc3M+ioWt5DBQ4n31beq772AbESpDaM5VBRdDlre6/Q3
|
||||||
|
WEasplODNer44md+V09LbhT3sDYpHuTIYwvHcf7jOO6wUKl7JulOwEkBD2IiTs+6
|
||||||
|
RMT2eIavlQjIObqNvLTWoVfm4b32vvBzyXdrZyr1FIlJ+VlhIpvEC1ZPq3ZLC831
|
||||||
|
sDPtyVI+dA4KV/+ZN3NvP0BfL9+7KE20Ma1V2u8reV51nddjRzNkYt3AdAuO3B9i
|
||||||
|
CUqauhe5o7Ey7QFRAxYvT4xmg9mRjSJSlX+jwXroKymtxgG3f/14Do+5yyN0bS3O
|
||||||
|
FC1H3uV1vwQztxkpJdh8PoWoh+1OsqwrRIYSEAx9M1xSBHz5TzgHQJmot5fwLQTn
|
||||||
|
QgvMyCyS46ciaMjRILqagt6P
|
||||||
|
-----END CERTIFICATE-----
|
27
src/test/test_pki/RevokedClient.key
Normal file
27
src/test/test_pki/RevokedClient.key
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIIEowIBAAKCAQEA4nSzS6SPoVopVBbWtnt91PsKoXIFxtDTKv2eKhoUggIkiI39
|
||||||
|
GxNE6XAS0UFijLrxI//3D6nhzRP7VBevZPskGWNnwjRGi0+ZQv0nLp8zl0PybgYz
|
||||||
|
jgrijP4yTolpU05xjX6PrvQotEkouFf+A1OKKoV2YxestR2XYoXeqtjYmHiuLKCQ
|
||||||
|
7TEKUqIvnub/z60INcj5zJx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sSNbUQcElqAwaPHYfhQINm2rZLemtKderNc049lVhFJoffoTZG6QYPfOLz
|
||||||
|
jQETZbga3FEvATeHcb7QHwKBgH0DPzkNSbYNeUN+SP7nBKJ0xvAkz8qknqnINu4B
|
||||||
|
sNtvq3/0BYq38cqa8iW9hUByBRN4DDrd++Apt8nkzI6ai9YMFrz6t1q3cyJr/cRS
|
||||||
|
MpCQY1qC/kXvI+Ww+rqI9rQ55aiHYwx+8jCy+kz1prBEYS3aTfRTqb5fcGh+/iO7
|
||||||
|
zPi5AoGBANvsVAjy0HJxJom8yfCPw2tzMPh7o9v1jMblKN1xX8B249i27S5UOifO
|
||||||
|
Viy0OR6uiNGT6YLA7Q7esGavkiuK0bWa0M9ezWbGoNh4DmOzn9Q8yEbDz9VF23Pw
|
||||||
|
fc52Ehiq9zS9cqIXc+cQJe/o2J6YziUnBcJc2Ld7d75TISkkdYrN
|
||||||
|
-----END RSA PRIVATE KEY-----
|
17
src/test/test_pki/TCPTunnelTestCA.crl
Normal file
17
src/test/test_pki/TCPTunnelTestCA.crl
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
-----BEGIN X509 CRL-----
|
||||||
|
MIICrjCBlwIBATANBgkqhkiG9w0BAQsFADAaMRgwFgYDVQQDEw9UQ1BUdW5uZWxU
|
||||||
|
ZXN0Q0EXDTIyMDkwMjA3MDgwNFoXDTIyMDkwMjA3MDgwNFowJDAiAhEAy+tW1Xx5
|
||||||
|
QICKFfn1PPDJXBcNMjIwOTAyMDcwODA0WqAjMCEwHwYDVR0jBBgwFoAU+53PiQbh
|
||||||
|
7KSQGc797M71fZg+JDUwDQYJKoZIhvcNAQELBQADggIBAAT08Q5BJIU+yvPSsNdE
|
||||||
|
yMBQZSUfTyFOxWYeUiqohpRkCBdhWYAnrZiZN83GArW7rFi1D9p0Cdg5ayDgY1A3
|
||||||
|
4SsnXklwcEdYxIzaLskN1bRY7Idmu9TXdDssPWCyawTfWfV5AfqnqnuKx71gradf
|
||||||
|
jMixrOoOWiBqMp3kHO6F2Q5gKGTQcvjYAe9yVeOF/tchMiHEHBw59HigiHmkX4od
|
||||||
|
7GNbyWyqJlMaVoK13hOt/qnjOFKITsUSzIZ1pI8NY44sBFSIM1SzklfZZ3vBNaeC
|
||||||
|
gA6JBrBm/vEvbZ/WsfCI0uVJwLgCoY4tupocKCLwyN2tyGFhvPwlv4UFEEkabYuo
|
||||||
|
9F7/5CG3JO2yJPHMuflebLawyyfXlbjH9fqvjNRnyry3MXsdphU5OV/xavrSNgLW
|
||||||
|
i8HItaFThCvnMdlMn38UYeGUqp/lgrpQiXEA8K+BX55lJzzNK+UPLNEkf3bROWvR
|
||||||
|
01tstOAhn0rfPKW01HjqXKU8Si2ExBR+kzdamhiZoaKcxuemK/TPd+vmNXuvwede
|
||||||
|
3o2qdXycgFddbKmKejV3gy+zptnFyEGlC3E3BgfSdQ2Tdn0BBltzhRdENB6o5SYh
|
||||||
|
ZUP4Mo3Gr0Hy7eeLGQM7wzmxUxOGmVdqDoWnbOwC2ySEzR6Tsf9id7Sl50DDUcS5
|
||||||
|
G20W0UM0cWIOyaaHAxKl9frl
|
||||||
|
-----END X509 CRL-----
|
29
src/test/test_pki/TCPTunnelTestCA.crt
Normal file
29
src/test/test_pki/TCPTunnelTestCA.crt
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIE9DCCAtygAwIBAgIBATANBgkqhkiG9w0BAQsFADAaMRgwFgYDVQQDEw9UQ1BU
|
||||||
|
dW5uZWxUZXN0Q0EwHhcNMjIwOTAyMDcwNjE0WhcNNDIwOTAyMDcwNjEzWjAaMRgw
|
||||||
|
FgYDVQQDEw9UQ1BUdW5uZWxUZXN0Q0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAw
|
||||||
|
ggIKAoICAQC5agi1SIe/1SqoBb+p3IstdnZa12IrKtTiSSANV/RtjLgFymqqlvNd
|
||||||
|
I3OJOglJr/ISSWrldh+ZRb661Ds7USLPY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CUb5+xDRmgz6q/SsAtgH8Rrzt8KYhrT5r4kMkpIFssLBWUQgHGdZEaEnt89qnIVb
|
||||||
|
/mULw7l0716yTkqUBydibyDUsvhgOh1c5Xg/8ICwVptvFzzcbvWFtMjOQCuqB/ud
|
||||||
|
lBcMPIlM2CyytQ6uJjcjEfoy2O1rAlgEb2QKR7abPinlLFo2d1kx3GwPgSzdpROB
|
||||||
|
fJalW0QDLkdeSPSX2a/99KTI8GKQKriG5D2kcHVFAY57P7yjbyrLtD2dKdCTp0M5
|
||||||
|
jPMGjWvFOJ86k8XiNB8yMtABp0K5WZLqqvPFm16sBPaJnpKGo/KUipnLOTnEOpHJ
|
||||||
|
LWDDH8P+HKjhV99s7IwBu+67sDsKO/AsZGRuLJSGh1j8nl/iKhHGgXPfGPY7oDIZ
|
||||||
|
6JyqnW0906KrIoUFZ0b8iKMwIu35aVR++rfWIdFcYqW4flNkAZI0XY5IlJ/i9d7N
|
||||||
|
0ezY2xRAYlJSvefisMIylm0OgUDg0Nv7
|
||||||
|
-----END CERTIFICATE-----
|
51
src/test/test_pki/TCPTunnelTestCA.key
Normal file
51
src/test/test_pki/TCPTunnelTestCA.key
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIIJKAIBAAKCAgEAuWoItUiHv9UqqAW/qdyLLXZ2WtdiKyrU4kkgDVf0bYy4Bcpq
|
||||||
|
qpbzXSNziToJSa/yEklq5XYfmUW+utQ7O1Eiz2AvmRlFyuI0aHvgr1vlo6lDCm2b
|
||||||
|
tgqwDmJpUstPUAgESV9ZL9XSw4LpHzplwk8+ubjKX+oWc06/yjQliSJl0n7CS7Ll
|
||||||
|
KoUS5zOJhFdz9k1+oa7QGGvLwlakTuL5RTr5mHWCDk/03y0zIZqqqHVRUDKFBb5e
|
||||||
|
P2WRHHRJiTiJ3fspLUgjvWYr/gP9uGW/ZmOOl/NDVUqFJr02AdhRKNwDKpsatUB6
|
||||||
|
NyO/5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Y-----
|
25
src/test/test_pki/ValidClient.crt
Normal file
25
src/test/test_pki/ValidClient.crt
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIELDCCAhSgAwIBAgIRAMBV0/1Yv1gtGnyi/NMvFl0wDQYJKoZIhvcNAQELBQAw
|
||||||
|
GjEYMBYGA1UEAxMPVENQVHVubmVsVGVzdENBMB4XDTIyMDkwMjA3MDczN1oXDTQy
|
||||||
|
MDkwMjA3MDYxMlowFjEUMBIGA1UEAxMLVmFsaWRDbGllbnQwggEiMA0GCSqGSIb3
|
||||||
|
DQEBAQUAA4IBDwAwggEKAoIBAQCd5PIwp/QUA3UVHDHLBQankyDTOyQxSzKR6CbO
|
||||||
|
yh2hkTs/l78eI2KewovYgP4oowRsHYUTNcZHBBKm3fE6BoZOVuQg0Tw126opJ5WE
|
||||||
|
O57nPoeqn/Rlic+lm8r/IM6rUCU0cuPrP3OgzGKgceldlnWmBZ6z6CPtClgv0H0E
|
||||||
|
gpvW57/gfveW4JfON4w+CjWKFFwAdk7NwgwAVupDeTDvzdK4ExWY/cGDs3NynAS/
|
||||||
|
xS8C2KBVmK40l9eE0HMY6cFQ54hM9wYVeZFZsCQ+9P/3ywEtdb1xsVjcDzmk5Uhx
|
||||||
|
wVGrzu9FIowx1K3b/zINQVhefsDPCa/IfMy4NaNxwg65zqjZAgMBAAGjcTBvMA4G
|
||||||
|
A1UdDwEB/wQEAwIDuDAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwHQYD
|
||||||
|
VR0OBBYEFPw35WYKl2KasK9cNi2tROUQFX+RMB8GA1UdIwQYMBaAFPudz4kG4eyk
|
||||||
|
kBnO/ezO9X2YPiQ1MA0GCSqGSIb3DQEBCwUAA4ICAQAe33X1mHnOIWeCA7XZGBVu
|
||||||
|
+zbXTheHOSZICrM/pOzNbspTTFkQ68sBOwd2HcFhhm1WX09b05ipYiEbXNZCIELq
|
||||||
|
RWPN6yr7x7zFNjZyXxZAtL01pOVih8yfyg1WgW2hVB3VH9/9txMRIySfRoD8OMD9
|
||||||
|
rJfE8mhJcCELY1Fp2G4U6pghoGqRTyalHO5pxVFQuumudYnNlJhdSflcL6Y17Y5F
|
||||||
|
pclI8vJ3j940x/w1XfAd68xiw/Rc6SZQzIzvl6mjSGyFX5Un814wWXQZ7kAtH9fV
|
||||||
|
d8l75O02GLoocmkePwPFmhqc09WYAZTZgxJqEPyI6S1VHOUBsGru5rkY44zeRs2p
|
||||||
|
V2jHSIpcsbP04iwMDNFJV24Fio8A9hV4LFm5Nyv3O6gBgyyiRnYGvfS9R6wazGNW
|
||||||
|
LXAXQw69Wios4PxdlIX85jIJgyJ5GrjpjTTYmzkhe7fs8s3jdm4a2mFMWQcjbSia
|
||||||
|
15mF/1TdVNcKqt/M55aYY6HL3AnIc90TDIXr7UWZVJSeYicVZdI8N0Ih/1myOYw7
|
||||||
|
3NvqUetYLw/FQ7C+763N9QLgSdPlBTMkMSyB2pkXAAzWwJ/UPJ6z5REZmTVHu8Kf
|
||||||
|
I5UD0GwVnfUpBTLEpUG4oTH39PhKlncCKtmMnaZiu0DzxMy0xeskFT7YZFj0BKQc
|
||||||
|
JXXeqkcOvTFHibpLR5lQ1Q==
|
||||||
|
-----END CERTIFICATE-----
|
27
src/test/test_pki/ValidClient.key
Normal file
27
src/test/test_pki/ValidClient.key
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIIEpgIBAAKCAQEAneTyMKf0FAN1FRwxywUGp5Mg0zskMUsykegmzsodoZE7P5e/
|
||||||
|
HiNinsKL2ID+KKMEbB2FEzXGRwQSpt3xOgaGTlbkINE8NduqKSeVhDue5z6Hqp/0
|
||||||
|
ZYnPpZvK/yDOq1AlNHLj6z9zoMxioHHpXZZ1pgWes+gj7QpYL9B9BIKb1ue/4H73
|
||||||
|
luCXzjeMPgo1ihRcAHZOzcIMAFbqQ3kw783SuBMVmP3B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WACV7CHtpID6YM18c//IXM7RwREBLoOWB1OgOYZlrMOuf+AcmMQHAFivbvy3Sg
|
||||||
|
8kSnhQUmBzNyT2qhID0Yg/irAoGBAIDfAGhjY8kqI8Y7TDOGR5Op7Vdh6s307Rio
|
||||||
|
5YeE3k/2p3kFpiIUdSm3fBXjRGvlmF8ZhHxrf8n9MK5Rcn8VUoKfT18vKZ1MYdzq
|
||||||
|
ulNxDe9B953IiC7i9oGnTuOB5q/L5OCKjaHpUX3Wok1cjeVVRpLNnHpIFKXg1CL9
|
||||||
|
uo5+ecxRAoGBAKUr4pYT8wmu8BoNNoVkn6/c7m7ssBJxRUsj7cjxNpCIXzUKMzDj
|
||||||
|
Vqup7ex/tVOXZ10JEE96IMvm+b+Dje32x5oP2qaMYAlAhxJd6P0+5C7eRhZnwqYa
|
||||||
|
n82eXRq0ij6ggvXHvfhxgpa51hCRtEv6MGNu5qJ9QGKxb8VAFbQT3vPI
|
||||||
|
-----END RSA PRIVATE KEY-----
|
25
src/test/test_pki/localhost.crt
Normal file
25
src/test/test_pki/localhost.crt
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIERzCCAi+gAwIBAgIQAtk0UZ5qjqGgxYWL7X9GhDANBgkqhkiG9w0BAQsFADAa
|
||||||
|
MRgwFgYDVQQDEw9UQ1BUdW5uZWxUZXN0Q0EwHhcNMjIwOTAyMDcwNzUxWhcNNDIw
|
||||||
|
OTAyMDcwNjEyWjAUMRIwEAYDVQQDEwlsb2NhbGhvc3QwggEiMA0GCSqGSIb3DQEB
|
||||||
|
AQUAA4IBDwAwggEKAoIBAQDLuZElNqvAPIiTBjWJIjD1Ie+Amw1MvsWMY7UP56qC
|
||||||
|
czkvHI4wfHRJ+mCsUsbKnKR8nYDCa2CiiZpI/oWDZcQZBWmOjaoeBJajw6g+sjFl
|
||||||
|
+lft4xY6aMSXnpcU71KNelOLZsZmPYs24ZUgmjnQB1s6HZlF1niGabCaNnLt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uR1Fsrgo+SYJqCeoe90+oo+GdqOmRuSZU9
|
||||||
|
N+ry011LZMsNzaHifWqsh1jp3kUQ5XnBA4KWv1Asgg0oCpRnYmUS7GSSdBZkp9a2
|
||||||
|
0TEp4yh/gUZ+YO3/XQmpDa1/3kojfhD+WcRQoZ5lwMrlwxtvmiOit4JJQA==
|
||||||
|
-----END CERTIFICATE-----
|
27
src/test/test_pki/localhost.key
Normal file
27
src/test/test_pki/localhost.key
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIIEpAIBAAKCAQEAy7mRJTarwDyIkwY1iSIw9SHvgJsNTL7FjGO1D+eqgnM5LxyO
|
||||||
|
MHx0SfpgrFLGypykfJ2AwmtgoomaSP6Fg2XEGQVpjo2qHgSWo8OoPrIxZfpX7eMW
|
||||||
|
OmjEl56XFO9SjXpTi2bGZj2LNuGVIJo50AdbOh2ZRdZ4hmmwmjZy7Xec9hwT6h56
|
||||||
|
NmL7w+K+NZ//pA44SqGdLdHKGZ2WgZRDzL5wTpQtWfwp+NbTkUxpIJt60/j2N2kv
|
||||||
|
J9qu6ay7zHO0A/+JGjeRKeiMnV2CAfoI8CLHIEhxHS2atKwFNV5Pz0KwnD98rHXl
|
||||||
|
xZ0quFbr4FUoFz2uKQAr2PnDY2kk85NVkWi1tQIDAQABAoIBAGipZAUPSjtPngaS
|
||||||
|
iQxzsV0uWwHiJnoIBCt0yf9q0DGGiplGfVIxjfi3ldTSDejngqW2sQCw84ttUAMy
|
||||||
|
J1ty+8SzACDJbN1RFCb8DMJw/2nZrDS9lpzZWC5gvlN2BB5E+wjB+ylpcsz2JYwD
|
||||||
|
T7ItJVP9AtJbNb4wLBd945tV+SCCL4wrfaudjDAAXw5YZSIjTucxU4WRm2y8wZ86
|
||||||
|
do4J+NscjLpUvuIthfGiui75WGHEdtNu5iveM1dUsQWrIsMxk53D425ovd5Szx6x
|
||||||
|
6UJBjSwhmIAXxtAwzzrlO/U/4JAyMOHJs+hmCu78bLwjSJBzP/fZzG/KhFm0eyMD
|
||||||
|
RNMDy4ECgYEA6g42ffOGfP/58IxPk8C+xoRjc2a1TAI/z3ymAxbC+iFYPCiuabXf
|
||||||
|
twJkTl0yioupq3H0yW6dh2/nTtIpA99L2tEYr44R48LcSD2R5UyE8nYohz+LlOJf
|
||||||
|
U/vx/p7ao6I8mv7xFI5E52ChvEfkvNwmVcUJlmZ1JswGdwNf4WZzb+ECgYEA3tNc
|
||||||
|
EXdiWPbkzbOZISJwMyA6S5NqIZm5zoBLtU5ChDoqHQMYE6YmI0stgpNEwEvcmO2C
|
||||||
|
+9cGvB5mhklrYxxIRL9TzqqUi628/DqSTubBm/Xm+WblRKoDCN0dKK6SS/pkrxWw
|
||||||
|
YyIGbrCHQXWR1KOlvTvq7uHNXixOvpQVElrmkFUCgYEA6EUUhKeAJlosoi/L5NfZ
|
||||||
|
Os40l1gswHJW+sQ7R0N2WJ1wn7rLYvJvQYFpI29Pcbgpt48OGjvgroA5rrnWpBYb
|
||||||
|
g9oPQmCdlkZRLouTVlc6dBcYHyfLkAOaEJEtVL42QT8GH9ayTfDlpiv6NQuvjlB2
|
||||||
|
5pTz78JbrhW4sLCznM577mECgYAcThMC8PxgOrSj4K2SBPLlu7FMCmTP8dwlfCyh
|
||||||
|
0lgmvdC9sLftPwzXLOSSEq0IFFroXjtmTFFBskbpxgfLJjuT6A34Ubje6Wn5TGNr
|
||||||
|
fGqZqin2AnkbONF73cKneU2CM0N47jNi1F6mzuvPh+THcyZJnIPiZnKVBOHX2a23
|
||||||
|
kC57pQKBgQCchLrp2oX0q0jKVb5BqbsJiRMuBhRC96M0IABH6YRaCW372XCvgCWC
|
||||||
|
jtvXuT0XmqTYbmtpPEw1Pp9eJ3qminK4Z55N2fG+c9wtzJ+Mli8UoS3yFRSzbneD
|
||||||
|
LtbdqXEoZPYd6dLbTPTe43Pnl45o4epC+46c678nP/TrtfnKAiL1SA==
|
||||||
|
-----END RSA PRIVATE KEY-----
|
58
src/test/tls_auth_expired_certificate.rs
Normal file
58
src/test/tls_auth_expired_certificate.rs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
use tokio::task;
|
||||||
|
|
||||||
|
use crate::tcp_relay_client::client_config::ClientConfig;
|
||||||
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
|
use crate::test::dummy_tcp_sockets::{wait_for_port, DummyTCPServer};
|
||||||
|
use crate::test::pki::Pki;
|
||||||
|
use crate::test::{get_port_number, PortsAllocation, LOCALHOST_IP};
|
||||||
|
|
||||||
|
fn port(index: u16) -> u16 {
|
||||||
|
get_port_number(PortsAllocation::TlsAuthExpiredClientCertificate, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
// Start internal service
|
||||||
|
let local_server = DummyTCPServer::start(port(1)).await;
|
||||||
|
tokio::spawn(async move {
|
||||||
|
local_server.loop_conn_square_operations().await;
|
||||||
|
});
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
let local_set = task::LocalSet::new();
|
||||||
|
local_set
|
||||||
|
.run_until(async move {
|
||||||
|
wait_for_port(port(1)).await;
|
||||||
|
|
||||||
|
// Start server relay
|
||||||
|
task::spawn_local(crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: Some(pki.localhost_crt.file_path()),
|
||||||
|
tls_key: Some(pki.localhost_key.file_path()),
|
||||||
|
tls_client_auth_root_cert: Some(pki.root_ca_crt.file_path()),
|
||||||
|
tls_revocation_list: Some(pki.root_ca_crl.file_path()),
|
||||||
|
}));
|
||||||
|
wait_for_port(port(0)).await;
|
||||||
|
|
||||||
|
// Start client relay
|
||||||
|
crate::tcp_relay_client::run_app(ClientConfig {
|
||||||
|
relay_url: format!("https://localhost:{}", port(0)),
|
||||||
|
listen_address: LOCALHOST_IP.to_string(),
|
||||||
|
root_certificate: Some(pki.root_ca_crt.file_path()),
|
||||||
|
tls_cert: Some(pki.expired_client_crt.file_path()),
|
||||||
|
tls_key: Some(pki.valid_client_key.file_path()),
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
}
|
58
src/test/tls_auth_invalid_certificate.rs
Normal file
58
src/test/tls_auth_invalid_certificate.rs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
use tokio::task;
|
||||||
|
|
||||||
|
use crate::tcp_relay_client::client_config::ClientConfig;
|
||||||
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
|
use crate::test::dummy_tcp_sockets::{wait_for_port, DummyTCPServer};
|
||||||
|
use crate::test::pki::Pki;
|
||||||
|
use crate::test::{get_port_number, PortsAllocation, LOCALHOST_IP};
|
||||||
|
|
||||||
|
fn port(index: u16) -> u16 {
|
||||||
|
get_port_number(PortsAllocation::TlsAuthInvalidClientCertificate, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
// Start internal service
|
||||||
|
let local_server = DummyTCPServer::start(port(1)).await;
|
||||||
|
tokio::spawn(async move {
|
||||||
|
local_server.loop_conn_square_operations().await;
|
||||||
|
});
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
let local_set = task::LocalSet::new();
|
||||||
|
local_set
|
||||||
|
.run_until(async move {
|
||||||
|
wait_for_port(port(1)).await;
|
||||||
|
|
||||||
|
// Start server relay
|
||||||
|
task::spawn_local(crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: Some(pki.localhost_crt.file_path()),
|
||||||
|
tls_key: Some(pki.localhost_key.file_path()),
|
||||||
|
tls_client_auth_root_cert: Some(pki.other_ca_crt.file_path()),
|
||||||
|
tls_revocation_list: Some(pki.other_ca_crl.file_path()),
|
||||||
|
}));
|
||||||
|
wait_for_port(port(0)).await;
|
||||||
|
|
||||||
|
// Start client relay
|
||||||
|
crate::tcp_relay_client::run_app(ClientConfig {
|
||||||
|
relay_url: format!("https://localhost:{}", port(0)),
|
||||||
|
listen_address: LOCALHOST_IP.to_string(),
|
||||||
|
root_certificate: Some(pki.root_ca_crt.file_path()),
|
||||||
|
tls_cert: Some(pki.revoked_client_crt.file_path()),
|
||||||
|
tls_key: Some(pki.revoked_client_key.file_path()),
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
}
|
58
src/test/tls_auth_revoked_certificate.rs
Normal file
58
src/test/tls_auth_revoked_certificate.rs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
use tokio::task;
|
||||||
|
|
||||||
|
use crate::tcp_relay_client::client_config::ClientConfig;
|
||||||
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
|
use crate::test::dummy_tcp_sockets::{wait_for_port, DummyTCPServer};
|
||||||
|
use crate::test::pki::Pki;
|
||||||
|
use crate::test::{get_port_number, PortsAllocation, LOCALHOST_IP};
|
||||||
|
|
||||||
|
fn port(index: u16) -> u16 {
|
||||||
|
get_port_number(PortsAllocation::TlsAuthRevokedClientCertificate, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
// Start internal service
|
||||||
|
let local_server = DummyTCPServer::start(port(1)).await;
|
||||||
|
tokio::spawn(async move {
|
||||||
|
local_server.loop_conn_square_operations().await;
|
||||||
|
});
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
let local_set = task::LocalSet::new();
|
||||||
|
local_set
|
||||||
|
.run_until(async move {
|
||||||
|
wait_for_port(port(1)).await;
|
||||||
|
|
||||||
|
// Start server relay
|
||||||
|
task::spawn_local(crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: Some(pki.localhost_crt.file_path()),
|
||||||
|
tls_key: Some(pki.localhost_key.file_path()),
|
||||||
|
tls_client_auth_root_cert: Some(pki.root_ca_crt.file_path()),
|
||||||
|
tls_revocation_list: Some(pki.root_ca_crl.file_path()),
|
||||||
|
}));
|
||||||
|
wait_for_port(port(0)).await;
|
||||||
|
|
||||||
|
// Start client relay
|
||||||
|
crate::tcp_relay_client::run_app(ClientConfig {
|
||||||
|
relay_url: format!("https://localhost:{}", port(0)),
|
||||||
|
listen_address: LOCALHOST_IP.to_string(),
|
||||||
|
root_certificate: Some(pki.root_ca_crt.file_path()),
|
||||||
|
tls_cert: Some(pki.revoked_client_crt.file_path()),
|
||||||
|
tls_key: Some(pki.revoked_client_key.file_path()),
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
}
|
59
src/test/valid_token_with_custom_increment.rs
Normal file
59
src/test/valid_token_with_custom_increment.rs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
use tokio::task;
|
||||||
|
|
||||||
|
use crate::tcp_relay_client::client_config::ClientConfig;
|
||||||
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
|
use crate::test::dummy_tcp_sockets::{
|
||||||
|
dummy_tcp_client_square_root_requests, wait_for_port, DummyTCPServer,
|
||||||
|
};
|
||||||
|
use crate::test::{get_port_number, PortsAllocation, LOCALHOST_IP};
|
||||||
|
|
||||||
|
const VALID_TOKEN: &str = "AvalidTOKEN";
|
||||||
|
|
||||||
|
fn port(index: u16) -> u16 {
|
||||||
|
get_port_number(PortsAllocation::ValidTokenWithCustomIncrement, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test()]
|
||||||
|
async fn test() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
// Start internal service
|
||||||
|
let local_server = DummyTCPServer::start(port(1)).await;
|
||||||
|
tokio::spawn(async move {
|
||||||
|
local_server.loop_conn_square_operations().await;
|
||||||
|
});
|
||||||
|
|
||||||
|
let local_set = task::LocalSet::new();
|
||||||
|
local_set
|
||||||
|
.run_until(async move {
|
||||||
|
wait_for_port(port(1)).await;
|
||||||
|
|
||||||
|
// Start server relay
|
||||||
|
task::spawn_local(crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![VALID_TOKEN.to_string()],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 3,
|
||||||
|
tls_cert: None,
|
||||||
|
tls_key: None,
|
||||||
|
tls_client_auth_root_cert: None,
|
||||||
|
tls_revocation_list: None,
|
||||||
|
}));
|
||||||
|
wait_for_port(port(0)).await;
|
||||||
|
|
||||||
|
// Start client relay
|
||||||
|
task::spawn(crate::tcp_relay_client::run_app(ClientConfig {
|
||||||
|
token: Some(VALID_TOKEN.to_string()),
|
||||||
|
relay_url: format!("http://{}:{}", LOCALHOST_IP, port(0)),
|
||||||
|
listen_address: LOCALHOST_IP.to_string(),
|
||||||
|
root_certificate: None,
|
||||||
|
..Default::default()
|
||||||
|
}));
|
||||||
|
wait_for_port(port(4)).await;
|
||||||
|
|
||||||
|
dummy_tcp_client_square_root_requests(port(4), 10).await;
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
}
|
63
src/test/valid_with_multiple_token_auth.rs
Normal file
63
src/test/valid_with_multiple_token_auth.rs
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
use tokio::task;
|
||||||
|
|
||||||
|
use crate::tcp_relay_client::client_config::ClientConfig;
|
||||||
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
|
use crate::test::dummy_tcp_sockets::{
|
||||||
|
dummy_tcp_client_square_root_requests, wait_for_port, DummyTCPServer,
|
||||||
|
};
|
||||||
|
use crate::test::{get_port_number, PortsAllocation, LOCALHOST_IP};
|
||||||
|
|
||||||
|
const VALID_TOKEN: &str = "AvalidTOKEN";
|
||||||
|
|
||||||
|
fn port(index: u16) -> u16 {
|
||||||
|
get_port_number(PortsAllocation::ValidWithTokenFile, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test()]
|
||||||
|
async fn valid_with_multiple_token_auth() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
// Start internal service
|
||||||
|
let local_server = DummyTCPServer::start(port(1)).await;
|
||||||
|
tokio::spawn(async move {
|
||||||
|
local_server.loop_conn_square_operations().await;
|
||||||
|
});
|
||||||
|
|
||||||
|
let local_set = task::LocalSet::new();
|
||||||
|
local_set
|
||||||
|
.run_until(async move {
|
||||||
|
wait_for_port(port(1)).await;
|
||||||
|
|
||||||
|
// Start server relay
|
||||||
|
task::spawn_local(crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![
|
||||||
|
"tok0".to_string(),
|
||||||
|
VALID_TOKEN.to_string(),
|
||||||
|
"tok2".to_string(),
|
||||||
|
],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: None,
|
||||||
|
tls_key: None,
|
||||||
|
tls_client_auth_root_cert: None,
|
||||||
|
tls_revocation_list: None,
|
||||||
|
}));
|
||||||
|
wait_for_port(port(0)).await;
|
||||||
|
|
||||||
|
// Start client relay
|
||||||
|
task::spawn(crate::tcp_relay_client::run_app(ClientConfig {
|
||||||
|
token: Some(VALID_TOKEN.to_string()),
|
||||||
|
relay_url: format!("http://{}:{}", LOCALHOST_IP, port(0)),
|
||||||
|
listen_address: LOCALHOST_IP.to_string(),
|
||||||
|
root_certificate: None,
|
||||||
|
..Default::default()
|
||||||
|
}));
|
||||||
|
wait_for_port(port(2)).await;
|
||||||
|
|
||||||
|
dummy_tcp_client_square_root_requests(port(2), 10).await;
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
}
|
61
src/test/valid_with_tls_auth.rs
Normal file
61
src/test/valid_with_tls_auth.rs
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
use tokio::task;
|
||||||
|
|
||||||
|
use crate::tcp_relay_client::client_config::ClientConfig;
|
||||||
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
|
use crate::test::dummy_tcp_sockets::{
|
||||||
|
dummy_tcp_client_square_root_requests, wait_for_port, DummyTCPServer,
|
||||||
|
};
|
||||||
|
use crate::test::pki::Pki;
|
||||||
|
use crate::test::{get_port_number, PortsAllocation, LOCALHOST_IP};
|
||||||
|
|
||||||
|
fn port(index: u16) -> u16 {
|
||||||
|
get_port_number(PortsAllocation::ValidWithTLSAuth, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
// Start internal service
|
||||||
|
let local_server = DummyTCPServer::start(port(1)).await;
|
||||||
|
tokio::spawn(async move {
|
||||||
|
local_server.loop_conn_square_operations().await;
|
||||||
|
});
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
let local_set = task::LocalSet::new();
|
||||||
|
local_set
|
||||||
|
.run_until(async move {
|
||||||
|
wait_for_port(port(1)).await;
|
||||||
|
|
||||||
|
// Start server relay
|
||||||
|
task::spawn_local(crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: Some(pki.localhost_crt.file_path()),
|
||||||
|
tls_key: Some(pki.localhost_key.file_path()),
|
||||||
|
tls_client_auth_root_cert: Some(pki.root_ca_crt.file_path()),
|
||||||
|
tls_revocation_list: Some(pki.root_ca_crl.file_path()),
|
||||||
|
}));
|
||||||
|
wait_for_port(port(0)).await;
|
||||||
|
|
||||||
|
// Start client relay
|
||||||
|
task::spawn(crate::tcp_relay_client::run_app(ClientConfig {
|
||||||
|
relay_url: format!("https://localhost:{}", port(0)),
|
||||||
|
listen_address: LOCALHOST_IP.to_string(),
|
||||||
|
root_certificate: Some(pki.root_ca_crt.file_path()),
|
||||||
|
tls_cert: Some(pki.valid_client_crt.file_path()),
|
||||||
|
tls_key: Some(pki.valid_client_key.file_path()),
|
||||||
|
..Default::default()
|
||||||
|
}));
|
||||||
|
wait_for_port(port(2)).await;
|
||||||
|
|
||||||
|
dummy_tcp_client_square_root_requests(port(2), 10).await;
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
}
|
59
src/test/valid_with_token_auth.rs
Normal file
59
src/test/valid_with_token_auth.rs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
use tokio::task;
|
||||||
|
|
||||||
|
use crate::tcp_relay_client::client_config::ClientConfig;
|
||||||
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
|
use crate::test::dummy_tcp_sockets::{
|
||||||
|
dummy_tcp_client_square_root_requests, wait_for_port, DummyTCPServer,
|
||||||
|
};
|
||||||
|
use crate::test::{get_port_number, PortsAllocation, LOCALHOST_IP};
|
||||||
|
|
||||||
|
const VALID_TOKEN: &str = "AvalidTOKEN";
|
||||||
|
|
||||||
|
fn port(index: u16) -> u16 {
|
||||||
|
get_port_number(PortsAllocation::ValidWithTokenAuth, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test()]
|
||||||
|
async fn valid_with_token_auth() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
// Start internal service
|
||||||
|
let local_server = DummyTCPServer::start(port(1)).await;
|
||||||
|
tokio::spawn(async move {
|
||||||
|
local_server.loop_conn_square_operations().await;
|
||||||
|
});
|
||||||
|
|
||||||
|
let local_set = task::LocalSet::new();
|
||||||
|
local_set
|
||||||
|
.run_until(async move {
|
||||||
|
wait_for_port(port(1)).await;
|
||||||
|
|
||||||
|
// Start server relay
|
||||||
|
task::spawn_local(crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![VALID_TOKEN.to_string()],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: None,
|
||||||
|
tls_key: None,
|
||||||
|
tls_client_auth_root_cert: None,
|
||||||
|
tls_revocation_list: None,
|
||||||
|
}));
|
||||||
|
wait_for_port(port(0)).await;
|
||||||
|
|
||||||
|
// Start client relay
|
||||||
|
task::spawn(crate::tcp_relay_client::run_app(ClientConfig {
|
||||||
|
token: Some(VALID_TOKEN.to_string()),
|
||||||
|
relay_url: format!("http://{}:{}", LOCALHOST_IP, port(0)),
|
||||||
|
listen_address: LOCALHOST_IP.to_string(),
|
||||||
|
root_certificate: None,
|
||||||
|
..Default::default()
|
||||||
|
}));
|
||||||
|
wait_for_port(port(2)).await;
|
||||||
|
|
||||||
|
dummy_tcp_client_square_root_requests(port(2), 10).await;
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
}
|
62
src/test/valid_with_token_auth_and_server_tls.rs
Normal file
62
src/test/valid_with_token_auth_and_server_tls.rs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
use tokio::task;
|
||||||
|
|
||||||
|
use crate::tcp_relay_client::client_config::ClientConfig;
|
||||||
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
|
use crate::test::dummy_tcp_sockets::{
|
||||||
|
dummy_tcp_client_square_root_requests, wait_for_port, DummyTCPServer,
|
||||||
|
};
|
||||||
|
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::ValidWithTokenAuthAndServerTLS, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test()]
|
||||||
|
async fn test() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
// Start internal service
|
||||||
|
let local_server = DummyTCPServer::start(port(1)).await;
|
||||||
|
tokio::spawn(async move {
|
||||||
|
local_server.loop_conn_square_operations().await;
|
||||||
|
});
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
let local_set = task::LocalSet::new();
|
||||||
|
local_set
|
||||||
|
.run_until(async move {
|
||||||
|
wait_for_port(port(1)).await;
|
||||||
|
|
||||||
|
// Start server relay
|
||||||
|
task::spawn_local(crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![VALID_TOKEN.to_string()],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: Some(pki.localhost_crt.file_path()),
|
||||||
|
tls_key: Some(pki.localhost_key.file_path()),
|
||||||
|
tls_client_auth_root_cert: None,
|
||||||
|
tls_revocation_list: None,
|
||||||
|
}));
|
||||||
|
wait_for_port(port(0)).await;
|
||||||
|
|
||||||
|
// Start client relay
|
||||||
|
task::spawn(crate::tcp_relay_client::run_app(ClientConfig {
|
||||||
|
token: Some(VALID_TOKEN.to_string()),
|
||||||
|
relay_url: format!("https://localhost:{}", port(0)),
|
||||||
|
listen_address: LOCALHOST_IP.to_string(),
|
||||||
|
root_certificate: Some(pki.root_ca_crt.file_path()),
|
||||||
|
..Default::default()
|
||||||
|
}));
|
||||||
|
wait_for_port(port(2)).await;
|
||||||
|
|
||||||
|
dummy_tcp_client_square_root_requests(port(2), 10).await;
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
}
|
67
src/test/valid_with_token_auth_multiple_ports.rs
Normal file
67
src/test/valid_with_token_auth_multiple_ports.rs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
use tokio::task;
|
||||||
|
|
||||||
|
use crate::tcp_relay_client::client_config::ClientConfig;
|
||||||
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
|
use crate::test::dummy_tcp_sockets::{
|
||||||
|
dummy_tcp_client_additions_requests, dummy_tcp_client_square_root_requests, wait_for_port,
|
||||||
|
DummyTCPServer,
|
||||||
|
};
|
||||||
|
use crate::test::{get_port_number, PortsAllocation, LOCALHOST_IP};
|
||||||
|
|
||||||
|
const VALID_TOKEN: &str = "AvalidTOKEN";
|
||||||
|
const NUM_INC: i32 = 5;
|
||||||
|
|
||||||
|
fn port(index: u16) -> u16 {
|
||||||
|
get_port_number(PortsAllocation::ValidWithTokenAuthMultiplePorts, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test()]
|
||||||
|
async fn test() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
// Start internal services
|
||||||
|
let local_server_1 = DummyTCPServer::start(port(1)).await;
|
||||||
|
tokio::spawn(async move {
|
||||||
|
local_server_1.loop_conn_square_operations().await;
|
||||||
|
});
|
||||||
|
|
||||||
|
let local_server_2 = DummyTCPServer::start(port(3)).await;
|
||||||
|
tokio::spawn(async move {
|
||||||
|
local_server_2.loop_next_conn_add_operations(NUM_INC).await;
|
||||||
|
});
|
||||||
|
|
||||||
|
let local_set = task::LocalSet::new();
|
||||||
|
local_set
|
||||||
|
.run_until(async move {
|
||||||
|
wait_for_port(port(1)).await;
|
||||||
|
|
||||||
|
// Start server relay
|
||||||
|
task::spawn_local(crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![VALID_TOKEN.to_string()],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1), port(3)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: None,
|
||||||
|
tls_key: None,
|
||||||
|
tls_client_auth_root_cert: None,
|
||||||
|
tls_revocation_list: None,
|
||||||
|
}));
|
||||||
|
wait_for_port(port(0)).await;
|
||||||
|
|
||||||
|
// Start client relay
|
||||||
|
task::spawn(crate::tcp_relay_client::run_app(ClientConfig {
|
||||||
|
token: Some(VALID_TOKEN.to_string()),
|
||||||
|
relay_url: format!("http://{}:{}", LOCALHOST_IP, port(0)),
|
||||||
|
listen_address: LOCALHOST_IP.to_string(),
|
||||||
|
root_certificate: None,
|
||||||
|
..Default::default()
|
||||||
|
}));
|
||||||
|
wait_for_port(port(2)).await;
|
||||||
|
|
||||||
|
dummy_tcp_client_square_root_requests(port(2), 10).await;
|
||||||
|
dummy_tcp_client_additions_requests(port(4), NUM_INC, 10).await;
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
}
|
62
src/test/valid_with_token_file.rs
Normal file
62
src/test/valid_with_token_file.rs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
use tokio::task;
|
||||||
|
|
||||||
|
use crate::tcp_relay_client::client_config::ClientConfig;
|
||||||
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
|
use crate::test::dummy_tcp_sockets::{
|
||||||
|
dummy_tcp_client_square_root_requests, wait_for_port, DummyTCPServer,
|
||||||
|
};
|
||||||
|
use crate::test::{get_port_number, PortsAllocation, LOCALHOST_IP};
|
||||||
|
|
||||||
|
const VALID_TOKEN: &str = "AvalidTOKEN";
|
||||||
|
|
||||||
|
fn port(index: u16) -> u16 {
|
||||||
|
get_port_number(PortsAllocation::ValidWithMultipleTokenAuth, index)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test()]
|
||||||
|
async fn valid_with_token_file() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
// Start internal service
|
||||||
|
let local_server = DummyTCPServer::start(port(1)).await;
|
||||||
|
tokio::spawn(async move {
|
||||||
|
local_server.loop_conn_square_operations().await;
|
||||||
|
});
|
||||||
|
|
||||||
|
let local_set = task::LocalSet::new();
|
||||||
|
local_set
|
||||||
|
.run_until(async move {
|
||||||
|
wait_for_port(port(1)).await;
|
||||||
|
|
||||||
|
let token_file = mktemp::Temp::new_file().unwrap();
|
||||||
|
std::fs::write(&token_file, format!("tok1\ntok2\n{}\ntok4", VALID_TOKEN)).unwrap();
|
||||||
|
|
||||||
|
// Start server relay
|
||||||
|
task::spawn_local(crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![],
|
||||||
|
tokens_file: Some(token_file.to_str().unwrap().to_string()),
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: None,
|
||||||
|
tls_key: None,
|
||||||
|
tls_client_auth_root_cert: None,
|
||||||
|
tls_revocation_list: None,
|
||||||
|
}));
|
||||||
|
wait_for_port(port(0)).await;
|
||||||
|
|
||||||
|
// Start client relay
|
||||||
|
task::spawn(crate::tcp_relay_client::run_app(ClientConfig {
|
||||||
|
token: Some(VALID_TOKEN.to_string()),
|
||||||
|
relay_url: format!("http://{}:{}", LOCALHOST_IP, port(0)),
|
||||||
|
listen_address: LOCALHOST_IP.to_string(),
|
||||||
|
root_certificate: None,
|
||||||
|
..Default::default()
|
||||||
|
}));
|
||||||
|
wait_for_port(port(2)).await;
|
||||||
|
|
||||||
|
dummy_tcp_client_square_root_requests(port(2), 10).await;
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
}
|
54
src/test/with_token_auth_and_invalid_server_tls_bad_ca.rs
Normal file
54
src/test/with_token_auth_and_invalid_server_tls_bad_ca.rs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
use tokio::task;
|
||||||
|
|
||||||
|
use crate::tcp_relay_client::client_config::ClientConfig;
|
||||||
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
|
use crate::test::dummy_tcp_sockets::wait_for_port;
|
||||||
|
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::WithTokenAuthAndInvalidServerTLSBadCA,
|
||||||
|
index,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test()]
|
||||||
|
async fn test() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
let local_set = task::LocalSet::new();
|
||||||
|
local_set
|
||||||
|
.run_until(async move {
|
||||||
|
// Start server relay
|
||||||
|
task::spawn_local(crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![VALID_TOKEN.to_string()],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: Some(pki.localhost_crt.file_path()),
|
||||||
|
tls_key: Some(pki.localhost_key.file_path()),
|
||||||
|
tls_client_auth_root_cert: None,
|
||||||
|
tls_revocation_list: None,
|
||||||
|
}));
|
||||||
|
wait_for_port(port(0)).await;
|
||||||
|
|
||||||
|
// Start client relay
|
||||||
|
crate::tcp_relay_client::run_app(ClientConfig {
|
||||||
|
token: Some(VALID_TOKEN.to_string()),
|
||||||
|
relay_url: format!("https://localhost:{}", port(0)),
|
||||||
|
listen_address: LOCALHOST_IP.to_string(),
|
||||||
|
root_certificate: Some(pki.other_ca_crt.file_path()),
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
use tokio::task;
|
||||||
|
|
||||||
|
use crate::tcp_relay_client::client_config::ClientConfig;
|
||||||
|
use crate::tcp_relay_server::server_config::ServerConfig;
|
||||||
|
use crate::test::dummy_tcp_sockets::wait_for_port;
|
||||||
|
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::WithTokenAuthAndInvalidServerTLSExpiredAndBadCN,
|
||||||
|
index,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tokio::test()]
|
||||||
|
async fn test() {
|
||||||
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|
||||||
|
let pki = Pki::load();
|
||||||
|
|
||||||
|
let local_set = task::LocalSet::new();
|
||||||
|
local_set
|
||||||
|
.run_until(async move {
|
||||||
|
// Start server relay
|
||||||
|
task::spawn_local(crate::tcp_relay_server::run_app(ServerConfig {
|
||||||
|
tokens: vec![VALID_TOKEN.to_string()],
|
||||||
|
tokens_file: None,
|
||||||
|
ports: vec![port(1)],
|
||||||
|
upstream_server: "127.0.0.1".to_string(),
|
||||||
|
listen_address: format!("127.0.0.1:{}", port(0)),
|
||||||
|
increment_ports: 1,
|
||||||
|
tls_cert: Some(pki.expired_client_crt.file_path()),
|
||||||
|
tls_key: Some(pki.expired_client_key.file_path()),
|
||||||
|
tls_client_auth_root_cert: None,
|
||||||
|
tls_revocation_list: None,
|
||||||
|
}));
|
||||||
|
wait_for_port(port(0)).await;
|
||||||
|
|
||||||
|
// Start client relay
|
||||||
|
crate::tcp_relay_client::run_app(ClientConfig {
|
||||||
|
token: Some(VALID_TOKEN.to_string()),
|
||||||
|
relay_url: format!("https://localhost:{}", port(0)),
|
||||||
|
listen_address: LOCALHOST_IP.to_string(),
|
||||||
|
root_certificate: Some(pki.root_ca_crt.file_path()),
|
||||||
|
..Default::default()
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_err();
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user