Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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);
});
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -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/',
Expand Down Expand Up @@ -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);
});
);
});