Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3364676
D9200.id31127.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
D9200.id31127.diff
View Options
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
@@ -8,8 +8,8 @@
use client::identity_client_service_client::IdentityClientServiceClient;
use client::UploadOneTimeKeysRequest;
use commtest::identity::device::create_device;
-use futures_util::SinkExt;
use futures_util::StreamExt;
+use futures_util::{SinkExt, TryStreamExt};
use tokio_tungstenite::{connect_async, tungstenite::Message};
use tonic::transport::Endpoint;
use tonic::Request;
@@ -17,6 +17,70 @@
ConnectionInitializationMessage, DeviceTypes, RefreshKeyRequest,
};
+#[tokio::test]
+#[should_panic]
+async fn test_tunnelbroker_invalid_auth() {
+ let (mut socket, _) = connect_async("ws://localhost:51001")
+ .await
+ .expect("Can't connect");
+
+ let session_request = ConnectionInitializationMessage {
+ device_id: "".to_string(),
+ access_token: "".to_string(),
+ user_id: "".to_string(),
+ notify_token: None,
+ device_type: DeviceTypes::Keyserver,
+ device_app_version: None,
+ device_os: None,
+ };
+
+ let serialized_request = serde_json::to_string(&session_request)
+ .expect("Failed to serialize connection request");
+
+ socket
+ .send(Message::Text(serialized_request))
+ .await
+ .expect("Failed to send message");
+
+ socket
+ .next()
+ .await
+ .expect("Failed to receive response")
+ .expect("Failed to read the response");
+}
+
+#[tokio::test]
+async fn test_tunnelbroker_valid_auth() {
+ let (mut socket, _) = connect_async("ws://localhost:51001")
+ .await
+ .expect("Can't connect");
+
+ let device_info = create_device().await;
+ let session_request = ConnectionInitializationMessage {
+ device_id: device_info.device_id.to_string(),
+ access_token: device_info.access_token.to_string(),
+ user_id: device_info.user_id.to_string(),
+ notify_token: None,
+ device_type: DeviceTypes::Keyserver,
+ device_app_version: None,
+ device_os: None,
+ };
+
+ let serialized_request = serde_json::to_string(&session_request)
+ .expect("Failed to serialize connection request");
+
+ socket
+ .send(Message::Text(serialized_request))
+ .await
+ .expect("Failed to send message");
+
+ socket
+ .next()
+ .await
+ .expect("Failed to receive response")
+ .expect("Failed to read the response");
+}
+
#[tokio::test]
async fn test_refresh_keys_request_upon_depletion() {
let device_info = create_device().await;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 4:35 AM (14 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2582960
Default Alt Text
D9200.id31127.diff (2 KB)
Attached To
Mode
D9200: [Tunnelbroker] add authentication tests
Attached
Detach File
Event Timeline
Log In to Comment