@@ -5,12 +5,6 @@ import { env } from 'process';
55import { ClientEncryption } from '../../../src/client-side-encryption/client_encryption' ;
66import { Binary } from '../../mongodb' ;
77
8- const metadata : MongoDBMetadataUI = {
9- requires : {
10- clientSideEncryption : true
11- }
12- } as const ;
13-
148const 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} ) ;
0 commit comments