Skip to content

Commit 8b34213

Browse files
ci(NODE-6791): make deployed KMS tests run again (#4451)
1 parent 2107200 commit 8b34213

File tree

2 files changed

+62
-48
lines changed

2 files changed

+62
-48
lines changed

test/integration/client-side-encryption/client_side_encryption.prose.17.on_demand_gcp.test.ts

+32-24
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ import { env } from 'process';
55
import { ClientEncryption } from '../../../src/client-side-encryption/client_encryption';
66
import { Binary } from '../../mongodb';
77

8-
const metadata: MongoDBMetadataUI = {
9-
requires: {
10-
clientSideEncryption: true
11-
}
12-
} as const;
13-
148
const dataKeyOptions = {
159
masterKey: {
1610
projectId: 'devprod-drivers',
@@ -45,25 +39,39 @@ describe('17. On-demand GCP Credentials', () => {
4539
await keyVaultClient?.close();
4640
});
4741

48-
it('Case 1: Failure', metadata, async function () {
49-
if (env.EXPECTED_GCPKMS_OUTCOME !== 'failure') {
50-
this.skipReason = 'This test is supposed to run in the environment where failure is expected';
51-
this.skip();
42+
it(
43+
'Case 1: Failure',
44+
{
45+
requires: {
46+
predicate: () =>
47+
env.EXPECTED_GCPKMS_OUTCOME !== 'failure'
48+
? 'This test is supposed to run in the environment where failure is expected'
49+
: true
50+
}
51+
},
52+
async function () {
53+
const error = await clientEncryption
54+
.createDataKey('gcp', dataKeyOptions)
55+
.catch(error => error);
56+
// GaxiosError: Unsuccessful response status code. Request failed with status code 404
57+
expect(error).to.be.instanceOf(Error);
58+
expect(error).property('code', '404');
5259
}
60+
);
5361

54-
const error = await clientEncryption.createDataKey('gcp', dataKeyOptions).catch(error => error);
55-
// GaxiosError: Unsuccessful response status code. Request failed with status code 404
56-
expect(error).to.be.instanceOf(Error);
57-
expect(error).property('code', '404');
58-
});
59-
60-
it('Case 2: Success', metadata, async function () {
61-
if (env.EXPECTED_GCPKMS_OUTCOME !== 'success') {
62-
this.skipReason = 'This test is supposed to run in the environment where success is expected';
63-
this.skip();
62+
it(
63+
'Case 2: Success',
64+
{
65+
requires: {
66+
predicate: () =>
67+
env.EXPECTED_GCPKMS_OUTCOME !== 'success'
68+
? 'This test is supposed to run in the environment where success is expected'
69+
: true
70+
}
71+
},
72+
async function () {
73+
const dk = await clientEncryption.createDataKey('gcp', dataKeyOptions);
74+
expect(dk).to.be.instanceOf(Binary);
6475
}
65-
66-
const dk = await clientEncryption.createDataKey('gcp', dataKeyOptions);
67-
expect(dk).to.be.instanceOf(Binary);
68-
});
76+
);
6977
});

test/integration/client-side-encryption/client_side_encryption.prose.19.on_demand_azure.test.ts

+30-24
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ import { ClientEncryption } from '../../../src/client-side-encryption/client_enc
77
import { MongoCryptAzureKMSRequestError } from '../../../src/client-side-encryption/errors';
88
import { Binary } from '../../mongodb';
99

10-
const metadata: MongoDBMetadataUI = {
11-
requires: {
12-
clientSideEncryption: true
13-
}
14-
} as const;
15-
1610
const dataKeyOptions = {
1711
masterKey: {
1812
keyVaultEndpoint: 'https://drivers-2411-keyvault.vault.azure.net/',
@@ -48,25 +42,37 @@ describe('19. On-demand Azure Credentials', () => {
4842
await keyVaultClient?.close();
4943
});
5044

51-
it('Case 1: Failure', metadata, async function () {
52-
if (env.EXPECTED_AZUREKMS_OUTCOME !== 'failure') {
53-
this.skipReason = 'This test is supposed to run in the environment where failure is expected';
54-
this.skip();
45+
it(
46+
'Case 1: Failure',
47+
{
48+
requires: {
49+
predicate: () =>
50+
env.EXPECTED_AZUREKMS_OUTCOME !== 'failure'
51+
? 'This test is supposed to run in the environment where failure is expected'
52+
: true
53+
}
54+
},
55+
async function () {
56+
const error = await clientEncryption
57+
.createDataKey('azure', dataKeyOptions)
58+
.catch(error => error);
59+
expect(error).to.be.instanceOf(MongoCryptAzureKMSRequestError);
5560
}
61+
);
5662

57-
const error = await clientEncryption
58-
.createDataKey('azure', dataKeyOptions)
59-
.catch(error => error);
60-
expect(error).to.be.instanceOf(MongoCryptAzureKMSRequestError);
61-
});
62-
63-
it('Case 2: Success', metadata, async function () {
64-
if (env.EXPECTED_AZUREKMS_OUTCOME !== 'success') {
65-
this.skipReason = 'This test is supposed to run in the environment where success is expected';
66-
this.skip();
63+
it(
64+
'Case 2: Success',
65+
{
66+
requires: {
67+
predicate: () =>
68+
env.EXPECTED_AZUREKMS_OUTCOME !== 'success'
69+
? 'This test is supposed to run in the environment where success is expected'
70+
: true
71+
}
72+
},
73+
async function () {
74+
const dk = await clientEncryption.createDataKey('azure', dataKeyOptions);
75+
expect(dk).to.be.instanceOf(Binary);
6776
}
68-
69-
const dk = await clientEncryption.createDataKey('azure', dataKeyOptions);
70-
expect(dk).to.be.instanceOf(Binary);
71-
});
77+
);
7278
});

0 commit comments

Comments
 (0)