From 1bf572883bd203984417019782bc9bb45909af77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Klocek?= Date: Sun, 12 Nov 2023 15:31:31 +0100 Subject: [PATCH] [commtest][identity] Add test for FindUserID RPC Summary: Added integration test for FindUserID RPC added in D9834. Depends on D9834 Test Plan: The test passes locally and on CI Reviewers: kamil, michal, varun, wyilio Reviewed By: varun Subscribers: ashoat, tomek, wyilio Differential Revision: https://phab.comm.dev/D9835 --- services/commtest/run-tests-ci.sh | 1 + .../tests/identity_integration_tests.rs | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 services/commtest/tests/identity_integration_tests.rs diff --git a/services/commtest/run-tests-ci.sh b/services/commtest/run-tests-ci.sh index be17ab05e5..d7f5e1c4e1 100755 --- a/services/commtest/run-tests-ci.sh +++ b/services/commtest/run-tests-ci.sh @@ -51,6 +51,7 @@ run_test "backup*" run_test "tunnelbroker_*" --test-threads=1 run_test grpc_client_test # below tests are flaky and need to be run in order +run_test identity_integration_tests run_test identity_keyserver_tests run_test identity_access_tokens_tests run_test identity_one_time_key_tests diff --git a/services/commtest/tests/identity_integration_tests.rs b/services/commtest/tests/identity_integration_tests.rs new file mode 100644 index 0000000000..c43db44103 --- /dev/null +++ b/services/commtest/tests/identity_integration_tests.rs @@ -0,0 +1,40 @@ +use commtest::identity::device::{ + create_device, DEVICE_TYPE, PLACEHOLDER_CODE_VERSION, +}; +use commtest::service_addr; +use grpc_clients::identity::protos::authenticated::find_user_id_request::Identifier; +use grpc_clients::identity::{ + get_auth_client, protos::authenticated::FindUserIdRequest, +}; + +#[tokio::test] +async fn find_user_id_by_username() { + let device_info = create_device(None).await; + + let mut client = get_auth_client( + &service_addr::IDENTITY_GRPC.to_string(), + device_info.user_id.clone(), + device_info.device_id, + device_info.access_token, + PLACEHOLDER_CODE_VERSION, + DEVICE_TYPE.to_string(), + ) + .await + .expect("Couldn't connect to identity service"); + + let request = FindUserIdRequest { + identifier: Some(Identifier::Username(device_info.username)), + }; + + let response = client + .find_user_id(request) + .await + .expect("Request failed") + .into_inner(); + + assert_eq!( + response.user_id, + Some(device_info.user_id), + "User ID should match" + ); +}