diff --git a/services/commtest/run-tests-ci.sh b/services/commtest/run-tests-ci.sh index be17ab05e..d7f5e1c4e 100755 --- a/services/commtest/run-tests-ci.sh +++ b/services/commtest/run-tests-ci.sh @@ -1,66 +1,67 @@ #!/bin/env bash set -euo pipefail NUM_FAILURES=0 awscli() { aws --endpoint-url="$LOCALSTACK_ENDPOINT" "$@" } # Set up Localstack using Terraform reset_localstack() { echo "Resetting Localstack..." pushd ../terraform/dev >/dev/null terraform init # Force delete secrets due to bug in Localstack where Terraform can't delete them echo "Deleting secrets..." secret_arns=$(awscli secretsmanager list-secrets --query "SecretList[].ARN" --output text) for arn in $secret_arns; do awscli secretsmanager delete-secret --secret-id "$arn" --force-delete-without-recovery done # Reset terraform state echo "Resetting terraform state..." terraform apply -destroy -auto-approve terraform apply -auto-approve popd >/dev/null } run_test() { local exit_code echo "COMMTEST: Running test: $1" set +e RUSTFLAGS=-Awarnings cargo test --test "$1" -- --show-output "${@:2}" exit_code=$? set -e if [ $exit_code -ne 0 ]; then ((NUM_FAILURES += 1)) fi } # Reset localstack and then run tests reset_localstack run_test "blob_*" 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 run_test identity_prekey_tests run_test identity_tunnelbroker_tests if [ $NUM_FAILURES -eq 0 ]; then echo "COMMTEST: ALL TESTS PASSED" exit 0 else echo "COMMTEST: $NUM_FAILURES TEST SUITES FAILED" exit 1 fi diff --git a/services/commtest/tests/identity_integration_tests.rs b/services/commtest/tests/identity_integration_tests.rs new file mode 100644 index 000000000..c43db4410 --- /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" + ); +}