@@ -5,7 +5,6 @@ import { resolve } from 'path';
5
5
import * as sinon from 'sinon' ;
6
6
7
7
import { ClientEncryption } from '../../../src/client-side-encryption/client_encryption' ;
8
- import * as cryptoCallbacks from '../../../src/client-side-encryption/crypto_callbacks' ;
9
8
import {
10
9
MongoCryptCreateDataKeyError ,
11
10
MongoCryptCreateEncryptedCollectionError
@@ -35,66 +34,6 @@ class MockClient {
35
34
describe ( 'ClientEncryption' , function ( ) {
36
35
this . timeout ( 12000 ) ;
37
36
38
- context ( 'with stubbed key material and fixed random source' , function ( ) {
39
- const sandbox = sinon . createSandbox ( ) ;
40
-
41
- afterEach ( ( ) => {
42
- sandbox . restore ( ) ;
43
- } ) ;
44
- beforeEach ( ( ) => {
45
- const rndData = Buffer . from (
46
- '\x4d\x06\x95\x64\xf5\xa0\x5e\x9e\x35\x23\xb9\x8f\x57\x5a\xcb\x15' ,
47
- 'latin1'
48
- ) ;
49
- let rndPos = 0 ;
50
- sandbox . stub ( cryptoCallbacks , 'randomHook' ) . callsFake ( ( buffer , count ) => {
51
- if ( rndPos + count > rndData . length ) {
52
- return new Error ( 'Out of fake random data' ) ;
53
- }
54
- buffer . set ( rndData . subarray ( rndPos , rndPos + count ) ) ;
55
- rndPos += count ;
56
- return count ;
57
- } ) ;
58
-
59
- // stubbed out for AWS unit testing below
60
- sandbox . stub ( StateMachine . prototype , 'fetchKeys' ) . callsFake ( ( client , ns , filter ) => {
61
- filter = deserialize ( filter ) ;
62
- const keyIds = filter . $or [ 0 ] . _id . $in . map ( key => key . toString ( 'hex' ) ) ;
63
- const fileNames = keyIds . map ( keyId =>
64
- resolve ( `${ __dirname } /data/keys/${ keyId . toUpperCase ( ) } -local-document.json` )
65
- ) ;
66
- const contents = fileNames . map ( filename =>
67
- EJSON . parse ( fs . readFileSync ( filename , { encoding : 'utf-8' } ) )
68
- ) ;
69
- return Promise . resolve ( contents ) ;
70
- } ) ;
71
- } ) ;
72
-
73
- // This exactly matches _test_encrypt_fle2_explicit from the C tests
74
- it ( 'should explicitly encrypt and decrypt with the "local" KMS provider (FLE2, exact result)' , function ( ) {
75
- const encryption = new ClientEncryption ( new MockClient ( ) , {
76
- keyVaultNamespace : 'client.encryption' ,
77
- kmsProviders : { local : { key : Buffer . alloc ( 96 ) } }
78
- } ) ;
79
-
80
- const encryptOptions = {
81
- keyId : new Binary ( Buffer . from ( 'ABCDEFAB123498761234123456789012' , 'hex' ) , 4 ) ,
82
- algorithm : 'Unindexed'
83
- } ;
84
-
85
- return encryption
86
- . encrypt ( 'value123' , encryptOptions )
87
- . then ( encrypted => {
88
- expect ( encrypted . _bsontype ) . to . equal ( 'Binary' ) ;
89
- expect ( encrypted . sub_type ) . to . equal ( 6 ) ;
90
- return encryption . decrypt ( encrypted ) ;
91
- } )
92
- . then ( decrypted => {
93
- expect ( decrypted ) . to . equal ( 'value123' ) ;
94
- } ) ;
95
- } ) ;
96
- } ) ;
97
-
98
37
it ( 'should provide the libmongocrypt version' , function ( ) {
99
38
expect ( ClientEncryption . libmongocryptVersion ) . to . be . a ( 'string' ) ;
100
39
} ) ;
0 commit comments