libmongocrypt-helper 1.7.4.0.1002 → 1.8.0.0.1001

Sign up to get free protection for your applications and to get access to all the features.
Files changed (396) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/ext/libmongocrypt/libmongocrypt/CHANGELOG.md +9 -7
  4. data/ext/libmongocrypt/libmongocrypt/CMakeLists.txt +17 -23
  5. data/ext/libmongocrypt/libmongocrypt/Earthfile +374 -0
  6. data/ext/libmongocrypt/libmongocrypt/README.md +7 -7
  7. data/ext/libmongocrypt/libmongocrypt/VERSION_CURRENT +1 -1
  8. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/CryptClient.cs +25 -6
  9. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt/Library.cs +25 -3
  10. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Example/MongoDB.Libmongocrypt.Example.csproj +1 -1
  11. data/ext/libmongocrypt/libmongocrypt/bindings/cs/MongoDB.Libmongocrypt.Test/BasicTests.cs +1 -1
  12. data/ext/libmongocrypt/libmongocrypt/bindings/cs/Scripts/build.cake +3 -2
  13. data/ext/libmongocrypt/libmongocrypt/bindings/cs/cs.sln +79 -0
  14. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/build.gradle.kts +2 -2
  15. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/java/com/mongodb/crypt/capi/MongoCryptTest.java +6 -4
  16. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit-v2/int32/encrypted-payload.json +26 -0
  17. data/ext/libmongocrypt/libmongocrypt/bindings/node/CHANGELOG.md +24 -0
  18. data/ext/libmongocrypt/libmongocrypt/bindings/node/README.md +134 -5
  19. data/ext/libmongocrypt/libmongocrypt/bindings/node/etc/build-static.sh +3 -6
  20. data/ext/libmongocrypt/libmongocrypt/bindings/node/index.d.ts +203 -77
  21. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/autoEncrypter.js +1 -1
  22. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/clientEncryption.js +165 -43
  23. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/common.js +12 -14
  24. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/errors.js +75 -0
  25. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/index.js +34 -3
  26. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/aws.js +26 -0
  27. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/azure.js +178 -0
  28. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/gcp.js +24 -0
  29. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/index.js +54 -0
  30. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/providers/utils.js +39 -0
  31. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/stateMachine.js +9 -4
  32. data/ext/libmongocrypt/libmongocrypt/bindings/node/package-lock.json +4440 -5189
  33. data/ext/libmongocrypt/libmongocrypt/bindings/node/package.json +27 -8
  34. data/ext/libmongocrypt/libmongocrypt/bindings/node/src/mongocrypt.cc +65 -38
  35. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/autoEncrypter.test.js +4 -7
  36. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/clientEncryption.test.js +434 -42
  37. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/common.test.js +94 -0
  38. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/cryptoCallbacks.test.js +1 -45
  39. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/index.test.js +45 -0
  40. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/mongocryptdManager.test.js +1 -1
  41. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/providers/credentialsProvider.test.js +551 -0
  42. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/release.test.js +10 -3
  43. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/requirements.helper.js +23 -1
  44. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/stateMachine.test.js +1 -1
  45. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/tools/chai-addons.js +8 -0
  46. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/types/index.test-d.ts +63 -0
  47. data/ext/libmongocrypt/libmongocrypt/bindings/python/CHANGELOG.rst +26 -0
  48. data/ext/libmongocrypt/libmongocrypt/bindings/python/README.rst +2 -2
  49. data/ext/libmongocrypt/libmongocrypt/bindings/python/build-manylinux-wheel.sh +1 -1
  50. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binding.py +128 -238
  51. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/compat.py +0 -27
  52. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/explicit_encrypter.py +1 -1
  53. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/mongocrypt.py +5 -21
  54. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/version.py +2 -2
  55. data/ext/libmongocrypt/libmongocrypt/bindings/python/release.sh +5 -5
  56. data/ext/libmongocrypt/libmongocrypt/bindings/python/setup.py +14 -9
  57. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/__init__.py +1 -10
  58. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit-v2/int32/encrypted-payload.json +26 -0
  59. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_mongocrypt.py +5 -5
  60. data/ext/libmongocrypt/libmongocrypt/bindings/python/test-requirements.txt +4 -12
  61. data/ext/libmongocrypt/libmongocrypt/cmake/ImportBSON.cmake +8 -6
  62. data/ext/libmongocrypt/libmongocrypt/cmake/IntelDFP.cmake +2 -1
  63. data/ext/libmongocrypt/libmongocrypt/cmake/Platform.cmake +50 -0
  64. data/ext/libmongocrypt/libmongocrypt/cmake/mongocrypt-config.cmake +21 -0
  65. data/ext/libmongocrypt/libmongocrypt/debian/gbp.conf +2 -2
  66. data/ext/libmongocrypt/libmongocrypt/etc/c6-vault.repo +39 -0
  67. data/ext/libmongocrypt/libmongocrypt/etc/fle2_aead_generate_tests.py +15 -24
  68. data/ext/libmongocrypt/libmongocrypt/etc/fle2_crypto.py +66 -54
  69. data/ext/libmongocrypt/libmongocrypt/etc/fle2_generate_tests.py +14 -23
  70. data/ext/libmongocrypt/libmongocrypt/etc/fle2v2_aead_generate_tests.py +32 -0
  71. data/ext/libmongocrypt/libmongocrypt/etc/format-all.sh +12 -0
  72. data/ext/libmongocrypt/libmongocrypt/etc/format.sh +16 -0
  73. data/ext/libmongocrypt/libmongocrypt/etc/install-package.sh +48 -0
  74. data/ext/libmongocrypt/libmongocrypt/etc/mongo-inteldfp-libmongocrypt-pr-625.patch +13 -0
  75. data/ext/libmongocrypt/libmongocrypt/src/crypto/cng.c +381 -436
  76. data/ext/libmongocrypt/libmongocrypt/src/crypto/commoncrypto.c +162 -227
  77. data/ext/libmongocrypt/libmongocrypt/src/crypto/libcrypto.c +180 -248
  78. data/ext/libmongocrypt/libmongocrypt/src/crypto/none.c +33 -55
  79. data/ext/libmongocrypt/libmongocrypt/src/csfle-markup.cpp +175 -205
  80. data/ext/libmongocrypt/libmongocrypt/src/mc-array-private.h +10 -21
  81. data/ext/libmongocrypt/libmongocrypt/src/mc-array.c +44 -56
  82. data/ext/libmongocrypt/libmongocrypt/src/mc-check-conversions-private.h +4 -8
  83. data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.h +351 -463
  84. data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.test.cpp +59 -66
  85. data/ext/libmongocrypt/libmongocrypt/src/mc-efc-private.h +7 -11
  86. data/ext/libmongocrypt/libmongocrypt/src/mc-efc.c +80 -92
  87. data/ext/libmongocrypt/libmongocrypt/src/mc-fle-blob-subtype-private.h +18 -10
  88. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder-private.h +59 -70
  89. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder.c +384 -439
  90. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private-v2.h +41 -0
  91. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-private.h +11 -18
  92. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-v2.c +135 -0
  93. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload.c +109 -126
  94. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private-v2.h +88 -0
  95. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private.h +24 -27
  96. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-v2.c +137 -0
  97. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload.c +106 -125
  98. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private-v2.h +117 -0
  99. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private.h +28 -36
  100. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-v2.c +294 -0
  101. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload.c +237 -278
  102. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-private-v2.h +133 -0
  103. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-private.h +67 -56
  104. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-v2.c +437 -0
  105. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev.c +476 -325
  106. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-common-private.h +69 -0
  107. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-common.c +182 -0
  108. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-private.h +23 -31
  109. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-v2-private.h +85 -0
  110. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-v2.c +142 -0
  111. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev.c +104 -231
  112. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-range-operator-private.h +8 -7
  113. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds-private.h +55 -56
  114. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds.c +517 -580
  115. data/ext/libmongocrypt/libmongocrypt/src/mc-optional-private.h +36 -66
  116. data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation-private.h +57 -76
  117. data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation.c +158 -189
  118. data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding-private.h +36 -42
  119. data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding.c +515 -558
  120. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-generator.template.h +155 -191
  121. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-private.h +43 -53
  122. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover.c +170 -240
  123. data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts-private.h +29 -34
  124. data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts.c +289 -338
  125. data/ext/libmongocrypt/libmongocrypt/src/mc-reader-private.h +36 -71
  126. data/ext/libmongocrypt/libmongocrypt/src/mc-reader.c +111 -164
  127. data/ext/libmongocrypt/libmongocrypt/src/mc-tokens-private.h +55 -49
  128. data/ext/libmongocrypt/libmongocrypt/src/mc-tokens.c +109 -125
  129. data/ext/libmongocrypt/libmongocrypt/src/mc-writer-private.h +66 -0
  130. data/ext/libmongocrypt/libmongocrypt/src/mc-writer.c +141 -0
  131. data/ext/libmongocrypt/libmongocrypt/src/mlib/check.hpp +37 -55
  132. data/ext/libmongocrypt/libmongocrypt/src/mlib/endian.h +11 -11
  133. data/ext/libmongocrypt/libmongocrypt/src/mlib/error.h +27 -32
  134. data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.h +444 -499
  135. data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.test.cpp +251 -334
  136. data/ext/libmongocrypt/libmongocrypt/src/mlib/macros.h +4 -5
  137. data/ext/libmongocrypt/libmongocrypt/src/mlib/path.h +196 -231
  138. data/ext/libmongocrypt/libmongocrypt/src/mlib/path.test.c +56 -79
  139. data/ext/libmongocrypt/libmongocrypt/src/mlib/str.h +411 -530
  140. data/ext/libmongocrypt/libmongocrypt/src/mlib/str.test.c +116 -131
  141. data/ext/libmongocrypt/libmongocrypt/src/mlib/thread.h +17 -26
  142. data/ext/libmongocrypt/libmongocrypt/src/mlib/user-check.h +2 -2
  143. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary-private.h +3 -6
  144. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-binary.c +31 -48
  145. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer-private.h +55 -131
  146. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer.c +444 -565
  147. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo-private.h +1 -2
  148. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo.c +28 -45
  149. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key-private.h +11 -17
  150. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-key.c +103 -132
  151. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth-private.h +8 -14
  152. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-oauth.c +78 -90
  153. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-private.h +26 -45
  154. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache.c +220 -273
  155. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext-private.h +13 -25
  156. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext.c +147 -166
  157. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-compat.h +2 -2
  158. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto-private.h +110 -204
  159. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto.c +1137 -1565
  160. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-datakey.c +425 -472
  161. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-decrypt.c +817 -694
  162. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-encrypt.c +2394 -2697
  163. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-private.h +166 -186
  164. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-rewrap-many-datakey.c +308 -351
  165. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx.c +921 -1138
  166. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-dll-private.h +16 -24
  167. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endian-private.h +44 -58
  168. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint-private.h +21 -25
  169. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-endpoint.c +167 -181
  170. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek-private.h +37 -43
  171. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kek.c +215 -253
  172. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker-private.h +73 -108
  173. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker.c +889 -1034
  174. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-private.h +27 -44
  175. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key.c +349 -402
  176. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx-private.h +92 -120
  177. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx.c +1397 -1612
  178. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log-private.h +35 -67
  179. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-log.c +49 -83
  180. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking-private.h +30 -36
  181. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking.c +1821 -1470
  182. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-mutex-private.h +7 -12
  183. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts-private.h +80 -108
  184. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts.c +354 -424
  185. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-private.h +101 -117
  186. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status-private.h +3 -8
  187. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-status.c +92 -119
  188. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util-private.h +19 -29
  189. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util.c +136 -176
  190. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util-private.h +11 -21
  191. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util.c +96 -135
  192. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.c +1092 -1320
  193. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.h +130 -295
  194. data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_dll.c +66 -78
  195. data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_mutex.c +20 -28
  196. data/ext/libmongocrypt/libmongocrypt/src/os_win/os_dll.c +60 -73
  197. data/ext/libmongocrypt/libmongocrypt/src/os_win/os_mutex.c +8 -16
  198. data/ext/libmongocrypt/libmongocrypt/test/crypt_shared-stub.cpp +57 -87
  199. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/encrypted-payload-v2.json +60 -0
  200. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/encrypted-payload-v2.json +67 -0
  201. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/encrypted-payload.json +2 -2
  202. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed-contentionFactor1-v2.json +8 -0
  203. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed-v2.json +8 -0
  204. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-contentionFactor1-v2.json +8 -0
  205. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-same-user-and-index-key-v2.json +8 -0
  206. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-v2.json +8 -0
  207. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/cmd.json +6 -0
  208. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/encrypted-field-map.json +22 -0
  209. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/encrypted-payload.json +40 -0
  210. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality-v2/mongocryptd-reply.json +19 -0
  211. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/cmd.json +10 -0
  212. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-field-map.json +27 -0
  213. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-payload.json +41 -0
  214. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/mongocryptd-reply.json +49 -0
  215. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/cmd.json +6 -0
  216. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-field-map.json +30 -0
  217. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-payload.json +50 -0
  218. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/mongocryptd-reply.json +58 -0
  219. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/cmd.json +6 -0
  220. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-field-map.json +27 -0
  221. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-payload.json +41 -0
  222. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/mongocryptd-reply.json +49 -0
  223. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/cmd.json +8 -0
  224. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/encrypted-field-map.json +30 -0
  225. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/encrypted-payload.json +44 -0
  226. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/mongocryptd-reply.json +52 -0
  227. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/cmd.json +8 -0
  228. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-field-map.json +27 -0
  229. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-payload.json +41 -0
  230. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/mongocryptd-reply.json +49 -0
  231. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/cmd.json +8 -0
  232. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-field-map.json +27 -0
  233. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-payload.json +41 -0
  234. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/mongocryptd-reply.json +49 -0
  235. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/cmd.json +8 -0
  236. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-field-map.json +27 -0
  237. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-payload.json +41 -0
  238. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/mongocryptd-reply.json +49 -0
  239. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double/encrypted-payload-v2.json +26 -0
  240. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double-precision/encrypted-payload-v2.json +26 -0
  241. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32/encrypted-payload-v2.json +26 -0
  242. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/encrypted-payload-v2.json +26 -0
  243. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-openinterval/encrypted-payload-v2.json +16 -0
  244. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert/cmd.json +1 -1
  245. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/RNG_DATA.h +65 -65
  246. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/cmd.json +13 -0
  247. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-field-map.json +27 -0
  248. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-payload.json +44 -0
  249. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/mongocryptd-reply.json +52 -0
  250. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/RNG_DATA.h +132 -132
  251. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/RNG_DATA.h +71 -71
  252. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/cmd.json +9 -0
  253. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-field-map.json +30 -0
  254. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-payload.json +53 -0
  255. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/mongocryptd-reply.json +61 -0
  256. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/cmd.json +9 -0
  257. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-field-map.json +27 -0
  258. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-payload.json +44 -0
  259. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/mongocryptd-reply.json +52 -0
  260. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/RNG_DATA.h +68 -68
  261. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/RNG_DATA.h +19 -19
  262. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/cmd.json +11 -0
  263. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/encrypted-field-map.json +30 -0
  264. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/encrypted-payload.json +47 -0
  265. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/mongocryptd-reply.json +55 -0
  266. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/cmd.json +11 -0
  267. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-field-map.json +27 -0
  268. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-payload.json +44 -0
  269. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/mongocryptd-reply.json +52 -0
  270. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32/RNG_DATA.h +25 -25
  271. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/cmd.json +11 -0
  272. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-field-map.json +27 -0
  273. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-payload.json +44 -0
  274. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/mongocryptd-reply.json +52 -0
  275. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/RNG_DATA.h +65 -65
  276. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/cmd.json +11 -0
  277. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-field-map.json +27 -0
  278. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-payload.json +44 -0
  279. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/mongocryptd-reply.json +52 -0
  280. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/RNG_DATA.h +68 -68
  281. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/encrypted-payload-v2.json +8 -0
  282. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/RNG_DATA.h +19 -19
  283. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/encrypted-payload-v2.json +8 -0
  284. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/RNG_DATA.h +25 -25
  285. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/encrypted-payload-v2.json +8 -0
  286. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/encrypted-payload-v2.json +8 -0
  287. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/RNG_DATA.h +15 -15
  288. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/encrypted-payload-v2.json +8 -0
  289. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/cmd.json +9 -0
  290. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/encrypted-field-map.json +18 -0
  291. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/encrypted-payload.json +14 -0
  292. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed-v2/mongocryptd-reply.json +41 -0
  293. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/cmd.json +9 -0
  294. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/encrypted-field-map.json +22 -0
  295. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/encrypted-payload.json +39 -0
  296. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2/mongocryptd-reply.json +49 -0
  297. data/ext/libmongocrypt/libmongocrypt/test/data/iev-v2/FLECrudTest-insertOneRangeV2.json +10 -0
  298. data/ext/libmongocrypt/libmongocrypt/test/data/iev-v2/FLECrudTest-insertOneV2.json +10 -0
  299. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/README.md +17 -0
  300. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/aes-ctr.json +29 -0
  301. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2-fixed.json +10 -0
  302. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2-generated.json +38 -0
  303. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-decrypt.json +35 -0
  304. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-fixed.json +29 -0
  305. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2aead-generated.json +122 -0
  306. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2v2-aead-fixed.json +29 -0
  307. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/fle2v2-aead-generated.json +122 -0
  308. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/mcgrew.json +12 -0
  309. data/ext/libmongocrypt/libmongocrypt/test/data/roundtrip/nist.json +20 -0
  310. data/ext/libmongocrypt/libmongocrypt/test/data/tokens/README.md +27 -0
  311. data/ext/libmongocrypt/libmongocrypt/test/data/tokens/mc.json +21 -0
  312. data/ext/libmongocrypt/libmongocrypt/test/data/tokens/server.json +21 -0
  313. data/ext/libmongocrypt/libmongocrypt/test/example-no-bson.c +4 -4
  314. data/ext/libmongocrypt/libmongocrypt/test/example-state-machine.c +278 -323
  315. data/ext/libmongocrypt/libmongocrypt/test/fuzz_kms.c +8 -7
  316. data/ext/libmongocrypt/libmongocrypt/test/test-dll.cpp +6 -7
  317. data/ext/libmongocrypt/libmongocrypt/test/test-gcp-auth.c +221 -283
  318. data/ext/libmongocrypt/libmongocrypt/test/test-mc-efc.c +58 -73
  319. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-equality-payload-v2.c +78 -0
  320. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-range-payload-v2.c +89 -0
  321. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev-v2.c +248 -0
  322. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev.c +467 -414
  323. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup-v2.c +172 -0
  324. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup.c +141 -159
  325. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-uev-v2.c +338 -0
  326. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-uev.c +238 -176
  327. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-rfds.c +373 -474
  328. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-edge-generation.c +346 -388
  329. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-encoding.c +708 -825
  330. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-mincover.c +417 -481
  331. data/ext/libmongocrypt/libmongocrypt/test/test-mc-rangeopts.c +110 -144
  332. data/ext/libmongocrypt/libmongocrypt/test/test-mc-reader.c +124 -207
  333. data/ext/libmongocrypt/libmongocrypt/test/test-mc-tokens.c +223 -213
  334. data/ext/libmongocrypt/libmongocrypt/test/test-mc-writer.c +176 -0
  335. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.c +634 -807
  336. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.h +1 -2
  337. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert.h +168 -189
  338. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-buffer.c +187 -211
  339. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache-oauth.c +34 -36
  340. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache.c +210 -233
  341. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ciphertext.c +185 -220
  342. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-compact.c +331 -445
  343. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-hooks.c +670 -814
  344. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.c +102 -135
  345. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.h +54 -71
  346. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto.c +394 -846
  347. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-csfle-lib.c +159 -183
  348. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-decrypt.c +867 -1045
  349. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-encrypt.c +4349 -4713
  350. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-rewrap-many-datakey.c +750 -964
  351. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-setopt.c +991 -1178
  352. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-datakey.c +342 -419
  353. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-dll.c +23 -30
  354. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-endpoint.c +98 -111
  355. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kek.c +49 -52
  356. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-broker.c +770 -920
  357. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-cache.c +354 -407
  358. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key.c +197 -245
  359. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-ctx.c +286 -370
  360. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-responses.c +147 -166
  361. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-local-kms.c +50 -61
  362. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-log.c +85 -100
  363. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-marking.c +656 -692
  364. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-status.c +46 -58
  365. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-traverse-util.c +377 -451
  366. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.c +48 -67
  367. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-util.h +4 -10
  368. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.c +827 -918
  369. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.h +111 -172
  370. data/ext/libmongocrypt/libmongocrypt/test/util/csfle.c +508 -559
  371. data/ext/libmongocrypt/libmongocrypt/test/util/util.c +735 -881
  372. data/ext/libmongocrypt/libmongocrypt/test/util/util.h +33 -55
  373. data/lib/libmongocrypt_helper/version.rb +2 -2
  374. data.tar.gz.sig +0 -0
  375. metadata +154 -26
  376. metadata.gz.sig +0 -0
  377. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/encrypted-payload.json +0 -26
  378. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit/int32/key-document.json +0 -0
  379. data/ext/libmongocrypt/libmongocrypt/bindings/node/lib/credentialsProvider.js +0 -33
  380. data/ext/libmongocrypt/libmongocrypt/bindings/node/test/credentialsProvider.test.js +0 -163
  381. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/fle2-find-range-explicit/int32/encrypted-payload.json +0 -26
  382. data/ext/libmongocrypt/libmongocrypt/test/data/aes-ctr.cstructs +0 -359
  383. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-aead.cstructs +0 -109
  384. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/encrypted-payload.json +0 -26
  385. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/rangeopts.json +0 -5
  386. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/value-to-encrypt.json +0 -20
  387. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/RNG_DATA.h +0 -70
  388. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/encrypted-payload.json +0 -8
  389. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/rangeopts.json +0 -5
  390. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/value-to-encrypt.json +0 -5
  391. data/ext/libmongocrypt/libmongocrypt/test/data/fle2.cstructs +0 -33
  392. /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
  393. /data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/rangeopts.json +0 -0
  394. /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
  395. /data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/{fle2-find-range-explicit → fle2-find-range-explicit-v2}/int32/rangeopts.json +0 -0
  396. /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,6 +1,6 @@
