From 8bff30d419183b646d1c9938156d580efe3d686d Mon Sep 17 00:00:00 2001 From: Sergey Petushkov Date: Mon, 20 Jan 2025 10:40:29 +0100 Subject: [PATCH] chore(ci): use encoded cert in e2e tests --- .evergreen/connectivity-tests/run.sh | 2 +- .evergreen/functions.yml | 2 +- packages/compass-e2e-tests/tests/connection.test.ts | 8 ++++++-- packages/data-service/src/connect.spec.ts | 13 ++++++++++--- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.evergreen/connectivity-tests/run.sh b/.evergreen/connectivity-tests/run.sh index b6c8ab81066..61cc986d590 100644 --- a/.evergreen/connectivity-tests/run.sh +++ b/.evergreen/connectivity-tests/run.sh @@ -22,7 +22,7 @@ docker run \ -e E2E_TESTS_FREE_TIER_HOST="${E2E_TESTS_FREE_TIER_HOST}" \ -e E2E_TESTS_ATLAS_USERNAME="${E2E_TESTS_ATLAS_USERNAME}" \ -e E2E_TESTS_ATLAS_PASSWORD="${E2E_TESTS_ATLAS_PASSWORD}" \ - -e E2E_TESTS_ATLAS_X509_PEM="${E2E_TESTS_ATLAS_X509_PEM}" \ + -e E2E_TESTS_ATLAS_X509_PEM_BASE64="${E2E_TESTS_ATLAS_X509_PEM_BASE64}" \ -e MONGODB_VERSION="${MONGODB_VERSION}" \ --add-host mongodb-kerberos-1.example.com:0.0.0.0 \ --add-host mongodb-kerberos-2.example.com:0.0.0.0 \ diff --git a/.evergreen/functions.yml b/.evergreen/functions.yml index 0981ef74724..fed83e8c399 100644 --- a/.evergreen/functions.yml +++ b/.evergreen/functions.yml @@ -62,7 +62,7 @@ variables: E2E_TESTS_FREE_TIER_HOST: ${e2e_tests_free_tier_host} E2E_TESTS_ATLAS_USERNAME: ${e2e_tests_atlas_username} E2E_TESTS_ATLAS_PASSWORD: ${e2e_tests_atlas_password} - E2E_TESTS_ATLAS_X509_PEM: ${e2e_tests_atlas_x509_pem} + E2E_TESTS_ATLAS_X509_PEM_BASE64: ${e2e_tests_atlas_x509_pem_base64} E2E_TESTS_ATLAS_IAM_ACCESS_KEY_ID: ${e2e_tests_atlas_iam_aws_access_key_id} E2E_TESTS_ATLAS_IAM_SECRET_ACCESS_KEY: ${e2e_tests_atlas_iam_aws_secret_access_key} E2E_TESTS_ATLAS_IAM_TEMP_ROLE_ARN: ${e2e_tests_atlas_iam_temp_role_arn} diff --git a/packages/compass-e2e-tests/tests/connection.test.ts b/packages/compass-e2e-tests/tests/connection.test.ts index a679b038df1..cac595f00b7 100644 --- a/packages/compass-e2e-tests/tests/connection.test.ts +++ b/packages/compass-e2e-tests/tests/connection.test.ts @@ -39,7 +39,7 @@ function hasAtlasEnvironmentVariables(): boolean { 'E2E_TESTS_FREE_TIER_HOST', 'E2E_TESTS_ATLAS_USERNAME', 'E2E_TESTS_ATLAS_PASSWORD', - 'E2E_TESTS_ATLAS_X509_PEM', + 'E2E_TESTS_ATLAS_X509_PEM_BASE64', 'E2E_TESTS_ATLAS_IAM_ACCESS_KEY_ID', 'E2E_TESTS_ATLAS_IAM_SECRET_ACCESS_KEY', 'E2E_TESTS_ATLAS_IAM_TEMP_ROLE_ARN', @@ -724,7 +724,11 @@ describe('Connection form', function () { try { tempdir = await fs.mkdtemp(path.join(os.tmpdir(), 'connect-tests-')); const certPath = path.join(tempdir, 'x509.pem'); - await fs.writeFile(certPath, process.env.E2E_TESTS_ATLAS_X509_PEM ?? ''); + await fs.writeFile( + certPath, + process.env.E2E_TESTS_ATLAS_X509_PEM_BASE64 ?? '', + 'base64' + ); const atlasConnectionOptions: ConnectFormState = { hosts: [process.env.E2E_TESTS_ATLAS_HOST ?? ''], diff --git a/packages/data-service/src/connect.spec.ts b/packages/data-service/src/connect.spec.ts index 7c739823320..717cc6ece4c 100644 --- a/packages/data-service/src/connect.spec.ts +++ b/packages/data-service/src/connect.spec.ts @@ -30,7 +30,7 @@ const { E2E_TESTS_SERVERLESS_HOST, E2E_TESTS_FREE_TIER_HOST, E2E_TESTS_ANALYTICS_NODE_HOST, - E2E_TESTS_ATLAS_X509_PEM, + E2E_TESTS_ATLAS_X509_PEM_BASE64, } = process.env; const buildConnectionString = ( @@ -204,7 +204,10 @@ describe('connect', function () { }); it('connects to atlas with X509', async function () { - if (!IS_CI && !(E2E_TESTS_ATLAS_HOST || E2E_TESTS_ATLAS_X509_PEM)) { + if ( + !IS_CI && + !(E2E_TESTS_ATLAS_HOST || E2E_TESTS_ATLAS_X509_PEM_BASE64) + ) { return this.skip(); } @@ -212,7 +215,11 @@ describe('connect', function () { try { tempdir = await fs.mkdtemp(path.join(os.tmpdir(), 'connect-tests-')); const certPath = path.join(tempdir, 'x509.pem'); - await fs.writeFile(certPath, E2E_TESTS_ATLAS_X509_PEM); + await fs.writeFile( + certPath, + process.env.E2E_TESTS_ATLAS_X509_PEM_BASE64 ?? '', + 'base64' + ); const url = new ConnectionStringUrl( `mongodb+srv://${E2E_TESTS_ATLAS_HOST || ''}/admin`