Page MenuHomePhabricator

D9312.id31936.diff
No OneTemporary

D9312.id31936.diff

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
@@ -3,6 +3,9 @@
mod proto {
tonic::include_proto!("identity.client");
}
+use crate::identity::olm_account_infos::{
+ ClientPublicKeys, DEFAULT_CLIENT_KEYS,
+};
use proto as client;
use proto::{
identity_client_service_client::IdentityClientServiceClient, DeviceKeyUpload,
@@ -16,7 +19,7 @@
pub access_token: String,
}
-pub async fn create_device() -> DeviceInfo {
+pub async fn create_device(keys: Option<&ClientPublicKeys>) -> DeviceInfo {
let password = "pass";
let username: String = rand::thread_rng()
.sample_iter(&Alphanumeric)
@@ -25,9 +28,11 @@
.collect();
// TODO: Generate dynamic valid olm account info
- let example_payload = r#"{\"notificationIdentityPublicKeys\":{\"curve25519\":\"DYmV8VdkjwG/VtC8C53morogNJhpTPT/4jzW0/cxzQo\",\"ed25519\":\"D0BV2Y7Qm36VUtjwyQTJJWYAycN7aMSJmhEsRJpW2mk\"},\"primaryIdentityPublicKeys\":{\"curve25519\":\"Y4ZIqzpE1nv83kKGfvFP6rifya0itRg2hifqYtsISnk\",\"ed25519\":\"cSlL+VLLJDgtKSPlIwoCZg0h0EmHlQoJC08uV/O+jvg\"}}"#;
+ let keys = keys.unwrap_or_else(|| &DEFAULT_CLIENT_KEYS);
+ let example_payload =
+ serde_json::to_string(&keys).expect("Failed to serialize example payload");
// The ed25519 value from the olm payload
- let device_id = r#"cSlL+VLLJDgtKSPlIwoCZg0h0EmHlQoJC08uV/O+jvg"#;
+ let device_id = &keys.primary_identity_public_keys.ed25519;
let mut client_registration = Registration::new();
let opaque_registration_request =
diff --git a/services/commtest/src/identity/mod.rs b/services/commtest/src/identity/mod.rs
--- a/services/commtest/src/identity/mod.rs
+++ b/services/commtest/src/identity/mod.rs
@@ -1 +1,2 @@
pub mod device;
+pub mod olm_account_infos;
diff --git a/services/commtest/src/identity/olm_account_infos.rs b/services/commtest/src/identity/olm_account_infos.rs
new file mode 100644
--- /dev/null
+++ b/services/commtest/src/identity/olm_account_infos.rs
@@ -0,0 +1,48 @@
+use lazy_static::lazy_static;
+use serde::{Deserialize, Serialize};
+
+#[derive(Serialize, Deserialize, Debug, Clone)]
+pub struct IdentityPublicKeys {
+ pub ed25519: String,
+ pub curve25519: String,
+}
+
+#[derive(Serialize, Deserialize, Debug, Clone)]
+#[serde(rename_all = "camelCase")]
+pub struct ClientPublicKeys {
+ pub primary_identity_public_keys: IdentityPublicKeys,
+ pub notification_identity_public_keys: IdentityPublicKeys,
+}
+
+lazy_static! {
+ pub static ref DEFAULT_CLIENT_KEYS: ClientPublicKeys = ClientPublicKeys {
+ primary_identity_public_keys: IdentityPublicKeys {
+ ed25519: "cSlL+VLLJDgtKSPlIwoCZg0h0EmHlQoJC08uV/O+jvg".to_string(),
+ curve25519: "Y4ZIqzpE1nv83kKGfvFP6rifya0itRg2hifqYtsISnk".to_string(),
+ },
+ notification_identity_public_keys: IdentityPublicKeys {
+ ed25519: "D0BV2Y7Qm36VUtjwyQTJJWYAycN7aMSJmhEsRJpW2mk".to_string(),
+ curve25519: "DYmV8VdkjwG/VtC8C53morogNJhpTPT/4jzW0/cxzQo".to_string(),
+ }
+ };
+ pub static ref MOCK_CLIENT_KEYS_1: ClientPublicKeys = ClientPublicKeys {
+ primary_identity_public_keys: IdentityPublicKeys {
+ ed25519: "lbp5cS9fH5NnWIJbZ57wGBzDBGvmjoq6gMBHsIyXfJ4".to_string(),
+ curve25519: "x74rEeVzfTcjm+B2yLN/wgfvHEzEtphQ/JeQfIrzPzQ".to_string(),
+ },
+ notification_identity_public_keys: IdentityPublicKeys {
+ ed25519: "+mi3TltiSK2883cm0TK2mkSKPcQb+WVfshltTSVgA2Y".to_string(),
+ curve25519: "GI8V9FwOYIqxB2TzQN31nXKR8y3/B3k+ZOCgxkTlUlI".to_string(),
+ },
+ };
+ pub static ref MOCK_CLIENT_KEYS_2: ClientPublicKeys = ClientPublicKeys {
+ primary_identity_public_keys: IdentityPublicKeys {
+ ed25519: "ZXx1ADCFxFm6P+UmVhX0A1tuqUoBU7lYjig/gMzSEJI".to_string(),
+ curve25519: "zHfP5eeD3slrgidtNRknHw3NKtJ7hA+vinaT3ACIhRA".to_string(),
+ },
+ notification_identity_public_keys: IdentityPublicKeys {
+ ed25519: "TqzVFQLnJvt9JfMVU54d6InEd/wQV3DCplBuj5axTlU".to_string(),
+ curve25519: "nRVVaf+Iz2MfEFtQtzrvV/EmTivqKpOeHlCt9OWYUxM".to_string(),
+ },
+ };
+}
diff --git a/services/commtest/tests/grpc_client_test.rs b/services/commtest/tests/grpc_client_test.rs
--- a/services/commtest/tests/grpc_client_test.rs
+++ b/services/commtest/tests/grpc_client_test.rs
@@ -3,7 +3,7 @@
#[tokio::test]
async fn verify_access_token() {
use grpc_clients::identity::unauthenticated::client::verify_user_access_token;
- let device_info = create_device().await;
+ let device_info = create_device(None).await;
let token_valid = verify_user_access_token(
"http://127.0.0.1:50054",
diff --git a/services/commtest/tests/identity_access_tokens_tests.rs b/services/commtest/tests/identity_access_tokens_tests.rs
--- a/services/commtest/tests/identity_access_tokens_tests.rs
+++ b/services/commtest/tests/identity_access_tokens_tests.rs
@@ -11,7 +11,7 @@
#[tokio::test]
async fn verify_access_token() {
- let device_info = create_device().await;
+ let device_info = create_device(None).await;
let mut identity_client =
IdentityClientServiceClient::connect("http://127.0.0.1:50054")
@@ -34,7 +34,7 @@
#[tokio::test]
async fn upload_one_time_keys() {
- let device_info = create_device().await;
+ let device_info = create_device(None).await;
let mut identity_client =
IdentityClientServiceClient::connect("http://127.0.0.1:50054")
diff --git a/services/commtest/tests/identity_keyserver_tests.rs b/services/commtest/tests/identity_keyserver_tests.rs
--- a/services/commtest/tests/identity_keyserver_tests.rs
+++ b/services/commtest/tests/identity_keyserver_tests.rs
@@ -13,7 +13,7 @@
#[tokio::test]
async fn set_prekey() {
- let device_info = create_device().await;
+ let device_info = create_device(None).await;
let channel = Endpoint::from_static("http://[::1]:50054")
.connect()
diff --git a/services/commtest/tests/identity_one_time_key_tests.rs b/services/commtest/tests/identity_one_time_key_tests.rs
--- a/services/commtest/tests/identity_one_time_key_tests.rs
+++ b/services/commtest/tests/identity_one_time_key_tests.rs
@@ -10,7 +10,7 @@
#[tokio::test]
async fn verify_access_token() {
- let device_info = create_device().await;
+ let device_info = create_device(None).await;
let mut identity_client =
IdentityClientServiceClient::connect("http://127.0.0.1:50054")
diff --git a/services/commtest/tests/identity_prekey_tests.rs b/services/commtest/tests/identity_prekey_tests.rs
--- a/services/commtest/tests/identity_prekey_tests.rs
+++ b/services/commtest/tests/identity_prekey_tests.rs
@@ -13,7 +13,7 @@
#[tokio::test]
async fn set_prekey() {
- let device_info = create_device().await;
+ let device_info = create_device(None).await;
let channel = Endpoint::from_static("http://[::1]:50054")
.connect()
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
@@ -17,7 +17,7 @@
#[tokio::test]
#[should_panic]
async fn test_tunnelbroker_invalid_auth() {
- let mut device_info = create_device().await;
+ let mut device_info = create_device(None).await;
device_info.access_token = "".to_string();
let mut socket = create_socket(&device_info).await;
@@ -30,7 +30,7 @@
#[tokio::test]
async fn test_tunnelbroker_valid_auth() {
- let device_info = create_device().await;
+ let device_info = create_device(None).await;
let mut socket = create_socket(&device_info).await;
socket
@@ -42,7 +42,7 @@
#[tokio::test]
async fn test_refresh_keys_request_upon_depletion() {
- let device_info = create_device().await;
+ let device_info = create_device(None).await;
let mut identity_client =
IdentityClientServiceClient::connect("http://127.0.0.1:50054")
@@ -95,7 +95,7 @@
// from Tunnelbroker to refresh keys
// Create session as a keyserver
- let device_info = create_device().await;
+ let device_info = create_device(None).await;
let mut socket = create_socket(&device_info).await;
// Have keyserver receive any websocket messages
diff --git a/services/commtest/tests/tunnelbroker_integration_tests.rs b/services/commtest/tests/tunnelbroker_integration_tests.rs
--- a/services/commtest/tests/tunnelbroker_integration_tests.rs
+++ b/services/commtest/tests/tunnelbroker_integration_tests.rs
@@ -11,7 +11,7 @@
#[tokio::test]
async fn send_refresh_request() {
// Create session as a keyserver
- let device_info = create_device().await;
+ let device_info = create_device(None).await;
let mut socket = create_socket(&device_info).await;
// Send request for keyserver to refresh keys (identity service)
@@ -51,7 +51,7 @@
/// then recalled once a device connects
#[tokio::test]
async fn persist_messages() {
- let device_info = create_device().await;
+ let device_info = create_device(None).await;
// Send request for keyserver to refresh keys (identity service)
let mut tunnelbroker_client =

File Metadata

Mime Type
text/plain
Expires
Wed, Jan 8, 4:43 PM (4 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2820411
Default Alt Text
D9312.id31936.diff (8 KB)

Event Timeline