aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgilles henaux <gill.henaux@gmail.com>2023-02-20 21:49:33 +0100
committergilles henaux <gill.henaux@gmail.com>2023-02-20 21:49:33 +0100
commit5cd8de4ac805590fc183276e3114aadad35051de (patch)
treee9be8e4dfb0ee3a65ce3b8f4ad17339912422074
parent6d85439ea69cecb9635a4eee64b4d784312ec3f5 (diff)
[tests] Use the newly added configuration methods
-rw-r--r--tests/certificates.rs14
-rw-r--r--tests/utils/mod.rs19
2 files changed, 21 insertions, 12 deletions
diff --git a/tests/certificates.rs b/tests/certificates.rs
index 21daec7..1745b0d 100644
--- a/tests/certificates.rs
+++ b/tests/certificates.rs
@@ -8,7 +8,7 @@ use bevy_quinnet::{
Client, QuinnetClientPlugin, DEFAULT_KNOWN_HOSTS_FILE,
},
server::{
- certificate::CertificateRetrievalMode, QuinnetServerPlugin, Server, ServerConfigurationData,
+ certificate::CertificateRetrievalMode, QuinnetServerPlugin, Server, ServerConfiguration,
},
};
@@ -72,7 +72,7 @@ fn trust_on_first_use() {
let mut server = server_app.world.resource_mut::<Server>();
let (server_cert, _) = server
.start_endpoint(
- ServerConfigurationData::new(SERVER_HOST.to_string(), port, "0.0.0.0".to_string()),
+ ServerConfiguration::from_ip("0.0.0.0".parse().unwrap(), port),
CertificateRetrievalMode::LoadFromFile {
cert_file: TEST_CERT_FILE.to_string(),
key_file: TEST_KEY_FILE.to_string(),
@@ -130,7 +130,7 @@ fn trust_on_first_use() {
);
assert_eq!(
cert_info.server_name.to_string(),
- SERVER_HOST.to_string(),
+ SERVER_IP.to_string(),
"The server name should match the one we configured"
);
@@ -200,8 +200,10 @@ fn trust_on_first_use() {
.world
.resource_mut::<Server>()
.start_endpoint(
- ServerConfigurationData::new(SERVER_HOST.to_string(), port, "0.0.0.0".to_string()),
- CertificateRetrievalMode::GenerateSelfSigned,
+ ServerConfiguration::from_ip(LOCAL_BIND_IP, port),
+ CertificateRetrievalMode::GenerateSelfSigned {
+ server_hostname: SERVER_IP.to_string(),
+ },
)
.unwrap();
@@ -270,7 +272,7 @@ fn trust_on_first_use() {
);
assert_eq!(
interaction_cert_info.server_name.to_string(),
- SERVER_HOST.to_string(),
+ SERVER_IP.to_string(),
"The server name in the certificate interaction event should be the server we want to connect to"
);
assert_eq!(
diff --git a/tests/utils/mod.rs b/tests/utils/mod.rs
index 24b0ac8..55a1353 100644
--- a/tests/utils/mod.rs
+++ b/tests/utils/mod.rs
@@ -1,4 +1,8 @@
-use std::{thread::sleep, time::Duration};
+use std::{
+ net::{IpAddr, Ipv4Addr},
+ thread::sleep,
+ time::Duration,
+};
use bevy::{
app::ScheduleRunnerPlugin,
@@ -17,7 +21,7 @@ use bevy_quinnet::{
},
server::{
self, certificate::CertificateRetrievalMode, QuinnetServerPlugin, Server,
- ServerConfigurationData,
+ ServerConfiguration,
},
shared::{
channel::{ChannelId, ChannelType},
@@ -56,7 +60,8 @@ pub enum SharedMessage {
TestMessage(String),
}
-pub const SERVER_HOST: &str = "127.0.0.1";
+pub const SERVER_IP: IpAddr = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1));
+pub const LOCAL_BIND_IP: IpAddr = IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0));
pub fn build_client_app() -> App {
let mut client_app = App::new();
@@ -81,7 +86,7 @@ pub fn build_server_app() -> App {
}
pub fn default_client_configuration(port: u16) -> ConnectionConfiguration {
- ConnectionConfiguration::new(SERVER_HOST.to_string(), port, "0.0.0.0".to_string(), 0)
+ ConnectionConfiguration::from_ips(SERVER_IP, port, LOCAL_BIND_IP, 0)
}
pub fn start_simple_connection(mut client: ResMut<Client>, port: Res<Port>) {
@@ -96,8 +101,10 @@ pub fn start_simple_connection(mut client: ResMut<Client>, port: Res<Port>) {
pub fn start_listening(mut server: ResMut<Server>, port: Res<Port>) {
server
.start_endpoint(
- ServerConfigurationData::new(SERVER_HOST.to_string(), port.0, "0.0.0.0".to_string()),
- CertificateRetrievalMode::GenerateSelfSigned,
+ ServerConfiguration::from_ip(LOCAL_BIND_IP, port.0),
+ CertificateRetrievalMode::GenerateSelfSigned {
+ server_hostname: SERVER_IP.to_string(),
+ },
)
.unwrap();
}