mirror of https://github.com/fafhrd91/actix-web
actix-test: add rustls-0.23
This commit is contained in:
parent
52422f9d5c
commit
9b60ef1cbd
|
@ -29,6 +29,8 @@ rustls-0_20 = ["tls-rustls-0_20", "actix-http/rustls-0_20", "awc/rustls-0_20"]
|
||||||
rustls-0_21 = ["tls-rustls-0_21", "actix-http/rustls-0_21", "awc/rustls-0_21"]
|
rustls-0_21 = ["tls-rustls-0_21", "actix-http/rustls-0_21", "awc/rustls-0_21"]
|
||||||
# TLS via Rustls v0.22
|
# TLS via Rustls v0.22
|
||||||
rustls-0_22 = ["tls-rustls-0_22", "actix-http/rustls-0_22", "awc/rustls-0_22-webpki-roots"]
|
rustls-0_22 = ["tls-rustls-0_22", "actix-http/rustls-0_22", "awc/rustls-0_22-webpki-roots"]
|
||||||
|
# TLS via Rustls v0.22
|
||||||
|
rustls-0_23 = ["tls-rustls-0_23", "actix-http/rustls-0_23", "awc/rustls-0_23-webpki-roots"]
|
||||||
|
|
||||||
# TLS via OpenSSL
|
# TLS via OpenSSL
|
||||||
openssl = ["tls-openssl", "actix-http/openssl", "awc/openssl"]
|
openssl = ["tls-openssl", "actix-http/openssl", "awc/openssl"]
|
||||||
|
@ -53,4 +55,5 @@ tls-openssl = { package = "openssl", version = "0.10.55", optional = true }
|
||||||
tls-rustls-0_20 = { package = "rustls", version = "0.20", optional = true }
|
tls-rustls-0_20 = { package = "rustls", version = "0.20", optional = true }
|
||||||
tls-rustls-0_21 = { package = "rustls", version = "0.21", optional = true }
|
tls-rustls-0_21 = { package = "rustls", version = "0.21", optional = true }
|
||||||
tls-rustls-0_22 = { package = "rustls", version = "0.22", optional = true }
|
tls-rustls-0_22 = { package = "rustls", version = "0.22", optional = true }
|
||||||
|
tls-rustls-0_23 = { package = "rustls", version = "0.23", default-features = false, optional = true }
|
||||||
tokio = { version = "1.24.2", features = ["sync"] }
|
tokio = { version = "1.24.2", features = ["sync"] }
|
||||||
|
|
|
@ -145,6 +145,8 @@ where
|
||||||
StreamType::Rustls021(_) => true,
|
StreamType::Rustls021(_) => true,
|
||||||
#[cfg(feature = "rustls-0_22")]
|
#[cfg(feature = "rustls-0_22")]
|
||||||
StreamType::Rustls022(_) => true,
|
StreamType::Rustls022(_) => true,
|
||||||
|
#[cfg(feature = "rustls-0_23")]
|
||||||
|
StreamType::Rustls023(_) => true,
|
||||||
};
|
};
|
||||||
|
|
||||||
// run server in separate orphaned thread
|
// run server in separate orphaned thread
|
||||||
|
@ -371,6 +373,48 @@ where
|
||||||
.rustls_0_22(config.clone())
|
.rustls_0_22(config.clone())
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
#[cfg(feature = "rustls-0_23")]
|
||||||
|
StreamType::Rustls023(config) => match cfg.tp {
|
||||||
|
HttpVer::Http1 => builder.listen("test", tcp, move || {
|
||||||
|
let app_cfg =
|
||||||
|
AppConfig::__priv_test_new(false, local_addr.to_string(), local_addr);
|
||||||
|
|
||||||
|
let fac = factory()
|
||||||
|
.into_factory()
|
||||||
|
.map_err(|err| err.into().error_response());
|
||||||
|
|
||||||
|
HttpService::build()
|
||||||
|
.client_request_timeout(timeout)
|
||||||
|
.h1(map_config(fac, move |_| app_cfg.clone()))
|
||||||
|
.rustls_0_23(config.clone())
|
||||||
|
}),
|
||||||
|
HttpVer::Http2 => builder.listen("test", tcp, move || {
|
||||||
|
let app_cfg =
|
||||||
|
AppConfig::__priv_test_new(false, local_addr.to_string(), local_addr);
|
||||||
|
|
||||||
|
let fac = factory()
|
||||||
|
.into_factory()
|
||||||
|
.map_err(|err| err.into().error_response());
|
||||||
|
|
||||||
|
HttpService::build()
|
||||||
|
.client_request_timeout(timeout)
|
||||||
|
.h2(map_config(fac, move |_| app_cfg.clone()))
|
||||||
|
.rustls_0_23(config.clone())
|
||||||
|
}),
|
||||||
|
HttpVer::Both => builder.listen("test", tcp, move || {
|
||||||
|
let app_cfg =
|
||||||
|
AppConfig::__priv_test_new(false, local_addr.to_string(), local_addr);
|
||||||
|
|
||||||
|
let fac = factory()
|
||||||
|
.into_factory()
|
||||||
|
.map_err(|err| err.into().error_response());
|
||||||
|
|
||||||
|
HttpService::build()
|
||||||
|
.client_request_timeout(timeout)
|
||||||
|
.finish(map_config(fac, move |_| app_cfg.clone()))
|
||||||
|
.rustls_0_23(config.clone())
|
||||||
|
}),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
.expect("test server could not be created");
|
.expect("test server could not be created");
|
||||||
|
|
||||||
|
@ -447,6 +491,8 @@ enum StreamType {
|
||||||
Rustls021(tls_rustls_0_21::ServerConfig),
|
Rustls021(tls_rustls_0_21::ServerConfig),
|
||||||
#[cfg(feature = "rustls-0_22")]
|
#[cfg(feature = "rustls-0_22")]
|
||||||
Rustls022(tls_rustls_0_22::ServerConfig),
|
Rustls022(tls_rustls_0_22::ServerConfig),
|
||||||
|
#[cfg(feature = "rustls-0_23")]
|
||||||
|
Rustls023(tls_rustls_0_23::ServerConfig),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create default test server config.
|
/// Create default test server config.
|
||||||
|
@ -537,6 +583,13 @@ impl TestServerConfig {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Accepts secure connections via Rustls v0.22.
|
||||||
|
#[cfg(feature = "rustls-0_23")]
|
||||||
|
pub fn rustls_0_23(mut self, config: tls_rustls_0_23::ServerConfig) -> Self {
|
||||||
|
self.stream = StreamType::Rustls023(config);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Sets client timeout for first request.
|
/// Sets client timeout for first request.
|
||||||
pub fn client_request_timeout(mut self, dur: Duration) -> Self {
|
pub fn client_request_timeout(mut self, dur: Duration) -> Self {
|
||||||
self.client_request_timeout = dur;
|
self.client_request_timeout = dur;
|
||||||
|
|
Loading…
Reference in New Issue