diff --git a/native/native_rust_library/src/constants.rs b/native/native_rust_library/src/constants.rs --- a/native/native_rust_library/src/constants.rs +++ b/native/native_rust_library/src/constants.rs @@ -4,3 +4,34 @@ pub const IV_LENGTH: usize = 12; // bytes - unique Initialization Vector (nonce) pub const TAG_LENGTH: usize = 16; // bytes - GCM auth tag } + +#[cfg(debug_assertions)] +pub const DEFAULT_SOCKET_ADDR: &str = + "https://identity.staging.commtechnologies.org:50054"; + +#[cfg(not(debug_assertions))] +pub const DEFAULT_SOCKET_ADDR: &str = + "https://identity.commtechnologies.org:50054"; + +#[cfg(test)] +mod tests { + use super::*; + + #[cfg(debug_assertions)] + #[test] + fn test_default_socket_addr_debug() { + assert_eq!( + DEFAULT_SOCKET_ADDR, + "https://identity.staging.commtechnologies.org:50054" + ); + } + + #[cfg(not(debug_assertions))] + #[test] + fn test_default_socket_addr_release() { + assert_eq!( + DEFAULT_SOCKET_ADDR, + "https://identity.commtechnologies.org:50054" + ); + } +} diff --git a/native/native_rust_library/src/lib.rs b/native/native_rust_library/src/lib.rs --- a/native/native_rust_library/src/lib.rs +++ b/native/native_rust_library/src/lib.rs @@ -1,6 +1,7 @@ use crate::ffi::{bool_callback, string_callback, void_callback}; use comm_opaque2::client::{Login, Registration}; use comm_opaque2::grpc::opaque_error_to_grpc_status as handle_error; +use constants::DEFAULT_SOCKET_ADDR; use grpc_clients::identity::protos::authenticated::{ UpdateUserPasswordFinishRequest, UpdateUserPasswordStartRequest, }; @@ -243,7 +244,7 @@ async fn fetch_nonce() -> Result { let mut identity_client = get_unauthenticated_client( - "http://127.0.0.1:50054", + DEFAULT_SOCKET_ADDR, CODE_VERSION, DEVICE_TYPE.as_str_name().to_lowercase(), ) @@ -265,7 +266,7 @@ async fn version_supported_helper() -> Result { let mut identity_client = get_unauthenticated_client( - "http://127.0.0.1:50054", + DEFAULT_SOCKET_ADDR, CODE_VERSION, DEVICE_TYPE.as_str_name().to_lowercase(), ) @@ -373,7 +374,7 @@ }; let mut identity_client = get_unauthenticated_client( - "http://127.0.0.1:50054", + DEFAULT_SOCKET_ADDR, CODE_VERSION, DEVICE_TYPE.as_str_name().to_lowercase(), ) @@ -487,7 +488,7 @@ }; let mut identity_client = get_unauthenticated_client( - "http://127.0.0.1:50054", + DEFAULT_SOCKET_ADDR, CODE_VERSION, DEVICE_TYPE.as_str_name().to_lowercase(), ) @@ -611,7 +612,7 @@ }; let mut identity_client = get_unauthenticated_client( - "http://127.0.0.1:50054", + DEFAULT_SOCKET_ADDR, CODE_VERSION, DEVICE_TYPE.as_str_name().to_lowercase(), ) @@ -666,7 +667,7 @@ opaque_registration_request, }; let mut identity_client = get_auth_client( - "http://127.0.0.1:50054", + DEFAULT_SOCKET_ADDR, update_password_info.user_id, update_password_info.device_id, update_password_info.access_token, @@ -736,7 +737,7 @@ async fn delete_user_helper(auth_info: AuthInfo) -> Result<(), Error> { let mut identity_client = get_auth_client( - "http://127.0.0.1:50054", + DEFAULT_SOCKET_ADDR, auth_info.user_id, auth_info.device_id, auth_info.access_token, @@ -855,7 +856,7 @@ }; let mut identity_client = get_unauthenticated_client( - "http://127.0.0.1:50054", + DEFAULT_SOCKET_ADDR, CODE_VERSION, DEVICE_TYPE.as_str_name().to_lowercase(), )