1
1
  'use strict';
2
2
  const fs = require('fs');
3
- const expect = require('chai').expect;
3
+ const { expect } = require('chai');
4
4
  const sinon = require('sinon');
5
5
  const mongodb = require('mongodb');
6
6
  const BSON = mongodb.BSON;
@@ -9,6 +9,10 @@ const cryptoCallbacks = require('../lib/cryptoCallbacks');
9
9
  const stateMachine = require('../lib/stateMachine')({ mongodb });
10
10
  const StateMachine = stateMachine.StateMachine;
11
11
  const { Binary, EJSON, deserialize } = BSON;
12
+ const {
13
+ MongoCryptCreateEncryptedCollectionError,
14
+ MongoCryptCreateDataKeyError
15
+ } = require('../lib/errors');
12
16
 
13
17
  function readHttpResponse(path) {
14
18
  let data = fs.readFileSync(path, 'utf8').toString();
@@ -27,12 +31,20 @@ class MockClient {
27
31
  bson: BSON
28
32
  };
29
33
  }
34
+ db(dbName) {
35
+ return {
36
+ async createCollection(name, options) {
37
+ return { namespace: `${dbName}.${name}`, options };
38
+ }
39
+ };
40
+ }
30
41
  }
31
42
 
32
43
  const requirements = require('./requirements.helper');
