From a01921e6bc19fc87a82645c09859187011e3be2f Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Mon, 15 Aug 2022 12:26:19 +0200 Subject: [PATCH] chore: Fix e2ee tests by login with username instead of mxid Hacky workaround because the UIA Proxy does not work reliably with login via mxid. --- .gitlab-ci.yml | 11 ++++------- test_driver/matrixsdk_test.dart | 11 ++++++++--- test_driver/test_config.dart | 2 ++ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 37b57923..3a8803bd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,7 @@ workflow: - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH variables: - FLUTTER_IMAGE_TAG: '3.0.5' + FLUTTER_IMAGE_TAG: "3.0.5" coverage: tags: @@ -70,7 +70,7 @@ e2ee_test: image: registry.gitlab.com/famedly/company/frontend/flutter-dockerimages/flutter-linux/stable:${FLUTTER_IMAGE_TAG} dependencies: [] script: - - printf "abstract class TestUser {\n static const String homeserver = '$TEST_HOMESERVER';\n static const String username = '$TEST_USER1';\n static const String username2 = '$TEST_USER2';\n static const String password = '$TEST_USER_PASSWORD';\n}" > ./test_driver/test_config.dart + - printf "abstract class TestUser {\n static const String homeserver = '$TEST_HOMESERVER';\n static const String username = '$TEST_USER1';\n static const String username2 = '$TEST_USER2';\n static const String displayname = '$TEST_USER1_NAME';\n static const String displayname2 = '$TEST_USER2_NAME';\n static const String password = '$TEST_USER_PASSWORD';\n}" > ./test_driver/test_config.dart - ./scripts/prepare.sh - ./scripts/test_driver.sh timeout: 16m @@ -84,13 +84,10 @@ dry-run: - dart pub get - dart pub publish --dry-run - pub-dev: stage: deploy image: dart - dependencies: [ - dry-run - ] + dependencies: [dry-run] script: - rm -rf ./docs - | @@ -101,7 +98,7 @@ pub-dev: mkdir -p ~/.config/dart/ cp "${PUB_DEV_CREDENTIALS}" ~/.config/dart/pub-credentials.json - + - dart pub get - dart pub publish --force rules: diff --git a/test_driver/matrixsdk_test.dart b/test_driver/matrixsdk_test.dart index e0354c7c..d5c14816 100644 --- a/test_driver/matrixsdk_test.dart +++ b/test_driver/matrixsdk_test.dart @@ -44,16 +44,20 @@ void test() async { Logs().i('++++ Login Alice at ++++'); testClientA = Client('TestClientA', databaseBuilder: getDatabase); await testClientA.checkHomeserver(Uri.parse(TestUser.homeserver)); + // Workaround: Logging in with displayname instead of mxid because of a bug + // in the UIA proxy: https://gitlab.com/famedly/company/backend/services/uia-proxy/-/issues/27 + // When this gets fixed, we no longer need the displayname login at all. await testClientA.login(LoginType.mLoginPassword, - identifier: AuthenticationUserIdentifier(user: TestUser.username), + identifier: AuthenticationUserIdentifier(user: TestUser.displayname), password: TestUser.password); assert(testClientA.encryptionEnabled); Logs().i('++++ Login Bob ++++'); testClientB = Client('TestClientB', databaseBuilder: getDatabase); await testClientB.checkHomeserver(Uri.parse(TestUser.homeserver)); + // Workaround: Logging in with displayname instead of mxid await testClientB.login(LoginType.mLoginPassword, - identifier: AuthenticationUserIdentifier(user: TestUser.username2), + identifier: AuthenticationUserIdentifier(user: TestUser.displayname2), password: TestUser.password); assert(testClientB.encryptionEnabled); @@ -247,8 +251,9 @@ void test() async { Logs().i('++++ Login Bob in another client ++++'); final testClientC = Client('TestClientC', databaseBuilder: getDatabase); await testClientC.checkHomeserver(Uri.parse(TestUser.homeserver)); + // Workaround: Logging in with displayname instead of mxid await testClientC.login(LoginType.mLoginPassword, - identifier: AuthenticationUserIdentifier(user: TestUser.username2), + identifier: AuthenticationUserIdentifier(user: TestUser.displayname2), password: TestUser.password); await Future.delayed(Duration(seconds: 3)); diff --git a/test_driver/test_config.dart b/test_driver/test_config.dart index 8014255f..26cf73b8 100644 --- a/test_driver/test_config.dart +++ b/test_driver/test_config.dart @@ -2,5 +2,7 @@ class TestUser { static const String homeserver = 'https://enter-your-server.here'; static const String username = 'alice'; static const String username2 = 'bob'; + static const String displayname = 'Alice'; + static const String displayname2 = 'Bob'; static const String password = '1234'; }