diff --git a/services/commtest/build.rs b/services/commtest/build.rs --- a/services/commtest/build.rs +++ b/services/commtest/build.rs @@ -1,7 +1,7 @@ use std::fs; use std::io::Error; -const PROTO_DIR: &'static str = "../../shared/protos"; +const PROTO_DIR: &str = "../../shared/protos"; fn main() -> Result<(), Error> { let proto_files = fs::read_dir(PROTO_DIR)?; diff --git a/services/commtest/src/identity/device.rs b/services/commtest/src/identity/device.rs --- a/services/commtest/src/identity/device.rs +++ b/services/commtest/src/identity/device.rs @@ -31,7 +31,7 @@ let mut client_registration = Registration::new(); let opaque_registration_request = - client_registration.start(&password).unwrap(); + client_registration.start(password).unwrap(); let registration_start_request = RegistrationStartRequest { opaque_registration_request, username: username.to_string(), @@ -69,7 +69,7 @@ let opaque_registration_upload = client_registration .finish( - &password, + password, ®istration_start_response.opaque_registration_response, ) .unwrap(); @@ -84,10 +84,10 @@ .unwrap() .into_inner(); - return DeviceInfo { + DeviceInfo { username: username.to_string(), device_id: device_id.to_string(), user_id: registration_finish_response.user_id, access_token: registration_finish_response.access_token, - }; + } } diff --git a/services/commtest/src/tools.rs b/services/commtest/src/tools.rs --- a/services/commtest/src/tools.rs +++ b/services/commtest/src/tools.rs @@ -9,7 +9,7 @@ predefined_byte_value: Option, ) -> Vec { let byte_value = predefined_byte_value.unwrap_or(b'A'); - return vec![byte_value; number_of_bytes]; + vec![byte_value; number_of_bytes] } #[derive( @@ -40,7 +40,7 @@ if number_of_threads_str.is_empty() { return num_cpus::get(); } - return number_of_threads_str.parse::().unwrap(); + number_of_threads_str.parse::().unwrap() } pub struct DataHasher { @@ -49,9 +49,9 @@ impl DataHasher { pub fn new() -> DataHasher { - return DataHasher { + DataHasher { hasher: Sha512::new(), - }; + } } pub fn update(data_hasher: &mut DataHasher, bytes: Vec) { @@ -59,6 +59,12 @@ } pub fn get_hash(self) -> String { let hash = self.hasher.finalize(); - return hash.encode_hex::(); + hash.encode_hex::() + } +} + +impl Default for DataHasher { + fn default() -> Self { + Self::new() } } diff --git a/services/commtest/tests/identity_tunnelbroker_tests.rs b/services/commtest/tests/identity_tunnelbroker_tests.rs --- a/services/commtest/tests/identity_tunnelbroker_tests.rs +++ b/services/commtest/tests/identity_tunnelbroker_tests.rs @@ -83,7 +83,7 @@ }; println!("Getting keyserver info for user, {}", device_info.user_id); - let first_reponse = client + let _first_reponse = client .get_keyserver_keys(keyserver_request.clone()) .await .expect("Second keyserver keys request failed") @@ -92,7 +92,7 @@ .unwrap(); // The current threshold is 5, but we only upload two. Should receive request - // from tunnelbroker to refresh keys + // from Tunnelbroker to refresh keys // Create session as a keyserver let device_info = create_device().await; diff --git a/services/commtest/tests/tunnelbroker_integration_test.rs b/services/commtest/tests/tunnelbroker_integration_tests.rs rename from services/commtest/tests/tunnelbroker_integration_test.rs rename to services/commtest/tests/tunnelbroker_integration_tests.rs --- a/services/commtest/tests/tunnelbroker_integration_test.rs +++ b/services/commtest/tests/tunnelbroker_integration_tests.rs @@ -6,7 +6,6 @@ use futures_util::StreamExt; use proto::tunnelbroker_service_client::TunnelbrokerServiceClient; use proto::MessageToDevice; -use tunnelbroker_messages as messages; use tunnelbroker_messages::RefreshKeyRequest; #[tokio::test] @@ -21,7 +20,7 @@ .await .unwrap(); - let refresh_request = messages::RefreshKeyRequest { + let refresh_request = RefreshKeyRequest { device_id: device_info.device_id.clone(), number_of_keys: 5, }; @@ -51,7 +50,7 @@ /// Test that a message to an offline device gets pushed to dynamodb /// then recalled once a device connects #[tokio::test] -async fn presist_messages() { +async fn persist_messages() { let device_info = create_device().await; // Send request for keyserver to refresh keys (identity service) @@ -60,7 +59,7 @@ .await .unwrap(); - let refresh_request = messages::RefreshKeyRequest { + let refresh_request = RefreshKeyRequest { device_id: device_info.device_id.to_string(), number_of_keys: 5, }; diff --git a/services/identity/src/config.rs b/services/identity/src/config.rs --- a/services/identity/src/config.rs +++ b/services/identity/src/config.rs @@ -32,12 +32,12 @@ let localstack_endpoint = env::var(LOCALSTACK_ENDPOINT).ok(); let tunnelbroker_endpoint = match env::var(TUNNELBROKER_GRPC_ENDPOINT) { Ok(val) => { - info!("Using tunnelbroker endpoint from env var: {}", val); + info!("Using Tunnelbroker endpoint from env var: {}", val); val } Err(std::env::VarError::NotPresent) => { let val = DEFAULT_TUNNELBROKER_ENDPOINT; - info!("Falling back to default tunnelbroker endpoint: {}", val); + info!("Falling back to default Tunnelbroker endpoint: {}", val); val.to_string() } Err(e) => { diff --git a/shared/tunnelbroker_messages/src/messages/keys.rs b/shared/tunnelbroker_messages/src/messages/keys.rs --- a/shared/tunnelbroker_messages/src/messages/keys.rs +++ b/shared/tunnelbroker_messages/src/messages/keys.rs @@ -1,4 +1,4 @@ -// Messages sent between tunnelbroker and a device +// Messages sent between Tunnelbroker and a device use serde::{Deserialize, Serialize}; diff --git a/shared/tunnelbroker_messages/src/messages/mod.rs b/shared/tunnelbroker_messages/src/messages/mod.rs --- a/shared/tunnelbroker_messages/src/messages/mod.rs +++ b/shared/tunnelbroker_messages/src/messages/mod.rs @@ -1,4 +1,4 @@ -// Messages sent between tunnelbroker and a device +// Messages sent between Tunnelbroker and a device pub mod keys; pub mod session; diff --git a/shared/tunnelbroker_messages/src/messages/session.rs b/shared/tunnelbroker_messages/src/messages/session.rs --- a/shared/tunnelbroker_messages/src/messages/session.rs +++ b/shared/tunnelbroker_messages/src/messages/session.rs @@ -1,8 +1,8 @@ -// Messages sent between tunnelbroker and a device +// Messages sent between Tunnelbroker and a device use serde::{Deserialize, Serialize}; -/// The workflow when estabilishing a tunnelbroker connection: +/// The workflow when estabilishing a Tunnelbroker connection: /// - Client sends ConnectionInitializationMessage /// - Tunnelbroker validates access_token with identity service /// - Tunnelbroker emits an AMQP message declaring that it has opened a new @@ -26,7 +26,7 @@ Keyserver, } -/// Message sent by a client to tunnelbroker to initiate a websocket +/// Message sent by a client to Tunnelbroker to initiate a websocket /// session. Tunnelbroker will then validate the access token with identity /// service before continuing with the request. #[derive(Serialize, Deserialize)]