From 649c208f35b227ff6337af9209fc0e9b202daace Mon Sep 17 00:00:00 2001 From: Sergey Petushkov Date: Fri, 1 Nov 2024 12:36:13 +0100 Subject: [PATCH 1/4] fix(e2e): account for a recurring MFA reminder when singing in to cloud ui (#6429) --- .../helpers/compass-web-sandbox.ts | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/packages/compass-e2e-tests/helpers/compass-web-sandbox.ts b/packages/compass-e2e-tests/helpers/compass-web-sandbox.ts index 2f4345dc941..0a67b13d5e3 100644 --- a/packages/compass-e2e-tests/helpers/compass-web-sandbox.ts +++ b/packages/compass-e2e-tests/helpers/compass-web-sandbox.ts @@ -132,7 +132,44 @@ export async function spawnCompassWebSandboxAndSignInToAtlas( debug('Waiting for the auth to finish ...'); - const res = await authenticatePromise; + let authenticatedPromiseSettled = false; + + // Atlas Cloud will periodically remind user to enable MFA (which we can't + // enable in e2e CI environment), so to account for that, in parallel to + // waiting for auth to finish, we'll wait for the MFA screen to show up and + // skip it if it appears + const [, settledRes] = await Promise.allSettled([ + (async () => { + const remindMeLaterButton = 'button*=Remind me later'; + + await electronProxyRemote.waitUntil( + async () => { + return ( + authenticatedPromiseSettled || + (await electronProxyRemote.$(remindMeLaterButton).isDisplayed()) + ); + }, + // Takes awhile for the redirect to land on this reminder page when it + // happens, so no need to bombard the browser with displayed checks + { interval: 2000 } + ); + + if (authenticatedPromiseSettled) { + return; + } + + await electronProxyRemote.$(remindMeLaterButton).click(); + })(), + authenticatePromise.finally(() => { + authenticatedPromiseSettled = true; + }), + ]); + + if (settledRes.status === 'rejected') { + throw settledRes.reason; + } + + const res = settledRes.value; if (res.ok === false || !(await res.json()).projectId) { throw new Error( From 697e4ceed676545f9273660c874d5007a2c33ec5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 11:42:46 +0000 Subject: [PATCH 2/4] chore: update AUTHORS, THIRD-PARTY-NOTICES, Security Test Summary (#6431) Update report Co-authored-by: gribnoysup <5036933+gribnoysup@users.noreply.github.com> --- THIRD-PARTY-NOTICES.md | 2 +- docs/tracking-plan.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.md index a6150a72bc0..37e074f7bd2 100644 --- a/THIRD-PARTY-NOTICES.md +++ b/THIRD-PARTY-NOTICES.md @@ -1,5 +1,5 @@ The following third-party software is used by and included in **Mongodb Compass**. -This document was automatically generated on Wed Oct 30 2024. +This document was automatically generated on Fri Nov 01 2024. ## List of dependencies diff --git a/docs/tracking-plan.md b/docs/tracking-plan.md index a81d2ed0bb3..94cf3630022 100644 --- a/docs/tracking-plan.md +++ b/docs/tracking-plan.md @@ -1,7 +1,7 @@ # Compass Tracking Plan -Generated on Wed, Oct 30, 2024 at 02:38 PM +Generated on Fri, Nov 1, 2024 at 11:42 AM ## Table of Contents From 1eef24e8c2d9ef9ffd90139bed7f75dabd501b40 Mon Sep 17 00:00:00 2001 From: Sergey Petushkov Date: Fri, 1 Nov 2024 14:50:29 +0100 Subject: [PATCH 3/4] chore(e2e): automatically create db user and add ip address to the access list before running tests (#6432) --- .evergreen/functions.yml | 2 -- .evergreen/start-atlas-cloud-cluster.sh | 29 ++++++++++++++++++++----- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/.evergreen/functions.yml b/.evergreen/functions.yml index 3fc873e4cb9..bb69785b943 100644 --- a/.evergreen/functions.yml +++ b/.evergreen/functions.yml @@ -685,8 +685,6 @@ functions: DEBUG: ${debug|} COMPASS_E2E_ATLAS_CLOUD_SANDBOX_USERNAME: ${e2e_tests_compass_web_atlas_username} COMPASS_E2E_ATLAS_CLOUD_SANDBOX_PASSWORD: ${e2e_tests_compass_web_atlas_password} - COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_USERNAME: ${e2e_tests_compass_web_atlas_db_username} - COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_PASSWORD: ${e2e_tests_compass_web_atlas_password} MCLI_PUBLIC_API_KEY: ${e2e_tests_mcli_public_api_key} MCLI_PRIVATE_API_KEY: ${e2e_tests_mcli_private_api_key} MCLI_ORG_ID: ${e2e_tests_mcli_org_id} diff --git a/.evergreen/start-atlas-cloud-cluster.sh b/.evergreen/start-atlas-cloud-cluster.sh index 0b1b48bd540..541fd7a4df1 100644 --- a/.evergreen/start-atlas-cloud-cluster.sh +++ b/.evergreen/start-atlas-cloud-cluster.sh @@ -1,5 +1,8 @@ #!/bin/bash +RUN_ID="$(date +"%s")-$(git rev-parse --short HEAD)" +DELETE_AFTER="$(date -u -Iseconds -d '+2 hours' 2>/dev/null || date -u -Iseconds -v '+2H')" + # This script helps to automatically provision Atlas cluster for running the e2e # tests against. In CI this will always create a new cluster and delete it when # the test run is finished. You can also use this script locally to run e2e @@ -16,9 +19,6 @@ # # - Setup a new org and project. Save the org id and project id for later. # -# - Create new db user with username / password auth and admin role. This user -# will be used to prepopulate dbs with data in tests. Save the credentials. -# # - Create a new API key (Access Manager > Project Access > Create Application > # API Key) for the project you created and save the public and private keys. # @@ -38,8 +38,6 @@ # # COMPASS_E2E_ATLAS_CLOUD_SANDBOX_USERNAME Cloud user you created # COMPASS_E2E_ATLAS_CLOUD_SANDBOX_PASSWORD Cloud user password -# COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_USERNAME Db user for the project -# COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_PASSWORD Db user password # # - Source the script followed by running the tests to make sure that some # variables exported from this script are available for the test env: @@ -53,10 +51,13 @@ _ATLAS_CLOUD_TEST_CLUSTER_NAME=${ATLAS_CLOUD_TEST_CLUSTER_NAME:-""} # truncate if it's too long) so we're very limited in terms of how unique this # name can be. Hopefully the epoch + part of git hash is enough for these to not # overlap when tests are running -DEFAULT_ATLAS_CLOUD_TEST_CLUSTER_NAME="e2e-$(date +"%s")-$(git rev-parse HEAD)" +DEFAULT_ATLAS_CLOUD_TEST_CLUSTER_NAME="e2e-$RUN_ID" ATLAS_CLUSTER_NAME="${_ATLAS_CLOUD_TEST_CLUSTER_NAME:-$DEFAULT_ATLAS_CLOUD_TEST_CLUSTER_NAME}" +ATLAS_TEST_DB_USERNAME="testuser-$RUN_ID" +ATLAS_TEST_DB_PASSWORD="$(head -c 32 /dev/urandom | base64 | tr -dc 'a-zA-Z0-9')" + function atlascli() { docker run \ -e MCLI_PUBLIC_API_KEY \ @@ -79,10 +80,26 @@ cleanup() { else echo "Custom cluster name provided ($_ATLAS_CLOUD_TEST_CLUSTER_NAME), skipping cluster cleanup" fi + echo "Deleting Atlas db user \`$ATLAS_TEST_DB_USERNAME\`..." + atlascli dbusers delete $ATLAS_TEST_DB_USERNAME --force } trap cleanup EXIT +echo "Allowing access from current ip..." +atlascli accessList create \ + --currentIp \ + --deleteAfter "$DELETE_AFTER" + +echo "Creating Atlas db user \`$ATLAS_TEST_DB_USERNAME\`..." +atlascli dbusers create atlasAdmin \ + --username "$ATLAS_TEST_DB_USERNAME" \ + --password "$ATLAS_TEST_DB_PASSWORD" \ + --deleteAfter "$DELETE_AFTER" # so that it's autoremoved if cleaning up failed for some reason + +export COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_USERNAME="$ATLAS_TEST_DB_USERNAME" +export COMPASS_E2E_ATLAS_CLOUD_SANDBOX_DBUSER_PASSWORD="$ATLAS_TEST_DB_PASSWORD" + echo "Creating Atlas deployment \`$ATLAS_CLUSTER_NAME\` to test against..." atlascli clusters create $ATLAS_CLUSTER_NAME \ --provider AWS \ From d01d076528a5b73e8baff59bf054e938cbacd5b8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 1 Nov 2024 13:57:02 +0000 Subject: [PATCH 4/4] chore: update AUTHORS, THIRD-PARTY-NOTICES, Security Test Summary (#6433) Update report Co-authored-by: gribnoysup <5036933+gribnoysup@users.noreply.github.com> --- docs/tracking-plan.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tracking-plan.md b/docs/tracking-plan.md index 94cf3630022..f3ba95b1a7f 100644 --- a/docs/tracking-plan.md +++ b/docs/tracking-plan.md @@ -1,7 +1,7 @@ # Compass Tracking Plan -Generated on Fri, Nov 1, 2024 at 11:42 AM +Generated on Fri, Nov 1, 2024 at 01:56 PM ## Table of Contents