libmongocrypt-helper 1.7.4.0.1001 → 1.8.0.0.1001
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/ext/libmongocrypt/extconf.rb +2 -2
- data/ext/libmongocrypt/libmongocrypt/CHANGELOG.md +9 -7
- data/ext/libmongocrypt/libmongocrypt/CMakeLists.txt +17 -23
- data/ext/libmongocrypt/libmongocrypt/Earthfile +374 -0
- data/ext/libmongocrypt/libmongocrypt/README.md +7 -7
- data/ext/libmongocrypt/libmongocrypt/VERSION_CURRENT +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptClient.cs +25 -6
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Library.cs +25 -3
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Example/MongoDB.Libmongocrypt.Example.csproj +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/BasicTests.cs +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.cake +3 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/cs/cs.sln +79 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/build.gradle.kts +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/java/com/mongodb/crypt/capi/MongoCryptTest.java +6 -4
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit-v2/int32/encrypted-payload.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/CHANGELOG.md +24 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/README.md +134 -5
- data/ext/libmongocrypt/libmongocrypt/bindings/node/etc/build-static.sh +3 -6
- data/ext/libmongocrypt/libmongocrypt/bindings/node/index.d.ts +203 -77
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/autoEncrypter.js +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/clientEncryption.js +165 -43
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/common.js +12 -14
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/errors.js +75 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/index.js +34 -3
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/aws.js +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/azure.js +178 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/gcp.js +24 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/index.js +54 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/utils.js +39 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/stateMachine.js +9 -4
- data/ext/libmongocrypt/libmongocrypt/bindings/node/package-lock.json +4440 -5189
- data/ext/libmongocrypt/libmongocrypt/bindings/node/package.json +27 -8
- data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.cc +65 -38
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/autoEncrypter.test.js +4 -7
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/clientEncryption.test.js +434 -42
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/common.test.js +94 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/cryptoCallbacks.test.js +1 -45
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/index.test.js +45 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/mongocryptdManager.test.js +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/providers/credentialsProvider.test.js +551 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/release.test.js +10 -3
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/requirements.helper.js +23 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/stateMachine.test.js +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/tools/chai-addons.js +8 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/types/index.test-d.ts +63 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/CHANGELOG.rst +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/README.rst +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/python/build-manylinux-wheel.sh +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binding.py +128 -238
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/compat.py +0 -27
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/explicit_encrypter.py +1 -1
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/mongocrypt.py +5 -21
- data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/version.py +2 -2
- data/ext/libmongocrypt/libmongocrypt/bindings/python/release.sh +5 -5
- data/ext/libmongocrypt/libmongocrypt/bindings/python/setup.py +14 -9
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/__init__.py +1 -10
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit-v2/int32/encrypted-payload.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_mongocrypt.py +5 -5
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test-requirements.txt +4 -12
- data/ext/libmongocrypt/libmongocrypt/cmake/ImportBSON.cmake +8 -6
- data/ext/libmongocrypt/libmongocrypt/cmake/IntelDFP.cmake +2 -1
- data/ext/libmongocrypt/libmongocrypt/cmake/Platform.cmake +50 -0
- data/ext/libmongocrypt/libmongocrypt/cmake/mongocrypt-config.cmake +21 -0
- data/ext/libmongocrypt/libmongocrypt/debian/gbp.conf +2 -2
- data/ext/libmongocrypt/libmongocrypt/etc/c6-vault.repo +39 -0
- data/ext/libmongocrypt/libmongocrypt/etc/fle2_aead_generate_tests.py +15 -24
- data/ext/libmongocrypt/libmongocrypt/etc/fle2_crypto.py +66 -54
- data/ext/libmongocrypt/libmongocrypt/etc/fle2_generate_tests.py +14 -23
- data/ext/libmongocrypt/libmongocrypt/etc/fle2v2_aead_generate_tests.py +32 -0
- data/ext/libmongocrypt/libmongocrypt/etc/format-all.sh +12 -0
- data/ext/libmongocrypt/libmongocrypt/etc/format.sh +16 -0
- data/ext/libmongocrypt/libmongocrypt/etc/install-package.sh +48 -0
- data/ext/libmongocrypt/libmongocrypt/etc/mongo-inteldfp-libmongocrypt-pr-625.patch +13 -0
- data/ext/libmongocrypt/libmongocrypt/src/crypto/cng.c +381 -436
- data/ext/libmongocrypt/libmongocrypt/src/crypto/commoncrypto.c +162 -227
- data/ext/libmongocrypt/libmongocrypt/src/crypto/libcrypto.c +180 -248
- data/ext/libmongocrypt/libmongocrypt/src/crypto/none.c +33 -55
- data/ext/libmongocrypt/libmongocrypt/src/csfle-markup.cpp +175 -205
- data/ext/libmongocrypt/libmongocrypt/src/mc-array-private.h +10 -21
- data/ext/libmongocrypt/libmongocrypt/src/mc-array.c +44 -56
- data/ext/libmongocrypt/libmongocrypt/src/mc-check-conversions-private.h +4 -8
- data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.h +351 -463
- data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.test.cpp +59 -66
- data/ext/libmongocrypt/libmongocrypt/src/mc-efc-private.h +7 -11
- data/ext/libmongocrypt/libmongocrypt/src/mc-efc.c +80 -92
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle-blob-subtype-private.h +18 -10
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder-private.h +59 -70
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder.c +384 -439
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private-v2.h +41 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private.h +11 -18
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-v2.c +135 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload.c +109 -126
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private-v2.h +88 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private.h +24 -27
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-v2.c +137 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload.c +106 -125
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private-v2.h +117 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private.h +28 -36
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-v2.c +294 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload.c +237 -278
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-private-v2.h +133 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-private.h +67 -56
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-v2.c +437 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev.c +476 -325
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-common-private.h +69 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-common.c +182 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-private.h +23 -31
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-v2-private.h +85 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-v2.c +142 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev.c +104 -231
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-range-operator-private.h +8 -7
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds-private.h +55 -56
- data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds.c +517 -580
- data/ext/libmongocrypt/libmongocrypt/src/mc-optional-private.h +36 -66
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation-private.h +57 -76
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation.c +158 -189
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding-private.h +36 -42
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding.c +515 -558
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-generator.template.h +155 -191
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-private.h +43 -53
- data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover.c +170 -240
- data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts-private.h +29 -34
- data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts.c +289 -338
- data/ext/libmongocrypt/libmongocrypt/src/mc-reader-private.h +36 -71
- data/ext/libmongocrypt/libmongocrypt/src/mc-reader.c +111 -164
- data/ext/libmongocrypt/libmongocrypt/src/mc-tokens-private.h +55 -49
- data/ext/libmongocrypt/libmongocrypt/src/mc-tokens.c +109 -125
- data/ext/libmongocrypt/libmongocrypt/src/mc-writer-private.h +66 -0
- data/ext/libmongocrypt/libmongocrypt/src/mc-writer.c +141 -0
- data/ext/libmongocrypt/libmongocrypt/src/mlib/check.hpp +37 -55
- data/ext/libmongocrypt/libmongocrypt/src/mlib/endian.h +11 -11
- data/ext/libmongocrypt/libmongocrypt/src/mlib/error.h +27 -32
- data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.h +444 -499
- data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.test.cpp +251 -334
- data/ext/libmongocrypt/libmongocrypt/src/mlib/macros.h +4 -5
- data/ext/libmongocrypt/libmongocrypt/src/mlib/path.h +196 -231
- data/ext/libmongocrypt/libmongocrypt/src/mlib/path.test.c +56 -79
- data/ext/libmongocrypt/libmongocrypt/src/mlib/str.h +411 -530
- data/ext/libmongocrypt/libmongocrypt/src/mlib/str.test.c +116 -131
- data/ext/libmongocrypt/libmongocrypt/src/mlib/thread.h +17 -26
- data/ext/libmongocrypt/libmongocrypt/src/mlib/user-check.h +2 -2
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary-private.h +3 -6
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary.c +31 -48
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer-private.h +55 -131
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer.c +444 -565
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo-private.h +1 -2
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo.c +28 -45
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key-private.h +11 -17
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key.c +103 -132
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth-private.h +8 -14
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth.c +78 -90
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-private.h +26 -45
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache.c +220 -273
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext-private.h +13 -25
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext.c +147 -166
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-compat.h +2 -2
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto-private.h +110 -204
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto.c +1137 -1565
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-datakey.c +425 -472
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-decrypt.c +817 -694
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-encrypt.c +2394 -2697
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-private.h +166 -186
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-rewrap-many-datakey.c +308 -351
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx.c +921 -1138
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-dll-private.h +16 -24
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endian-private.h +44 -58
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint-private.h +21 -25
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint.c +167 -181
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek-private.h +37 -43
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek.c +215 -253
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker-private.h +73 -108
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker.c +889 -1034
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-private.h +27 -44
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key.c +349 -402
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx-private.h +92 -120
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx.c +1397 -1612
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log-private.h +35 -67
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log.c +49 -83
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking-private.h +30 -36
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking.c +1821 -1470
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-mutex-private.h +7 -12
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts-private.h +80 -108
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts.c +354 -424
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-private.h +101 -117
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status-private.h +3 -8
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status.c +92 -119
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util-private.h +19 -29
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util.c +136 -176
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util-private.h +11 -21
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util.c +96 -135
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.c +1092 -1320
- data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.h +130 -295
- data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_dll.c +66 -78
- data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_mutex.c +20 -28
- data/ext/libmongocrypt/libmongocrypt/src/os_win/os_dll.c +60 -73
- data/ext/libmongocrypt/libmongocrypt/src/os_win/os_mutex.c +8 -16
- data/ext/libmongocrypt/libmongocrypt/test/crypt_shared-stub.cpp +57 -87
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/encrypted-payload-v2.json +60 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/encrypted-payload-v2.json +67 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/encrypted-payload.json +2 -2
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed-contentionFactor1-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-contentionFactor1-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-same-user-and-index-key-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/encrypted-field-map.json +22 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/encrypted-payload.json +40 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/mongocryptd-reply.json +19 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/cmd.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-payload.json +50 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/mongocryptd-reply.json +58 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/cmd.json +6 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/cmd.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-payload.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double-precision/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/encrypted-payload-v2.json +26 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-openinterval/encrypted-payload-v2.json +16 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert/cmd.json +1 -1
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/RNG_DATA.h +65 -65
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/cmd.json +13 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/RNG_DATA.h +132 -132
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/RNG_DATA.h +71 -71
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-payload.json +53 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/mongocryptd-reply.json +61 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/RNG_DATA.h +68 -68
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/RNG_DATA.h +19 -19
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/encrypted-field-map.json +30 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/encrypted-payload.json +47 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/mongocryptd-reply.json +55 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32/RNG_DATA.h +25 -25
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/RNG_DATA.h +65 -65
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/cmd.json +11 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-field-map.json +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-payload.json +44 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/mongocryptd-reply.json +52 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/RNG_DATA.h +68 -68
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/RNG_DATA.h +19 -19
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/RNG_DATA.h +25 -25
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/RNG_DATA.h +15 -15
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/encrypted-payload-v2.json +8 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/encrypted-field-map.json +18 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/encrypted-payload.json +14 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/mongocryptd-reply.json +41 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/cmd.json +9 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/encrypted-field-map.json +22 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/encrypted-payload.json +39 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/mongocryptd-reply.json +49 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/iev-v2/FLECrudTest-insertOneRangeV2.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/iev-v2/FLECrudTest-insertOneV2.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/README.md +17 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/aes-ctr.json +29 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2-fixed.json +10 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2-generated.json +38 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-decrypt.json +35 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-fixed.json +29 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-generated.json +122 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2v2-aead-fixed.json +29 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2v2-aead-generated.json +122 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/mcgrew.json +12 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/nist.json +20 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/README.md +27 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/mc.json +21 -0
- data/ext/libmongocrypt/libmongocrypt/test/data/tokens/server.json +21 -0
- data/ext/libmongocrypt/libmongocrypt/test/example-no-bson.c +4 -4
- data/ext/libmongocrypt/libmongocrypt/test/example-state-machine.c +278 -323
- data/ext/libmongocrypt/libmongocrypt/test/fuzz_kms.c +8 -7
- data/ext/libmongocrypt/libmongocrypt/test/test-dll.cpp +6 -7
- data/ext/libmongocrypt/libmongocrypt/test/test-gcp-auth.c +221 -283
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-efc.c +58 -73
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-equality-payload-v2.c +78 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-range-payload-v2.c +89 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev-v2.c +248 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev.c +467 -414
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup-v2.c +172 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup.c +141 -159
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-uev-v2.c +338 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-uev.c +238 -176
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-rfds.c +373 -474
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-edge-generation.c +346 -388
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-encoding.c +708 -825
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-mincover.c +417 -481
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-rangeopts.c +110 -144
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-reader.c +124 -207
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-tokens.c +223 -213
- data/ext/libmongocrypt/libmongocrypt/test/test-mc-writer.c +176 -0
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.c +634 -807
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.h +1 -2
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert.h +168 -189
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-buffer.c +187 -211
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache-oauth.c +34 -36
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache.c +210 -233
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ciphertext.c +185 -220
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-compact.c +331 -445
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-hooks.c +670 -814
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.c +102 -135
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.h +54 -71
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto.c +394 -846
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-csfle-lib.c +159 -183
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-decrypt.c +867 -1045
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-encrypt.c +4349 -4713
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-rewrap-many-datakey.c +750 -964
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-setopt.c +991 -1178
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-datakey.c +342 -419
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-dll.c +23 -30
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-endpoint.c +98 -111
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kek.c +49 -52
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-broker.c +770 -920
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-cache.c +354 -407
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key.c +197 -245
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-ctx.c +286 -370
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-responses.c +147 -166
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-local-kms.c +50 -61
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-log.c +85 -100
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-marking.c +656 -692
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-status.c +46 -58
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-traverse-util.c +377 -451
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.c +48 -67
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.h +4 -10
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.c +827 -918
- data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.h +111 -172
- data/ext/libmongocrypt/libmongocrypt/test/util/csfle.c +508 -559
- data/ext/libmongocrypt/libmongocrypt/test/util/util.c +735 -881
- data/ext/libmongocrypt/libmongocrypt/test/util/util.h +33 -55
- data/lib/libmongocrypt_helper/version.rb +2 -2
- data/lib/libmongocrypt_helper.rb +2 -2
- data.tar.gz.sig +0 -0
- metadata +154 -26
- metadata.gz.sig +0 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/encrypted-payload.json +0 -26
- data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/key-document.json +0 -0
- data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/credentialsProvider.js +0 -33
- data/ext/libmongocrypt/libmongocrypt/bindings/node/test/credentialsProvider.test.js +0 -163
- data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit/int32/encrypted-payload.json +0 -26
- data/ext/libmongocrypt/libmongocrypt/test/data/aes-ctr.cstructs +0 -359
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-aead.cstructs +0 -109
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/encrypted-payload.json +0 -26
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/rangeopts.json +0 -5
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/value-to-encrypt.json +0 -20
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/RNG_DATA.h +0 -70
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/encrypted-payload.json +0 -8
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/rangeopts.json +0 -5
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/value-to-encrypt.json +0 -5
- data/ext/libmongocrypt/libmongocrypt/test/data/fle2.cstructs +0 -33
- /data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/key-filter.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/rangeopts.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/value-to-encrypt.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/rangeopts.json +0 -0
- /data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/value-to-encrypt.json +0 -0
@@ -1,9 +1,7 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
3
|
const sinon = require('sinon');
|
4
|
-
const
|
5
|
-
const expect = chai.expect;
|
6
|
-
chai.use(require('sinon-chai'));
|
4
|
+
const { expect } = require('chai');
|
7
5
|
const mongodb = require('mongodb');
|
8
6
|
const MongoClient = mongodb.MongoClient;
|
9
7
|
const stateMachine = require('../lib/stateMachine')({ mongodb });
|
@@ -198,48 +196,6 @@ describe('cryptoCallbacks', function () {
|
|
198
196
|
});
|
199
197
|
});
|
200
198
|
|
201
|
-
// AES-256-CTR is used specifically with FLE2 only
|
202
|
-
['aes256CtrEncryptHook', 'aes256CtrDecryptHook'].forEach(hookName => {
|
203
|
-
it(`should properly propagate an error when ${hookName} fails`, function (done) {
|
204
|
-
const error = new Error('some random error text');
|
205
|
-
this.sinon.stub(cryptoCallbacks, hookName).returns(error);
|
206
|
-
|
207
|
-
const encryption = new ClientEncryption(this.client, {
|
208
|
-
keyVaultNamespace: 'test.encryption',
|
209
|
-
kmsProviders
|
210
|
-
});
|
211
|
-
|
212
|
-
function finish(err) {
|
213
|
-
try {
|
214
|
-
expect(err, 'Expected an error to exist').to.exist;
|
215
|
-
expect(err).to.have.property('message', error.message);
|
216
|
-
done();
|
217
|
-
} catch (e) {
|
218
|
-
done(e);
|
219
|
-
}
|
220
|
-
}
|
221
|
-
|
222
|
-
try {
|
223
|
-
encryption.createDataKey('aws', dataKeyOptions, (err, dataKey) => {
|
224
|
-
if (err) return finish(err);
|
225
|
-
|
226
|
-
const encryptOptions = {
|
227
|
-
keyId: dataKey,
|
228
|
-
algorithm: 'Indexed',
|
229
|
-
contentionFactor: 0
|
230
|
-
};
|
231
|
-
|
232
|
-
encryption.encrypt('hello', encryptOptions, (err, encryptedValue) => {
|
233
|
-
if (err) return finish(err);
|
234
|
-
encryption.decrypt(encryptedValue, err => finish(err));
|
235
|
-
});
|
236
|
-
});
|
237
|
-
} catch (e) {
|
238
|
-
done(new Error('We should not be here'));
|
239
|
-
}
|
240
|
-
});
|
241
|
-
});
|
242
|
-
|
243
199
|
// These ones will fail with an error, but that error will get overridden
|
244
200
|
// with "failed to create KMS message" in mongocrypt-kms-ctx.c
|
245
201
|
['hmacSha256Hook', 'sha256Hook'].forEach(hookName => {
|
@@ -0,0 +1,45 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const { expect } = require('chai');
|
4
|
+
const mongodbClientEncryption = require('../lib/index');
|
5
|
+
const { fetchAzureKMSToken } = require('../lib/providers');
|
6
|
+
|
7
|
+
// Update this as you add exports, helps double check we don't accidentally remove something
|
8
|
+
// since not all tests import from the root public export
|
9
|
+
const EXPECTED_EXPORTS = [
|
10
|
+
'extension',
|
11
|
+
'MongoCryptError',
|
12
|
+
'MongoCryptCreateEncryptedCollectionError',
|
13
|
+
'MongoCryptCreateDataKeyError',
|
14
|
+
'MongoCryptAzureKMSRequestError',
|
15
|
+
'MongoCryptKMSRequestNetworkTimeoutError',
|
16
|
+
'AutoEncrypter',
|
17
|
+
'ClientEncryption'
|
18
|
+
];
|
19
|
+
|
20
|
+
describe('mongodb-client-encryption entrypoint', () => {
|
21
|
+
it('should export all and only the expected keys in expected_exports', () => {
|
22
|
+
expect(mongodbClientEncryption).to.have.all.keys(EXPECTED_EXPORTS);
|
23
|
+
});
|
24
|
+
|
25
|
+
it('extension returns an object equal in shape to the default except for extension', () => {
|
26
|
+
const extensionResult = mongodbClientEncryption.extension(require('mongodb'));
|
27
|
+
const expectedExports = EXPECTED_EXPORTS.filter(exp => exp !== 'extension');
|
28
|
+
const exportsDefault = Object.keys(mongodbClientEncryption).filter(exp => exp !== 'extension');
|
29
|
+
expect(extensionResult).to.have.all.keys(expectedExports);
|
30
|
+
expect(extensionResult).to.have.all.keys(exportsDefault);
|
31
|
+
});
|
32
|
+
|
33
|
+
context('exports for driver testing', () => {
|
34
|
+
it('exports `fetchAzureKMSToken` in a symbol property', () => {
|
35
|
+
expect(mongodbClientEncryption).to.have.property(
|
36
|
+
'___azureKMSProseTestExports',
|
37
|
+
fetchAzureKMSToken
|
38
|
+
);
|
39
|
+
});
|
40
|
+
it('extension exports `fetchAzureKMSToken` in a symbol property', () => {
|
41
|
+
const extensionResult = mongodbClientEncryption.extension(require('mongodb'));
|
42
|
+
expect(extensionResult).to.have.property('___azureKMSProseTestExports', fetchAzureKMSToken);
|
43
|
+
});
|
44
|
+
});
|
45
|
+
});
|
@@ -1,7 +1,7 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
3
|
const MongocryptdManager = require('../lib/mongocryptdManager').MongocryptdManager;
|
4
|
-
const expect = require('chai')
|
4
|
+
const { expect } = require('chai');
|
5
5
|
|
6
6
|
describe('MongocryptdManager', function () {
|
7
7
|
it('should default to having spawnArgs of --idleShutdownTimeoutSecs=60', function () {
|
@@ -0,0 +1,551 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const { expect } = require('chai');
|
4
|
+
const http = require('http');
|
5
|
+
const requirements = require('../requirements.helper');
|
6
|
+
const { loadCredentials, isEmptyCredentials } = require('../../lib/providers');
|
7
|
+
const { tokenCache, fetchAzureKMSToken } = require('../../lib/providers/azure');
|
8
|
+
const sinon = require('sinon');
|
9
|
+
const utils = require('../../lib/providers/utils');
|
10
|
+
const {
|
11
|
+
MongoCryptKMSRequestNetworkTimeoutError,
|
12
|
+
MongoCryptAzureKMSRequestError
|
13
|
+
} = require('../../lib/errors');
|
14
|
+
|
15
|
+
const originalAccessKeyId = process.env.AWS_ACCESS_KEY_ID;
|
16
|
+
const originalSecretAccessKey = process.env.AWS_SECRET_ACCESS_KEY;
|
17
|
+
const originalSessionToken = process.env.AWS_SESSION_TOKEN;
|
18
|
+
|
19
|
+
describe('#loadCredentials', function () {
|
20
|
+
context('isEmptyCredentials()', () => {
|
21
|
+
it('returns true for an empty object', () => {
|
22
|
+
expect(isEmptyCredentials('rainyCloud', { rainyCloud: {} })).to.be.true;
|
23
|
+
});
|
24
|
+
|
25
|
+
it('returns false for an object with keys', () => {
|
26
|
+
expect(isEmptyCredentials('rainyCloud', { rainyCloud: { password: 'secret' } })).to.be.false;
|
27
|
+
});
|
28
|
+
|
29
|
+
it('returns false for an nullish credentials', () => {
|
30
|
+
expect(isEmptyCredentials('rainyCloud', { rainyCloud: null })).to.be.false;
|
31
|
+
expect(isEmptyCredentials('rainyCloud', { rainyCloud: undefined })).to.be.false;
|
32
|
+
expect(isEmptyCredentials('rainyCloud', {})).to.be.false;
|
33
|
+
});
|
34
|
+
|
35
|
+
it('returns false for non object credentials', () => {
|
36
|
+
expect(isEmptyCredentials('rainyCloud', { rainyCloud: 0 })).to.be.false;
|
37
|
+
expect(isEmptyCredentials('rainyCloud', { rainyCloud: false })).to.be.false;
|
38
|
+
expect(isEmptyCredentials('rainyCloud', { rainyCloud: Symbol('secret') })).to.be.false;
|
39
|
+
});
|
40
|
+
});
|
41
|
+
|
42
|
+
context('when using aws', () => {
|
43
|
+
const accessKey = 'example';
|
44
|
+
const secretKey = 'example';
|
45
|
+
const sessionToken = 'example';
|
46
|
+
|
47
|
+
after(function () {
|
48
|
+
// After the entire suite runs, set the env back for the rest of the test run.
|
49
|
+
process.env.AWS_ACCESS_KEY_ID = originalAccessKeyId;
|
50
|
+
process.env.AWS_SECRET_ACCESS_KEY = originalSecretAccessKey;
|
51
|
+
process.env.AWS_SESSION_TOKEN = originalSessionToken;
|
52
|
+
});
|
53
|
+
|
54
|
+
context('when the credential provider finds credentials', function () {
|
55
|
+
before(function () {
|
56
|
+
process.env.AWS_ACCESS_KEY_ID = accessKey;
|
57
|
+
process.env.AWS_SECRET_ACCESS_KEY = secretKey;
|
58
|
+
process.env.AWS_SESSION_TOKEN = sessionToken;
|
59
|
+
});
|
60
|
+
|
61
|
+
context('when the credentials are empty', function () {
|
62
|
+
const kmsProviders = { aws: {} };
|
63
|
+
|
64
|
+
before(function () {
|
65
|
+
if (!requirements.credentialProvidersInstalled.aws) {
|
66
|
+
this.currentTest.skipReason = 'Cannot refresh credentials without sdk provider';
|
67
|
+
this.currentTest.skip();
|
68
|
+
return;
|
69
|
+
}
|
70
|
+
});
|
71
|
+
|
72
|
+
it('refreshes the aws credentials', async function () {
|
73
|
+
const providers = await loadCredentials(kmsProviders);
|
74
|
+
expect(providers).to.deep.equal({
|
75
|
+
aws: {
|
76
|
+
accessKeyId: accessKey,
|
77
|
+
secretAccessKey: secretKey,
|
78
|
+
sessionToken: sessionToken
|
79
|
+
}
|
80
|
+
});
|
81
|
+
});
|
82
|
+
});
|
83
|
+
|
84
|
+
context('when the credentials are not empty', function () {
|
85
|
+
context('when aws is empty', function () {
|
86
|
+
const kmsProviders = {
|
87
|
+
local: {
|
88
|
+
key: Buffer.alloc(96)
|
89
|
+
},
|
90
|
+
aws: {}
|
91
|
+
};
|
92
|
+
|
93
|
+
before(function () {
|
94
|
+
if (!requirements.credentialProvidersInstalled.aws) {
|
95
|
+
this.currentTest.skipReason = 'Cannot refresh credentials without sdk provider';
|
96
|
+
this.currentTest.skip();
|
97
|
+
return;
|
98
|
+
}
|
99
|
+
});
|
100
|
+
|
101
|
+
it('refreshes only the aws credentials', async function () {
|
102
|
+
const providers = await loadCredentials(kmsProviders);
|
103
|
+
expect(providers).to.deep.equal({
|
104
|
+
local: {
|
105
|
+
key: Buffer.alloc(96)
|
106
|
+
},
|
107
|
+
aws: {
|
108
|
+
accessKeyId: accessKey,
|
109
|
+
secretAccessKey: secretKey,
|
110
|
+
sessionToken: sessionToken
|
111
|
+
}
|
112
|
+
});
|
113
|
+
});
|
114
|
+
});
|
115
|
+
|
116
|
+
context('when aws is not empty', function () {
|
117
|
+
const kmsProviders = {
|
118
|
+
local: {
|
119
|
+
key: Buffer.alloc(96)
|
120
|
+
},
|
121
|
+
aws: {
|
122
|
+
accessKeyId: 'example'
|
123
|
+
}
|
124
|
+
};
|
125
|
+
|
126
|
+
before(function () {
|
127
|
+
if (!requirements.credentialProvidersInstalled.aws) {
|
128
|
+
this.currentTest.skipReason = 'Cannot refresh credentials without sdk provider';
|
129
|
+
this.currentTest.skip();
|
130
|
+
return;
|
131
|
+
}
|
132
|
+
});
|
133
|
+
|
134
|
+
it('does not refresh credentials', async function () {
|
135
|
+
const providers = await loadCredentials(kmsProviders);
|
136
|
+
expect(providers).to.deep.equal(kmsProviders);
|
137
|
+
});
|
138
|
+
});
|
139
|
+
});
|
140
|
+
});
|
141
|
+
|
142
|
+
context('when the sdk is not installed', function () {
|
143
|
+
const kmsProviders = {
|
144
|
+
local: {
|
145
|
+
key: Buffer.alloc(96)
|
146
|
+
},
|
147
|
+
aws: {}
|
148
|
+
};
|
149
|
+
|
150
|
+
before(function () {
|
151
|
+
if (requirements.credentialProvidersInstalled.aws) {
|
152
|
+
this.currentTest.skipReason = 'Credentials will be loaded when sdk present';
|
153
|
+
this.currentTest.skip();
|
154
|
+
return;
|
155
|
+
}
|
156
|
+
});
|
157
|
+
|
158
|
+
it('does not refresh credentials', async function () {
|
159
|
+
const providers = await loadCredentials(kmsProviders);
|
160
|
+
expect(providers).to.deep.equal(kmsProviders);
|
161
|
+
});
|
162
|
+
});
|
163
|
+
});
|
164
|
+
|
165
|
+
context('when using gcp', () => {
|
166
|
+
const setupHttpServer = status => {
|
167
|
+
let httpServer;
|
168
|
+
before(() => {
|
169
|
+
httpServer = http
|
170
|
+
.createServer((_, res) => {
|
171
|
+
if (status === 200) {
|
172
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
173
|
+
res.writeHead(200, { 'Metadata-Flavor': 'Google' });
|
174
|
+
res.end(JSON.stringify({ access_token: 'abc' }));
|
175
|
+
} else {
|
176
|
+
res.writeHead(401, { 'Content-Type': 'application/json' });
|
177
|
+
res.writeHead(401, { 'Metadata-Flavor': 'Google' });
|
178
|
+
res.end('{}');
|
179
|
+
}
|
180
|
+
})
|
181
|
+
.listen(5001);
|
182
|
+
process.env.GCE_METADATA_HOST = 'http://127.0.0.1:5001';
|
183
|
+
});
|
184
|
+
|
185
|
+
after(() => {
|
186
|
+
httpServer.close();
|
187
|
+
delete process.env.GCE_METADATA_HOST;
|
188
|
+
});
|
189
|
+
};
|
190
|
+
|
191
|
+
context('and gcp-metadata is installed', () => {
|
192
|
+
beforeEach(function () {
|
193
|
+
if (!requirements.credentialProvidersInstalled.gcp) {
|
194
|
+
this.currentTest.skipReason = 'Tests require gcp-metadata to be installed';
|
195
|
+
this.currentTest.skip();
|
196
|
+
return;
|
197
|
+
}
|
198
|
+
});
|
199
|
+
|
200
|
+
context('when metadata http response is 200 ok', () => {
|
201
|
+
setupHttpServer(200);
|
202
|
+
context('when the credentials are empty', function () {
|
203
|
+
const kmsProviders = { gcp: {} };
|
204
|
+
|
205
|
+
it('refreshes the gcp credentials', async function () {
|
206
|
+
const providers = await loadCredentials(kmsProviders);
|
207
|
+
expect(providers).to.deep.equal({
|
208
|
+
gcp: {
|
209
|
+
accessToken: 'abc'
|
210
|
+
}
|
211
|
+
});
|
212
|
+
});
|
213
|
+
});
|
214
|
+
});
|
215
|
+
|
216
|
+
context('when metadata http response is 401 bad', () => {
|
217
|
+
setupHttpServer(401);
|
218
|
+
context('when the credentials are empty', function () {
|
219
|
+
const kmsProviders = { gcp: {} };
|
220
|
+
|
221
|
+
it('surfaces error from server', async function () {
|
222
|
+
const error = await loadCredentials(kmsProviders).catch(error => error);
|
223
|
+
expect(error).to.be.instanceOf(Error);
|
224
|
+
});
|
225
|
+
});
|
226
|
+
});
|
227
|
+
});
|
228
|
+
|
229
|
+
context('and gcp-metadata is not installed', () => {
|
230
|
+
beforeEach(function () {
|
231
|
+
if (requirements.credentialProvidersInstalled.gcp) {
|
232
|
+
this.currentTest.skipReason = 'Tests require gcp-metadata to be installed';
|
233
|
+
this.currentTest.skip();
|
234
|
+
return;
|
235
|
+
}
|
236
|
+
});
|
237
|
+
|
238
|
+
context('when the credentials are empty', function () {
|
239
|
+
const kmsProviders = { gcp: {} };
|
240
|
+
|
241
|
+
it('does not modify the gcp credentials', async function () {
|
242
|
+
const providers = await loadCredentials(kmsProviders);
|
243
|
+
expect(providers).to.deep.equal({ gcp: {} });
|
244
|
+
});
|
245
|
+
});
|
246
|
+
});
|
247
|
+
});
|
248
|
+
|
249
|
+
context('when using azure', () => {
|
250
|
+
afterEach(() => tokenCache.resetCache());
|
251
|
+
afterEach(() => sinon.restore());
|
252
|
+
context('credential caching', () => {
|
253
|
+
const cache = tokenCache;
|
254
|
+
|
255
|
+
beforeEach(() => {
|
256
|
+
cache.resetCache();
|
257
|
+
});
|
258
|
+
|
259
|
+
context('when there is no cached token', () => {
|
260
|
+
let mockToken = {
|
261
|
+
accessToken: 'mock token',
|
262
|
+
expiresOnTimestamp: Date.now()
|
263
|
+
};
|
264
|
+
|
265
|
+
let token;
|
266
|
+
|
267
|
+
beforeEach(async () => {
|
268
|
+
sinon.stub(cache, '_getToken').returns(mockToken);
|
269
|
+
token = await cache.getToken();
|
270
|
+
});
|
271
|
+
it('fetches a token', async () => {
|
272
|
+
expect(token).to.have.property('accessToken', mockToken.accessToken);
|
273
|
+
});
|
274
|
+
it('caches the token on the class', async () => {
|
275
|
+
expect(cache.cachedToken).to.equal(mockToken);
|
276
|
+
});
|
277
|
+
});
|
278
|
+
|
279
|
+
context('when there is a cached token', () => {
|
280
|
+
context('when the cached token expires <= 1 minute from the current time', () => {
|
281
|
+
let mockToken = {
|
282
|
+
accessToken: 'mock token',
|
283
|
+
expiresOnTimestamp: Date.now()
|
284
|
+
};
|
285
|
+
|
286
|
+
let token;
|
287
|
+
|
288
|
+
beforeEach(async () => {
|
289
|
+
cache.cachedToken = {
|
290
|
+
accessToken: 'a new key',
|
291
|
+
expiresOnTimestamp: Date.now() + 3000
|
292
|
+
};
|
293
|
+
sinon.stub(cache, '_getToken').returns(mockToken);
|
294
|
+
token = await cache.getToken();
|
295
|
+
});
|
296
|
+
|
297
|
+
it('fetches a token', () => {
|
298
|
+
expect(token).to.have.property('accessToken', mockToken.accessToken);
|
299
|
+
});
|
300
|
+
it('caches the token on the class', () => {
|
301
|
+
expect(cache.cachedToken).to.equal(mockToken);
|
302
|
+
});
|
303
|
+
});
|
304
|
+
|
305
|
+
context('when the cached token expires > 1 minute from the current time', () => {
|
306
|
+
let expiredToken = {
|
307
|
+
token: 'mock token',
|
308
|
+
expiresOnTimestamp: Date.now()
|
309
|
+
};
|
310
|
+
|
311
|
+
let expectedMockToken = {
|
312
|
+
accessToken: 'a new key',
|
313
|
+
expiresOnTimestamp: Date.now() + 10000
|
314
|
+
};
|
315
|
+
|
316
|
+
let token;
|
317
|
+
|
318
|
+
beforeEach(async () => {
|
319
|
+
cache.cachedToken = expiredToken;
|
320
|
+
sinon.stub(cache, '_getToken').returns(expectedMockToken);
|
321
|
+
token = await cache.getToken();
|
322
|
+
});
|
323
|
+
it('returns the cached token', () => {
|
324
|
+
expect(token).to.have.property('accessToken', expectedMockToken.accessToken);
|
325
|
+
});
|
326
|
+
});
|
327
|
+
});
|
328
|
+
});
|
329
|
+
|
330
|
+
context('request configuration', () => {
|
331
|
+
const mockResponse = {
|
332
|
+
status: 200,
|
333
|
+
body: '{ "access_token": "token", "expires_in": "10000" }'
|
334
|
+
};
|
335
|
+
|
336
|
+
let httpSpy;
|
337
|
+
|
338
|
+
beforeEach(async () => {
|
339
|
+
httpSpy = sinon.stub(utils, 'get');
|
340
|
+
httpSpy.resolves(mockResponse);
|
341
|
+
|
342
|
+
await loadCredentials({ azure: {} });
|
343
|
+
});
|
344
|
+
|
345
|
+
it('sets the `api-version` param to 2012-02-01', () => {
|
346
|
+
const url = httpSpy.args[0][0];
|
347
|
+
expect(url).to.be.instanceof(URL);
|
348
|
+
expect(url.searchParams.get('api-version'), '2018-02-01');
|
349
|
+
});
|
350
|
+
|
351
|
+
it('sets the `resource` param to `https://vault.azure.net`', () => {
|
352
|
+
const url = httpSpy.args[0][0];
|
353
|
+
expect(url).to.be.instanceof(URL);
|
354
|
+
expect(url.searchParams.get('resource'), 'https://vault.azure.net');
|
355
|
+
});
|
356
|
+
|
357
|
+
it('sends the request to `http://169.254.169.254/metadata/identity/oauth2/token`', () => {
|
358
|
+
const url = httpSpy.args[0][0];
|
359
|
+
expect(url).to.be.instanceof(URL);
|
360
|
+
expect(url.toString()).to.include('http://169.254.169.254/metadata/identity/oauth2/token');
|
361
|
+
});
|
362
|
+
|
363
|
+
it('sets the Metadata header to true', () => {
|
364
|
+
const options = httpSpy.args[0][1];
|
365
|
+
expect(options).to.have.property('headers').to.have.property('Metadata', true);
|
366
|
+
});
|
367
|
+
|
368
|
+
it('sets the Content-Type header to application/json', () => {
|
369
|
+
const options = httpSpy.args[0][1];
|
370
|
+
expect(options)
|
371
|
+
.to.have.property('headers')
|
372
|
+
.to.have.property('Content-Type', 'application/json');
|
373
|
+
});
|
374
|
+
|
375
|
+
context('prose test specific requirements', () => {
|
376
|
+
/**
|
377
|
+
* the driver prose tests require the ability to set custom URL endpoints
|
378
|
+
* for the IMDS call and set custom headers
|
379
|
+
*/
|
380
|
+
const url = new URL('http://customentpoint.com');
|
381
|
+
|
382
|
+
beforeEach(async () => {
|
383
|
+
sinon.restore();
|
384
|
+
httpSpy = sinon.stub(utils, 'get');
|
385
|
+
httpSpy.resolves(mockResponse);
|
386
|
+
await fetchAzureKMSToken({
|
387
|
+
url,
|
388
|
+
headers: {
|
389
|
+
customHeader1: 'value1',
|
390
|
+
customHeader2: 'value2'
|
391
|
+
}
|
392
|
+
});
|
393
|
+
});
|
394
|
+
|
395
|
+
it('allows a custom URL to be specified', () => {
|
396
|
+
const url = httpSpy.args[0][0];
|
397
|
+
expect(url).to.be.instanceof(URL);
|
398
|
+
expect(url.toString()).to.include('http://customentpoint.com');
|
399
|
+
});
|
400
|
+
|
401
|
+
it('deep copies the provided url', () => {
|
402
|
+
const spiedUrl = httpSpy.args[0][0];
|
403
|
+
expect(spiedUrl).to.be.instanceof(URL);
|
404
|
+
expect(spiedUrl).to.not.equal(url);
|
405
|
+
});
|
406
|
+
|
407
|
+
it('allows custom headers to be specified', () => {
|
408
|
+
const options = httpSpy.args[0][1];
|
409
|
+
expect(options).to.have.property('headers').to.have.property('customHeader1', 'value1');
|
410
|
+
expect(options).to.have.property('headers').to.have.property('customHeader2', 'value2');
|
411
|
+
});
|
412
|
+
});
|
413
|
+
});
|
414
|
+
|
415
|
+
context('error handling', () => {
|
416
|
+
afterEach(() => sinon.restore());
|
417
|
+
context('when the request times out', () => {
|
418
|
+
before(() => {
|
419
|
+
sinon.stub(utils, 'get').rejects(new MongoCryptKMSRequestNetworkTimeoutError());
|
420
|
+
});
|
421
|
+
|
422
|
+
it('throws a MongoCryptKMSRequestError', async () => {
|
423
|
+
const error = await loadCredentials({ azure: {} }).catch(e => e);
|
424
|
+
expect(error).to.be.instanceOf(MongoCryptAzureKMSRequestError);
|
425
|
+
});
|
426
|
+
});
|
427
|
+
|
428
|
+
context('when the request returns a non-200 error', () => {
|
429
|
+
context('when the request has no body', () => {
|
430
|
+
before(() => {
|
431
|
+
sinon.stub(utils, 'get').resolves({ status: 400 });
|
432
|
+
});
|
433
|
+
|
434
|
+
it('throws a MongoCryptKMSRequestError', async () => {
|
435
|
+
const error = await loadCredentials({ azure: {} }).catch(e => e);
|
436
|
+
expect(error).to.be.instanceOf(MongoCryptAzureKMSRequestError);
|
437
|
+
expect(error).to.match(/Malformed JSON body in GET request/);
|
438
|
+
});
|
439
|
+
});
|
440
|
+
|
441
|
+
context('when the request has a non-json body', () => {
|
442
|
+
before(() => {
|
443
|
+
sinon.stub(utils, 'get').resolves({ status: 400, body: 'non-json body' });
|
444
|
+
});
|
445
|
+
|
446
|
+
it('throws a MongoCryptKMSRequestError', async () => {
|
447
|
+
const error = await loadCredentials({ azure: {} }).catch(e => e);
|
448
|
+
expect(error).to.be.instanceOf(MongoCryptAzureKMSRequestError);
|
449
|
+
expect(error).to.match(/Malformed JSON body in GET request/);
|
450
|
+
});
|
451
|
+
});
|
452
|
+
|
453
|
+
context('when the request has a json body', () => {
|
454
|
+
beforeEach(() => {
|
455
|
+
sinon
|
456
|
+
.stub(utils, 'get')
|
457
|
+
.resolves({ status: 400, body: '{ "error": "something went wrong" }' });
|
458
|
+
});
|
459
|
+
|
460
|
+
it('throws a MongoCryptKMSRequestError', async () => {
|
461
|
+
const error = await loadCredentials({ azure: {} }).catch(e => e);
|
462
|
+
expect(error).to.be.instanceOf(MongoCryptAzureKMSRequestError);
|
463
|
+
});
|
464
|
+
|
465
|
+
it('attaches the body to the error', async () => {
|
466
|
+
const error = await loadCredentials({ azure: {} }).catch(e => e);
|
467
|
+
expect(error).to.have.property('body').to.deep.equal({ error: 'something went wrong' });
|
468
|
+
});
|
469
|
+
});
|
470
|
+
});
|
471
|
+
|
472
|
+
context('when the request returns a 200 response', () => {
|
473
|
+
context('when the request has no body', () => {
|
474
|
+
before(() => {
|
475
|
+
sinon.stub(utils, 'get').resolves({ status: 200 });
|
476
|
+
});
|
477
|
+
|
478
|
+
it('throws a MongoCryptKMSRequestError', async () => {
|
479
|
+
const error = await loadCredentials({ azure: {} }).catch(e => e);
|
480
|
+
expect(error).to.be.instanceOf(MongoCryptAzureKMSRequestError);
|
481
|
+
expect(error).to.match(/Malformed JSON body in GET request/);
|
482
|
+
});
|
483
|
+
});
|
484
|
+
|
485
|
+
context('when the request has a non-json body', () => {
|
486
|
+
before(() => {
|
487
|
+
sinon.stub(utils, 'get').resolves({ status: 200, body: 'non-json body' });
|
488
|
+
});
|
489
|
+
|
490
|
+
it('throws a MongoCryptKMSRequestError', async () => {
|
491
|
+
const error = await loadCredentials({ azure: {} }).catch(e => e);
|
492
|
+
expect(error).to.be.instanceOf(MongoCryptAzureKMSRequestError);
|
493
|
+
expect(error).to.match(/Malformed JSON body in GET request/);
|
494
|
+
});
|
495
|
+
});
|
496
|
+
|
497
|
+
context('when the body has no access_token', () => {
|
498
|
+
beforeEach(() => {
|
499
|
+
sinon.stub(utils, 'get').resolves({ status: 200, body: '{ "expires_in": "10000" }' });
|
500
|
+
});
|
501
|
+
|
502
|
+
it('throws a MongoCryptKMSRequestError', async () => {
|
503
|
+
const error = await loadCredentials({ azure: {} }).catch(e => e);
|
504
|
+
expect(error).to.be.instanceOf(MongoCryptAzureKMSRequestError);
|
505
|
+
expect(error).to.match(/missing field `access_token/);
|
506
|
+
});
|
507
|
+
});
|
508
|
+
|
509
|
+
context('when the body has no expires_in', () => {
|
510
|
+
beforeEach(() => {
|
511
|
+
sinon.stub(utils, 'get').resolves({ status: 200, body: '{ "access_token": "token" }' });
|
512
|
+
});
|
513
|
+
|
514
|
+
it('throws a MongoCryptKMSRequestError', async () => {
|
515
|
+
const error = await loadCredentials({ azure: {} }).catch(e => e);
|
516
|
+
expect(error).to.be.instanceOf(MongoCryptAzureKMSRequestError);
|
517
|
+
expect(error).to.match(/missing field `expires_in/);
|
518
|
+
});
|
519
|
+
});
|
520
|
+
|
521
|
+
context('when expires_in cannot be parsed into a number', () => {
|
522
|
+
beforeEach(() => {
|
523
|
+
sinon.stub(utils, 'get').resolves({
|
524
|
+
status: 200,
|
525
|
+
body: '{ "access_token": "token", "expires_in": "foo" }'
|
526
|
+
});
|
527
|
+
});
|
528
|
+
|
529
|
+
it('throws a MongoCryptKMSRequestError', async () => {
|
530
|
+
const error = await loadCredentials({ azure: {} }).catch(e => e);
|
531
|
+
expect(error).to.be.instanceOf(MongoCryptAzureKMSRequestError);
|
532
|
+
expect(error).to.match(/unable to parse int from `expires_in` field/);
|
533
|
+
});
|
534
|
+
});
|
535
|
+
});
|
536
|
+
|
537
|
+
context('when a valid token was returned', () => {
|
538
|
+
beforeEach(() => {
|
539
|
+
sinon
|
540
|
+
.stub(utils, 'get')
|
541
|
+
.resolves({ status: 200, body: '{ "access_token": "token", "expires_in": "10000" }' });
|
542
|
+
});
|
543
|
+
|
544
|
+
it('returns the token in the `azure` field of the kms providers', async () => {
|
545
|
+
const kmsProviders = await loadCredentials({ azure: {} });
|
546
|
+
expect(kmsProviders).to.have.property('azure').to.deep.equal({ accessToken: 'token' });
|
547
|
+
});
|
548
|
+
});
|
549
|
+
});
|
550
|
+
});
|
551
|
+
});
|
@@ -1,5 +1,5 @@
|
|
1
1
|
'use strict';
|
2
|
-
const expect = require('chai')
|
2
|
+
const { expect } = require('chai');
|
3
3
|
const tar = require('tar');
|
4
4
|
const cp = require('child_process');
|
5
5
|
const fs = require('fs');
|
@@ -16,8 +16,13 @@ const REQUIRED_FILES = [
|
|
16
16
|
'package/lib/buffer_pool.js',
|
17
17
|
'package/lib/clientEncryption.js',
|
18
18
|
'package/lib/common.js',
|
19
|
-
'package/lib/
|
19
|
+
'package/lib/providers/index.js',
|
20
|
+
'package/lib/providers/gcp.js',
|
21
|
+
'package/lib/providers/aws.js',
|
22
|
+
'package/lib/providers/azure.js',
|
23
|
+
'package/lib/providers/utils.js',
|
20
24
|
'package/lib/cryptoCallbacks.js',
|
25
|
+
'package/lib/errors.js',
|
21
26
|
'package/lib/mongocryptdManager.js',
|
22
27
|
'package/lib/stateMachine.js',
|
23
28
|
'package/LICENSE',
|
@@ -27,7 +32,9 @@ const REQUIRED_FILES = [
|
|
27
32
|
'package/src/mongocrypt.h'
|
28
33
|
];
|
29
34
|
|
30
|
-
describe(`Release ${packFile}`, ()
|
35
|
+
describe(`Release ${packFile}`, function () {
|
36
|
+
this.timeout(5000);
|
37
|
+
|
31
38
|
let tarFileList;
|
32
39
|
before(() => {
|
33
40
|
expect(fs.existsSync(packFile)).to.equal(false);
|