33
44
 
34
45
  describe('ClientEncryption', function () {
35
46
  this.timeout(12000);
47
+ /** @type {MongoClient} */
36
48
  let client;
37
49
 
38
50
  function throwIfNotNsNotFoundError(err) {
@@ -42,10 +54,7 @@ describe('ClientEncryption', function () {
42
54
  }
43
55
 
44
56
  async function setup() {
45
- client = new MongoClient('mongodb://localhost:27017/test', {
46
- useNewUrlParser: true,
47
- useUnifiedTopology: true
48
- });
57
+ client = new MongoClient(process.env.MONGODB_URI || 'mongodb://localhost:27017/test');
49
58
  await client.connect();
50
59
  try {
51
60
  await client.db('client').collection('encryption').drop();
@@ -202,7 +211,7 @@ describe('ClientEncryption', function () {
202
211
  options: { masterKey: { region: 'region', key: 'cmk' } }
203
212
  }
204
213
  ].forEach(providerTest => {
205
- it(`should create a data key with the "${providerTest.name}" KMS provider`, function (done) {
214
+ it(`should create a data key with the "${providerTest.name}" KMS provider`, async function () {
206
215
  const providerName = providerTest.name;
207
216
  const encryption = new ClientEncryption(client, {
208
217
  keyVaultNamespace: 'client.encryption',
@@ -210,24 +219,16 @@ describe('ClientEncryption', function () {
210
219
  });
211
220
 
212
221
  const dataKeyOptions = providerTest.options || {};
213
- encryption.createDataKey(providerName, dataKeyOptions, (err, dataKey) => {
214
- expect(err).to.not.exist;
215
- expect(dataKey._bsontype).to.equal('Binary');
216
-
217
- client
218
- .db('client')
219
- .collection('encryption')
220
- .findOne({ _id: dataKey }, (err, doc) => {
221
- expect(err).to.not.exist;
222
- expect(doc).to.have.property('masterKey');
223
- expect(doc.masterKey).to.have.property('provider');
224
- expect(doc.masterKey.provider).to.eql(providerName);
225
- done();
226
- });
227
- });
222
+
223
+ const dataKey = await encryption.createDataKey(providerName, dataKeyOptions);
224
+ expect(dataKey).property('_bsontype', 'Binary');
225
+
226
+ const doc = await client.db('client').collection('encryption').findOne({ _id: dataKey });
227
+ expect(doc).to.have.property('masterKey');
228
+ expect(doc.masterKey).property('provider', providerName);
228
229
  });
229
230
 
230
- it(`should create a data key with the "${providerTest.name}" KMS provider (fixed key material)`, function (done) {
231
+ it(`should create a data key with the "${providerTest.name}" KMS provider (fixed key material)`, async function () {
231
232
  const providerName = providerTest.name;
232
233
  const encryption = new ClientEncryption(client, {
233
234
  keyVaultNamespace: 'client.encryption',
@@ -238,21 +239,13 @@ describe('ClientEncryption', function () {
238
239
  ...providerTest.options,
239
240
  keyMaterial: new BSON.Binary(Buffer.alloc(96))
240
241
  };
241
- encryption.createDataKey(providerName, dataKeyOptions, (err, dataKey) => {
242
- expect(err).to.not.exist;
243
- expect(dataKey._bsontype).to.equal('Binary');
244
-
245
- client
246
- .db('client')
247
- .collection('encryption')
248
- .findOne({ _id: dataKey }, (err, doc) => {
249
- expect(err).to.not.exist;
250
- expect(doc).to.have.property('masterKey');
251
- expect(doc.masterKey).to.have.property('provider');
252
- expect(doc.masterKey.provider).to.eql(providerName);
253
- done();
254
- });
255
- });
242
+
243
+ const dataKey = await encryption.createDataKey(providerName, dataKeyOptions);
244
+ expect(dataKey).property('_bsontype', 'Binary');
245
+
246
+ const doc = await client.db('client').collection('encryption').findOne({ _id: dataKey });
247
+ expect(doc).to.have.property('masterKey');
248
+ expect(doc.masterKey).property('provider', providerName);
256
249
  });
257
250
  });
258
251
 
@@ -514,7 +507,7 @@ describe('ClientEncryption', function () {
514
507
  beforeEach(function () {
515
508
  if (requirements.SKIP_AWS_TESTS) {
516
509
  this.currentTest.skipReason = `requirements.SKIP_AWS_TESTS=${requirements.SKIP_AWS_TESTS}`;
517
- this.skip();
510
+ this.currentTest.skip();
518
511
  return;
519
512
  }
520
513
 
@@ -683,10 +676,6 @@ describe('ClientEncryption', function () {
683
676
  .then(encrypted => {
684
677
  expect(encrypted._bsontype).to.equal('Binary');
685
678
  expect(encrypted.sub_type).to.equal(6);
686
- expect(encrypted.toString('base64')).to.equal(
687
- 'BqvN76sSNJh2EjQSNFZ4kBICTQaVZPWgXp41I7mPV1rLFTtw1tXzjcdSEyxpKKqujlko5TeizkB9hHQ009dVY1+fgIiDcefh+eQrm3CkhQ=='
688
- );
689
-
690
679
  return encryption.decrypt(encrypted);
691
680
  })
692
681
  .then(decrypted => {
@@ -695,7 +684,410 @@ describe('ClientEncryption', function () {
695
684
  });
696
685
  });
697
686
 
687
+ describe('encrypt()', function () {
688
+ let clientEncryption;
689
+ let completeOptions;
690
+ let dataKey;
691
+
692
+ beforeEach(async function () {
693
+ if (requirements.SKIP_LIVE_TESTS) {
694
+ this.currentTest.skipReason = `requirements.SKIP_LIVE_TESTS=${requirements.SKIP_LIVE_TESTS}`;
695
+ this.test.skip();
696
+ return;
697
+ }
698
+
699
+ await setup();
700
+ clientEncryption = new ClientEncryption(client, {
701
+ keyVaultNamespace: 'client.encryption',
702
+ kmsProviders: { local: { key: Buffer.alloc(96) } }
703
+ });
704
+
705
+ dataKey = await clientEncryption.createDataKey('local', {
706
+ name: 'local',
707
+ kmsProviders: { local: { key: Buffer.alloc(96) } }
708
+ });
709
+
710
+ completeOptions = {
711
+ algorithm: 'RangePreview',
712
+ contentionFactor: 0,
713
+ rangeOptions: {
714
+ min: new BSON.Long(0),
715
+ max: new BSON.Long(10),
716
+ sparsity: new BSON.Long(1)
717
+ },
718
+ keyId: dataKey
719
+ };
720
+ });
721
+
722
+ afterEach(() => teardown());
723
+
724
+ context('when expressionMode is incorrectly provided as an argument', function () {
725
+ it('overrides the provided option with the correct value for expression mode', async function () {
726
+ const optionsWithExpressionMode = { ...completeOptions, expressionMode: true };
727
+ const result = await clientEncryption.encrypt(
728
+ new mongodb.Long(0),
729
+ optionsWithExpressionMode
730
+ );
731
+
732
+ expect(result).to.be.instanceof(Binary);
733
+ });
734
+ });
735
+ });
736
+
737
+ describe('encryptExpression()', function () {
738
+ let clientEncryption;
739
+ let completeOptions;
740
+ let dataKey;
741
+ const expression = {
742
+ $and: [{ someField: { $gt: 1 } }]
743
+ };
744
+
745
+ beforeEach(async function () {
746
+ if (requirements.SKIP_LIVE_TESTS) {
747
+ this.currentTest.skipReason = `requirements.SKIP_LIVE_TESTS=${requirements.SKIP_LIVE_TESTS}`;
748
+ this.test.skip();
749
+ return;
750
+ }
751
+
752
+ await setup();
753
+ clientEncryption = new ClientEncryption(client, {
754
+ keyVaultNamespace: 'client.encryption',
755
+ kmsProviders: { local: { key: Buffer.alloc(96) } }
756
+ });
757
+
758
+ dataKey = await clientEncryption.createDataKey('local', {
759
+ name: 'local',
760
+ kmsProviders: { local: { key: Buffer.alloc(96) } }
761
+ });
762
+
763
+ completeOptions = {
764
+ algorithm: 'RangePreview',
765
+ queryType: 'rangePreview',
766
+ contentionFactor: 0,
767
+ rangeOptions: {
768
+ min: new BSON.Int32(0),
769
+ max: new BSON.Int32(10),
770
+ sparsity: new BSON.Long(1)
771
+ },
772
+ keyId: dataKey
773
+ };
774
+ });
775
+
776
+ afterEach(() => teardown());
777
+
778
+ it('throws if rangeOptions is not provided', async function () {
779
+ expect(delete completeOptions.rangeOptions).to.be.true;
780
+ const errorOrResult = await clientEncryption
781
+ .encryptExpression(expression, completeOptions)
782
+ .catch(e => e);
783
+
784
+ expect(errorOrResult).to.be.instanceof(TypeError);
785
+ });
786
+
787
+ it('throws if algorithm is not provided', async function () {
788
+ expect(delete completeOptions.algorithm).to.be.true;
789
+ const errorOrResult = await clientEncryption
790
+ .encryptExpression(expression, completeOptions)
791
+ .catch(e => e);
792
+
793
+ expect(errorOrResult).to.be.instanceof(TypeError);
794
+ });
795
+
796
+ it(`throws if algorithm does not equal 'rangePreview'`, async function () {
797
+ completeOptions['algorithm'] = 'equality';
798
+ const errorOrResult = await clientEncryption
799
+ .encryptExpression(expression, completeOptions)
800
+ .catch(e => e);
801
+
802
+ expect(errorOrResult).to.be.instanceof(TypeError);
803
+ });
804
+
805
+ it(`does not throw if algorithm has different casing than 'rangePreview'`, async function () {
806
+ completeOptions['algorithm'] = 'rAnGePrEvIeW';
807
+ const errorOrResult = await clientEncryption
808
+ .encryptExpression(expression, completeOptions)
809
+ .catch(e => e);
810
+
811
+ expect(errorOrResult).not.to.be.instanceof(Error);
812
+ });
813
+
814
+ context('when expressionMode is incorrectly provided as an argument', function () {
815
+ it('overrides the provided option with the correct value for expression mode', async function () {
816
+ const optionsWithExpressionMode = { ...completeOptions, expressionMode: false };
817
+ const result = await clientEncryption.encryptExpression(
818
+ expression,
819
+ optionsWithExpressionMode
820
+ );
821
+
822
+ expect(result).not.to.be.instanceof(Binary);
823
+ });
824
+ });
825
+ });
826
+
698
827
  it('should provide the libmongocrypt version', function () {
699
828
  expect(ClientEncryption.libmongocryptVersion).to.be.a('string');
700
829
  });
830
+
831
+ describe('createEncryptedCollection()', () => {
832
+ /** @type {InstanceType<ClientEncryption>} */
833
+ let clientEncryption;
834
+ const client = new MockClient();
835
+ let db;
836
+ const collectionName = 'secure';
837
+
838
+ beforeEach(async function () {
839
+ clientEncryption = new ClientEncryption(client, {
840
+ keyVaultNamespace: 'client.encryption',
841
+ kmsProviders: { local: { key: Buffer.alloc(96, 0) } }
842
+ });
843
+
844
+ db = client.db('createEncryptedCollectionDb');
845
+ });
846
+
847
+ afterEach(async () => {
848
+ sinon.restore();
849
+ });
850
+
851
+ context('validates input', () => {
852
+ it('throws TypeError if options are omitted', async () => {
853
+ const error = await clientEncryption
854
+ .createEncryptedCollection(db, collectionName)
855
+ .catch(error => error);
856
+ expect(error).to.be.instanceOf(TypeError, /provider/);
857
+ });
858
+
859
+ it('throws TypeError if options.createCollectionOptions are omitted', async () => {
860
+ const error = await clientEncryption
861
+ .createEncryptedCollection(db, collectionName, {})
862
+ .catch(error => error);
863
+ expect(error).to.be.instanceOf(TypeError, /encryptedFields/);
864
+ });
865
+
866
+ it('throws TypeError if options.createCollectionOptions.encryptedFields are omitted', async () => {
867
+ const error = await clientEncryption
868
+ .createEncryptedCollection(db, collectionName, { createCollectionOptions: {} })
869
+ .catch(error => error);
870
+ expect(error).to.be.instanceOf(TypeError, /Cannot read properties/);
871
+ });
872
+ });
873
+
874
+ context('when options.encryptedFields.fields is not an array', () => {
875
+ it('does not generate any encryption keys', async () => {
876
+ const createCollectionSpy = sinon.spy(db, 'createCollection');
877
+ const createDataKeySpy = sinon.spy(clientEncryption, 'createDataKey');
878
+ await clientEncryption.createEncryptedCollection(db, collectionName, {
879
+ createCollectionOptions: { encryptedFields: { fields: 'not an array' } }
880
+ });
881
+
882
+ expect(createDataKeySpy.callCount).to.equal(0);
883
+ const options = createCollectionSpy.getCall(0).args[1];
884
+ expect(options).to.deep.equal({ encryptedFields: { fields: 'not an array' } });
885
+ });
886
+ });
887
+
888
+ context('when options.encryptedFields.fields elements are not objects', () => {
889
+ it('they are passed along to createCollection', async () => {
890
+ const createCollectionSpy = sinon.spy(db, 'createCollection');
891
+ const keyId = new Binary(Buffer.alloc(16, 0));
892
+ const createDataKeyStub = sinon.stub(clientEncryption, 'createDataKey').resolves(keyId);
893
+ await clientEncryption.createEncryptedCollection(db, collectionName, {
894
+ createCollectionOptions: {
895
+ encryptedFields: { fields: ['not an array', { keyId: null }, { keyId: {} }] }
896
+ }
897
+ });
898
+
899
+ expect(createDataKeyStub.callCount).to.equal(1);
900
+ const options = createCollectionSpy.getCall(0).args[1];
901
+ expect(options).to.deep.equal({
902
+ encryptedFields: { fields: ['not an array', { keyId: keyId }, { keyId: {} }] }
903
+ });
904
+ });
905
+ });
906
+
907
+ it('only passes options.masterKey to createDataKey', async () => {
908
+ const masterKey = Symbol('key');
909
+ const createDataKey = sinon
910
+ .stub(clientEncryption, 'createDataKey')
911
+ .resolves(new Binary(Buffer.alloc(16, 0)));
912
+ const result = await clientEncryption.createEncryptedCollection(db, collectionName, {
913
+ provider: 'aws',
914
+ createCollectionOptions: { encryptedFields: { fields: [{}] } },
915
+ masterKey
916
+ });
917
+ expect(result).to.have.property('collection');
918
+ expect(createDataKey).to.have.been.calledOnceWithExactly('aws', { masterKey });
919
+ });
920
+
921
+ context('when createDataKey rejects', () => {
922
+ const customErrorEvil = new Error('evil!');
923
+ const customErrorGood = new Error('good!');
924
+ const keyId = new Binary(Buffer.alloc(16, 0), 4);
925
+ const createCollectionOptions = {
926
+ encryptedFields: { fields: [{}, {}, { keyId: 'cool id!' }, {}] }
927
+ };
928
+ const createDataKeyRejection = async () => {
929
+ const stub = sinon.stub(clientEncryption, 'createDataKey');
930
+ stub.onCall(0).resolves(keyId);
931
+ stub.onCall(1).rejects(customErrorEvil);
932
+ stub.onCall(2).rejects(customErrorGood);
933
+ stub.onCall(4).resolves(keyId);
934
+
935
+ const error = await clientEncryption
936
+ .createEncryptedCollection(db, collectionName, {
937
+ provider: 'local',
938
+ createCollectionOptions
939
+ })
940
+ .catch(error => error);
941
+
942
+ // At least make sure the function did not succeed
943
+ expect(error).to.be.instanceOf(Error);
944
+
945
+ return error;
946
+ };
947
+
948
+ it('throws MongoCryptCreateDataKeyError', async () => {
949
+ const error = await createDataKeyRejection();
950
+ expect(error).to.be.instanceOf(MongoCryptCreateDataKeyError);
951
+ });
952
+
953
+ it('thrown error has a cause set to the first error that was thrown from createDataKey', async () => {
954
+ const error = await createDataKeyRejection();
955
+ expect(error.cause).to.equal(customErrorEvil);
956
+ expect(error.message).to.include(customErrorEvil.message);
957
+ });
958
+
959
+ it('thrown error contains partially filled encryptedFields.fields', async () => {
960
+ const error = await createDataKeyRejection();
961
+ expect(error.encryptedFields).property('fields').that.is.an('array');
962
+ expect(error.encryptedFields.fields).to.have.lengthOf(
963
+ createCollectionOptions.encryptedFields.fields.length
964
+ );
965
+ expect(error.encryptedFields.fields).to.have.nested.property('[0].keyId', keyId);
966
+ expect(error.encryptedFields.fields).to.not.have.nested.property('[1].keyId');
967
+ expect(error.encryptedFields.fields).to.have.nested.property('[2].keyId', 'cool id!');
968
+ });
969
+ });
970
+
971
+ context('when createCollection rejects', () => {
972
+ const customError = new Error('evil!');
973
+ const keyId = new Binary(Buffer.alloc(16, 0), 4);
974
+ const createCollectionRejection = async () => {
975
+ const stubCreateDataKey = sinon.stub(clientEncryption, 'createDataKey');
976
+ stubCreateDataKey.onCall(0).resolves(keyId);
977
+ stubCreateDataKey.onCall(1).resolves(keyId);
978
+ stubCreateDataKey.onCall(2).resolves(keyId);
979
+
980
+ sinon.stub(db, 'createCollection').rejects(customError);
981
+
982
+ const createCollectionOptions = {
983
+ encryptedFields: { fields: [{}, {}, { keyId: 'cool id!' }] }
984
+ };
985
+ const error = await clientEncryption
986
+ .createEncryptedCollection(db, collectionName, {
987
+ provider: 'local',
988
+ createCollectionOptions
989
+ })
990
+ .catch(error => error);
991
+
992
+ // At least make sure the function did not succeed
993
+ expect(error).to.be.instanceOf(Error);
994
+
995
+ return error;
996
+ };
997
+
998
+ it('throws MongoCryptCreateEncryptedCollectionError', async () => {
999
+ const error = await createCollectionRejection();
1000
+ expect(error).to.be.instanceOf(MongoCryptCreateEncryptedCollectionError);
1001
+ });
1002
+
1003
+ it('thrown error has a cause set to the error that was thrown from createCollection', async () => {
1004
+ const error = await createCollectionRejection();
1005
+ expect(error.cause).to.equal(customError);
1006
+ expect(error.message).to.include(customError.message);
1007
+ });
1008
+
1009
+ it('thrown error contains filled encryptedFields.fields', async () => {
1010
+ const error = await createCollectionRejection();
1011
+ expect(error.encryptedFields).property('fields').that.is.an('array');
1012
+ expect(error.encryptedFields.fields).to.have.nested.property('[0].keyId', keyId);
1013
+ expect(error.encryptedFields.fields).to.have.nested.property('[1].keyId', keyId);
1014
+ expect(error.encryptedFields.fields).to.have.nested.property('[2].keyId', 'cool id!');
1015
+ });
1016
+ });
1017
+
1018
+ context('when there are nullish keyIds in the encryptedFields.fields array', function () {
1019
+ it('does not mutate the input fields array when generating data keys', async () => {
1020
+ const encryptedFields = Object.freeze({
1021
+ escCollection: 'esc',
1022
+ eccCollection: 'ecc',
1023
+ ecocCollection: 'ecoc',
1024
+ fields: Object.freeze([
1025
+ Object.freeze({ keyId: false }),
1026
+ Object.freeze({
1027
+ keyId: null,
1028
+ path: 'name',
1029
+ bsonType: 'int',
1030
+ queries: Object.freeze({ contentionFactor: 0 })
1031
+ }),
1032
+ null
1033
+ ])
1034
+ });
1035
+
1036
+ const keyId = new Binary(Buffer.alloc(16, 0), 4);
1037
+ sinon.stub(clientEncryption, 'createDataKey').resolves(keyId);
1038
+
1039
+ const { collection, encryptedFields: resultEncryptedFields } =
1040
+ await clientEncryption.createEncryptedCollection(db, collectionName, {
1041
+ provider: 'local',
1042
+ createCollectionOptions: {
1043
+ encryptedFields
1044
+ }
1045
+ });
1046
+
1047
+ expect(collection).to.have.property('namespace', 'createEncryptedCollectionDb.secure');
1048
+ expect(encryptedFields, 'original encryptedFields should be unmodified').nested.property(
1049
+ 'fields[0].keyId',
1050
+ false
1051
+ );
1052
+ expect(
1053
+ resultEncryptedFields,
1054
+ 'encryptedFields created by helper should have replaced nullish keyId'
1055
+ ).nested.property('fields[1].keyId', keyId);
1056
+ expect(encryptedFields, 'original encryptedFields should be unmodified').nested.property(
1057
+ 'fields[2]',
1058
+ null
1059
+ );
1060
+ });
1061
+
1062
+ it('generates dataKeys for all null keyIds in the fields array', async () => {
1063
+ const encryptedFields = Object.freeze({
1064
+ escCollection: 'esc',
1065
+ eccCollection: 'ecc',
1066
+ ecocCollection: 'ecoc',
1067
+ fields: Object.freeze([
1068
+ Object.freeze({ keyId: null }),
1069
+ Object.freeze({ keyId: null }),
1070
+ Object.freeze({ keyId: null })
1071
+ ])
1072
+ });
1073
+
1074
+ const keyId = new Binary(Buffer.alloc(16, 0), 4);
1075
+ sinon.stub(clientEncryption, 'createDataKey').resolves(keyId);
1076
+
1077
+ const { collection, encryptedFields: resultEncryptedFields } =
1078
+ await clientEncryption.createEncryptedCollection(db, collectionName, {
1079
+ provider: 'local',
1080
+ createCollectionOptions: {
1081
+ encryptedFields
1082
+ }
1083
+ });
1084
+
1085
+ expect(collection).to.have.property('namespace', 'createEncryptedCollectionDb.secure');
1086
+ expect(resultEncryptedFields.fields).to.have.lengthOf(3);
1087
+ expect(resultEncryptedFields.fields.filter(({ keyId }) => keyId === null)).to.have.lengthOf(
1088
+ 0
1089
+ );
1090
+ });
1091
+ });
1092
+ });
701
1093
  });
@@ -0,0 +1,94 @@
1
+ 'use strict';
2
+
3
+ const { expect } = require('chai');
4
+ const maybeCallback = require('../lib/common').maybeCallback;
5
+
6
+ describe('maybeCallback()', () => {
7
+ it('should accept two arguments', () => {
8
+ expect(maybeCallback).to.have.lengthOf(2);
9
+ });
10
+
11
+ describe('when handling an error case', () => {
12
+ it('should pass the error to the callback provided', done => {
13
+ const superPromiseRejection = Promise.reject(new Error('fail'));
14
+ const result = maybeCallback(
15
+ () => superPromiseRejection,
16
+ (error, result) => {
17
+ try {
18
+ expect(result).to.not.exist;
19
+ expect(error).to.be.instanceOf(Error);
20
+ return done();
21
+ } catch (assertionError) {
22
+ return done(assertionError);
23
+ }
24
+ }
25
+ );
26
+ expect(result).to.be.undefined;
27
+ });
28
+
29
+ it('should return the rejected promise to the caller when no callback is provided', async () => {
30
+ const superPromiseRejection = Promise.reject(new Error('fail'));
31
+ const returnedPromise = maybeCallback(() => superPromiseRejection, undefined);
32
+ expect(returnedPromise).to.equal(superPromiseRejection);
33
+ // @ts-expect-error: There is no overload to change the return type not be nullish,
34
+ // and we do not want to add one in fear of making it too easy to neglect adding the callback argument
35
+ const thrownError = await returnedPromise.catch(error => error);
36
+ expect(thrownError).to.be.instanceOf(Error);
37
+ });
38
+
39
+ it('should not modify a rejection error promise', async () => {
40
+ class MyError extends Error {}
41
+ const driverError = Object.freeze(new MyError());
42
+ const rejection = Promise.reject(driverError);
43
+ // @ts-expect-error: There is no overload to change the return type not be nullish,
44
+ // and we do not want to add one in fear of making it too easy to neglect adding the callback argument
45
+ const thrownError = await maybeCallback(() => rejection, undefined).catch(error => error);
46
+ expect(thrownError).to.be.equal(driverError);
47
+ });
48
+
49
+ it('should not modify a rejection error when passed to callback', done => {
50
+ class MyError extends Error {}
51
+ const driverError = Object.freeze(new MyError());
52
+ const rejection = Promise.reject(driverError);
53
+ maybeCallback(
54
+ () => rejection,
55
+ error => {
56
+ try {
57
+ expect(error).to.exist;
58
+ expect(error).to.equal(driverError);
59
+ done();
60
+ } catch (assertionError) {
61
+ done(assertionError);
62
+ }
63
+ }
64
+ );
65
+ });
66
+ });
67
+
68
+ describe('when handling a success case', () => {
69
+ it('should pass the result and undefined error to the callback provided', done => {
70
+ const superPromiseSuccess = Promise.resolve(2);
71
+
72
+ const result = maybeCallback(
73
+ () => superPromiseSuccess,
74
+ (error, result) => {
75
+ try {
76
+ expect(error).to.be.undefined;
77
+ expect(result).to.equal(2);
78
+ done();
79
+ } catch (assertionError) {
80
+ done(assertionError);
81
+ }
82
+ }
83
+ );
84
+ expect(result).to.be.undefined;
85
+ });
86
+
87
+ it('should return the resolved promise to the caller when no callback is provided', async () => {
88
+ const superPromiseSuccess = Promise.resolve(2);
89
+ const result = maybeCallback(() => superPromiseSuccess);
90
+ expect(result).to.equal(superPromiseSuccess);
91
+ expect(await result).to.equal(2);
92
+ });
93
+ });
94
+ });