Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3491082
D5931.id20192.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D5931.id20192.diff
View Options
diff --git a/services/commtest/tests/tunnelbroker_integration_test.rs b/services/commtest/tests/tunnelbroker_integration_test.rs
--- a/services/commtest/tests/tunnelbroker_integration_test.rs
+++ b/services/commtest/tests/tunnelbroker_integration_test.rs
@@ -1,4 +1,68 @@
+use commtest::tunnelbroker::{
+ new_session::create_new_session,
+ new_session::get_string_to_sign,
+ new_session::sign_string_with_private_key,
+ tunnelbroker_utils::{
+ proto::new_session_request::DeviceTypes,
+ session_signature_device_id_format_validation, tonic_client_builder,
+ },
+};
+use openssl::pkey::PKey;
+use openssl::rsa::Rsa;
+
#[tokio::test]
-async fn tunnelbroker_integration_test() {
- assert!(false, "not implemented");
+async fn tunnelbroker_integration_test() -> Result<(), anyhow::Error> {
+ const DEVICE_ID: &str =
+ "mobile:OOOTESTb2ueEmQ4QsevRWlXxFCNt055y20T1PHdoYAQRt0S6TLzZWNM6XSvdW000";
+
+ // Should fail on the wrong device ID format provided
+ let mut client = tonic_client_builder().await?;
+ assert!(
+ session_signature_device_id_format_validation(&mut client)
+ .await
+ .is_ok(),
+ "DeviceID format validation failed on getting session signature request"
+ );
+
+ // Generate a keypair
+ let keypair = Rsa::generate(1024)?;
+ let keypair = PKey::from_rsa(keypair)?;
+ let public_key_pem = String::from_utf8(keypair.public_key_to_pem()?)?;
+
+ // Get and sign the string to be signed
+ let string_to_be_signed = get_string_to_sign(&mut client, DEVICE_ID).await?;
+ let signature_base64 =
+ sign_string_with_private_key(&keypair, &string_to_be_signed)?;
+
+ // Should fail on the wrong signature provided
+ assert!(
+ create_new_session(
+ &mut client,
+ DEVICE_ID,
+ &public_key_pem,
+ "wrong_signature",
+ "fake_notify_token",
+ DeviceTypes::Mobile,
+ "v.x.x.x",
+ "iOS x.x.x",
+ )
+ .await
+ .is_err(),
+ "New session returns success when using wrong signature"
+ );
+
+ // Create a new session with the correct signature
+ let _session_id = create_new_session(
+ &mut client,
+ DEVICE_ID,
+ &public_key_pem,
+ &signature_base64,
+ "fake_notify_token",
+ DeviceTypes::Mobile,
+ "v.x.x.x",
+ "iOS x.x.x",
+ )
+ .await?;
+
+ Ok(())
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 6:17 PM (14 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2676850
Default Alt Text
D5931.id20192.diff (2 KB)
Attached To
Mode
D5931: [services/commtest] Tunnelbroker - Adding the API integration tests call function
Attached
Detach File
Event Timeline
Log In to Comment