From 3c89ebbad5e58d114a2f94d45869490393cc1f4b Mon Sep 17 00:00:00 2001 From: bailey Date: Wed, 5 Mar 2025 09:57:08 -0700 Subject: [PATCH] fix skipping of KMS tests --- ..._encryption.prose.17.on_demand_gcp.test.ts | 56 +++++++++++-------- ...ncryption.prose.19.on_demand_azure.test.ts | 54 ++++++++++-------- 2 files changed, 62 insertions(+), 48 deletions(-) diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.17.on_demand_gcp.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.17.on_demand_gcp.test.ts index f069eb15a6f..98c204fb2e3 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.17.on_demand_gcp.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.17.on_demand_gcp.test.ts @@ -5,12 +5,6 @@ import { env } from 'process'; import { ClientEncryption } from '../../../src/client-side-encryption/client_encryption'; import { Binary } from '../../mongodb'; -const metadata: MongoDBMetadataUI = { - requires: { - clientSideEncryption: true - } -} as const; - const dataKeyOptions = { masterKey: { projectId: 'devprod-drivers', @@ -45,25 +39,39 @@ describe('17. On-demand GCP Credentials', () => { await keyVaultClient?.close(); }); - it('Case 1: Failure', metadata, async function () { - if (env.EXPECTED_GCPKMS_OUTCOME !== 'failure') { - this.skipReason = 'This test is supposed to run in the environment where failure is expected'; - this.skip(); + it( + 'Case 1: Failure', + { + requires: { + predicate: () => + env.EXPECTED_GCPKMS_OUTCOME !== 'failure' + ? 'This test is supposed to run in the environment where failure is expected' + : true + } + }, + async function () { + const error = await clientEncryption + .createDataKey('gcp', dataKeyOptions) + .catch(error => error); + // GaxiosError: Unsuccessful response status code. Request failed with status code 404 + expect(error).to.be.instanceOf(Error); + expect(error).property('code', '404'); } + ); - const error = await clientEncryption.createDataKey('gcp', dataKeyOptions).catch(error => error); - // GaxiosError: Unsuccessful response status code. Request failed with status code 404 - expect(error).to.be.instanceOf(Error); - expect(error).property('code', '404'); - }); - - it('Case 2: Success', metadata, async function () { - if (env.EXPECTED_GCPKMS_OUTCOME !== 'success') { - this.skipReason = 'This test is supposed to run in the environment where success is expected'; - this.skip(); + it( + 'Case 2: Success', + { + requires: { + predicate: () => + env.EXPECTED_GCPKMS_OUTCOME !== 'success' + ? 'This test is supposed to run in the environment where success is expected' + : true + } + }, + async function () { + const dk = await clientEncryption.createDataKey('gcp', dataKeyOptions); + expect(dk).to.be.instanceOf(Binary); } - - const dk = await clientEncryption.createDataKey('gcp', dataKeyOptions); - expect(dk).to.be.instanceOf(Binary); - }); + ); }); diff --git a/test/integration/client-side-encryption/client_side_encryption.prose.19.on_demand_azure.test.ts b/test/integration/client-side-encryption/client_side_encryption.prose.19.on_demand_azure.test.ts index 16e679ca5e6..aba12464f8a 100644 --- a/test/integration/client-side-encryption/client_side_encryption.prose.19.on_demand_azure.test.ts +++ b/test/integration/client-side-encryption/client_side_encryption.prose.19.on_demand_azure.test.ts @@ -7,12 +7,6 @@ import { ClientEncryption } from '../../../src/client-side-encryption/client_enc import { MongoCryptAzureKMSRequestError } from '../../../src/client-side-encryption/errors'; import { Binary } from '../../mongodb'; -const metadata: MongoDBMetadataUI = { - requires: { - clientSideEncryption: true - } -} as const; - const dataKeyOptions = { masterKey: { keyVaultEndpoint: 'https://drivers-2411-keyvault.vault.azure.net/', @@ -48,25 +42,37 @@ describe('19. On-demand Azure Credentials', () => { await keyVaultClient?.close(); }); - it('Case 1: Failure', metadata, async function () { - if (env.EXPECTED_AZUREKMS_OUTCOME !== 'failure') { - this.skipReason = 'This test is supposed to run in the environment where failure is expected'; - this.skip(); + it( + 'Case 1: Failure', + { + requires: { + predicate: () => + env.EXPECTED_AZUREKMS_OUTCOME !== 'failure' + ? 'This test is supposed to run in the environment where failure is expected' + : true + } + }, + async function () { + const error = await clientEncryption + .createDataKey('azure', dataKeyOptions) + .catch(error => error); + expect(error).to.be.instanceOf(MongoCryptAzureKMSRequestError); } + ); - const error = await clientEncryption - .createDataKey('azure', dataKeyOptions) - .catch(error => error); - expect(error).to.be.instanceOf(MongoCryptAzureKMSRequestError); - }); - - it('Case 2: Success', metadata, async function () { - if (env.EXPECTED_AZUREKMS_OUTCOME !== 'success') { - this.skipReason = 'This test is supposed to run in the environment where success is expected'; - this.skip(); + it( + 'Case 2: Success', + { + requires: { + predicate: () => + env.EXPECTED_AZUREKMS_OUTCOME !== 'success' + ? 'This test is supposed to run in the environment where success is expected' + : true + } + }, + async function () { + const dk = await clientEncryption.createDataKey('azure', dataKeyOptions); + expect(dk).to.be.instanceOf(Binary); } - - const dk = await clientEncryption.createDataKey('azure', dataKeyOptions); - expect(dk).to.be.instanceOf(Binary); - }); + ); });