libmongocrypt-helper 1.12.0.0.1001 → 1.14.0.0.1001

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (648) hide show
  1. checksums.yaml +4 -4
  2. data/ext/libmongocrypt/libmongocrypt/CHANGELOG.md +27 -0
  3. data/ext/libmongocrypt/libmongocrypt/CMakeLists.txt +15 -1
  4. data/ext/libmongocrypt/libmongocrypt/CODEOWNERS +3 -3
  5. data/ext/libmongocrypt/libmongocrypt/CONTRIBUTING.md +14 -0
  6. data/ext/libmongocrypt/libmongocrypt/Earthfile +50 -50
  7. data/ext/libmongocrypt/libmongocrypt/README.md +8 -17
  8. data/ext/libmongocrypt/libmongocrypt/bindings/python/CHANGELOG.rst +13 -0
  9. data/ext/libmongocrypt/libmongocrypt/bindings/python/CONTRIBUTING.md +34 -0
  10. data/ext/libmongocrypt/libmongocrypt/bindings/python/README.rst +1 -1
  11. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/asynchronous/state_machine.py +6 -2
  12. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/binding.py +57 -3
  13. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/mongocrypt.py +40 -0
  14. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/options.py +14 -0
  15. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/synchronous/state_machine.py +6 -2
  16. data/ext/libmongocrypt/libmongocrypt/bindings/python/pymongocrypt/version.py +1 -1
  17. data/ext/libmongocrypt/libmongocrypt/bindings/python/sbom.json +8 -8
  18. data/ext/libmongocrypt/libmongocrypt/bindings/python/scripts/libmongocrypt-version.txt +1 -0
  19. data/ext/libmongocrypt/libmongocrypt/bindings/python/{release.sh → scripts/release.sh} +9 -3
  20. data/ext/libmongocrypt/libmongocrypt/bindings/python/{synchro.py → scripts/synchro.py} +16 -9
  21. data/ext/libmongocrypt/libmongocrypt/bindings/python/scripts/synchro.sh +8 -0
  22. data/ext/libmongocrypt/libmongocrypt/bindings/python/scripts/update-version.sh +27 -0
  23. data/ext/libmongocrypt/libmongocrypt/bindings/python/scripts/update_binding.py +78 -0
  24. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/compact/success/encrypted-field-config-map.json +0 -1
  25. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/data/encrypted-field-config-map.json +0 -2
  26. data/ext/libmongocrypt/libmongocrypt/bindings/python/test/test_mongocrypt.py +26 -11
  27. data/ext/libmongocrypt/libmongocrypt/cmake/FetchMongoC.cmake +4 -2
  28. data/ext/libmongocrypt/libmongocrypt/cmake/ImportBSON.cmake +3 -5
  29. data/ext/libmongocrypt/libmongocrypt/doc/releasing.md +37 -43
  30. data/ext/libmongocrypt/libmongocrypt/etc/calc_release_version.py +39 -13
  31. data/ext/libmongocrypt/libmongocrypt/etc/calc_release_version_selftest.sh +1 -1
  32. data/ext/libmongocrypt/libmongocrypt/etc/cyclonedx.sbom.json +9 -9
  33. data/ext/libmongocrypt/libmongocrypt/etc/format.sh +0 -2
  34. data/ext/libmongocrypt/libmongocrypt/etc/libbson-remove-GCC-diagnostic-in-functions.patch +158 -0
  35. data/ext/libmongocrypt/libmongocrypt/etc/libbson-remove-GCC-diagnostic-pragma.patch +3 -3
  36. data/ext/libmongocrypt/libmongocrypt/etc/purls.txt +1 -1
  37. data/ext/libmongocrypt/libmongocrypt/integrating.md +42 -11
  38. data/ext/libmongocrypt/libmongocrypt/kms-message/CMakeLists.txt +1 -1
  39. data/ext/libmongocrypt/libmongocrypt/kms-message/src/hexlify.c +5 -0
  40. data/ext/libmongocrypt/libmongocrypt/kms-message/src/hexlify.h +1 -1
  41. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_azure_request.c +1 -1
  42. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_crypto_windows.c +2 -2
  43. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_gcp_request.c +1 -1
  44. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_reader_writer.c +4 -2
  45. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_kmip_request.c +1 -2
  46. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message.c +1 -1
  47. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_message_private.h +7 -3
  48. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request.c +4 -4
  49. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request_opt.c +1 -1
  50. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request_str.c +2 -8
  51. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_request_str.h +9 -0
  52. data/ext/libmongocrypt/libmongocrypt/kms-message/src/kms_response_parser.c +0 -1
  53. data/ext/libmongocrypt/libmongocrypt/kms-message/src/sort.c +7 -3
  54. data/ext/libmongocrypt/libmongocrypt/kms-message/src/sort.h +2 -0
  55. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kmip_reader_writer.c +13 -6
  56. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_assert.h +29 -11
  57. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_azure_online.c +3 -3
  58. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_gcp_online.c +4 -4
  59. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_kmip_request.c +4 -0
  60. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_kmip_response.c +3 -0
  61. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_kmip_response_parser.c +4 -0
  62. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_online_util.c +1 -1
  63. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_online_util.h +1 -1
  64. data/ext/libmongocrypt/libmongocrypt/kms-message/test/test_kms_request.c +50 -48
  65. data/ext/libmongocrypt/libmongocrypt/src/crypto/libcrypto.c +235 -65
  66. data/ext/libmongocrypt/libmongocrypt/src/crypto/none.c +1 -1
  67. data/ext/libmongocrypt/libmongocrypt/src/csfle-markup.cpp +4 -2
  68. data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.h +2 -2
  69. data/ext/libmongocrypt/libmongocrypt/src/mc-dec128.test.cpp +2 -2
  70. data/ext/libmongocrypt/libmongocrypt/src/mc-efc-private.h +6 -4
  71. data/ext/libmongocrypt/libmongocrypt/src/mc-efc.c +44 -12
  72. data/ext/libmongocrypt/libmongocrypt/src/mc-fle-blob-subtype-private.h +5 -1
  73. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder-private.h +89 -8
  74. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-encryption-placeholder.c +346 -131
  75. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload-v2.c +6 -18
  76. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-equality-payload.c +6 -18
  77. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-private-v2.h +1 -1
  78. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload-v2.c +25 -26
  79. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-range-payload.c +2 -1
  80. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-text-payload-private.h +122 -0
  81. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-find-text-payload.c +477 -0
  82. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-private-v2.h +35 -3
  83. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload-v2.c +193 -44
  84. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-insert-update-payload.c +6 -18
  85. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-private-v2.h +105 -7
  86. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev-v2.c +386 -74
  87. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-iev.c +13 -10
  88. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-payload-uev-common.c +3 -2
  89. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-rfds.c +7 -6
  90. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-tag-and-encrypted-metadata-block-private.h +7 -2
  91. data/ext/libmongocrypt/libmongocrypt/src/mc-fle2-tag-and-encrypted-metadata-block.c +21 -3
  92. data/ext/libmongocrypt/libmongocrypt/src/mc-optional-private.h +1 -1
  93. data/ext/libmongocrypt/libmongocrypt/{bindings/java/mongocrypt/benchmarks/build.gradle.kts → src/mc-parse-utils-private.h} +10 -11
  94. data/ext/libmongocrypt/libmongocrypt/src/mc-parse-utils.c +48 -0
  95. data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation-private.h +5 -5
  96. data/ext/libmongocrypt/libmongocrypt/src/mc-range-edge-generation.c +15 -20
  97. data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding-private.h +4 -6
  98. data/ext/libmongocrypt/libmongocrypt/src/mc-range-encoding.c +9 -18
  99. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-generator.template.h +4 -5
  100. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover-private.h +5 -9
  101. data/ext/libmongocrypt/libmongocrypt/src/mc-range-mincover.c +14 -19
  102. data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts-private.h +2 -4
  103. data/ext/libmongocrypt/libmongocrypt/src/mc-rangeopts.c +109 -119
  104. data/ext/libmongocrypt/libmongocrypt/src/mc-reader-private.h +2 -2
  105. data/ext/libmongocrypt/libmongocrypt/src/mc-reader.c +4 -2
  106. data/ext/libmongocrypt/libmongocrypt/src/mc-schema-broker-private.h +123 -0
  107. data/ext/libmongocrypt/libmongocrypt/src/mc-schema-broker.c +1065 -0
  108. data/ext/libmongocrypt/libmongocrypt/src/mc-str-encode-string-sets-private.h +95 -0
  109. data/ext/libmongocrypt/libmongocrypt/src/mc-str-encode-string-sets.c +304 -0
  110. data/ext/libmongocrypt/libmongocrypt/src/mc-text-search-str-encode-private.h +52 -0
  111. data/ext/libmongocrypt/libmongocrypt/src/mc-text-search-str-encode.c +324 -0
  112. data/ext/libmongocrypt/libmongocrypt/src/mc-tokens-private.h +130 -2
  113. data/ext/libmongocrypt/libmongocrypt/src/mc-tokens.c +159 -3
  114. data/ext/libmongocrypt/libmongocrypt/src/mc-writer-private.h +1 -1
  115. data/ext/libmongocrypt/libmongocrypt/src/mc-writer.c +4 -2
  116. data/ext/libmongocrypt/libmongocrypt/src/mlib/error.h +1 -1
  117. data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.h +12 -1
  118. data/ext/libmongocrypt/libmongocrypt/src/mlib/int128.test.cpp +5 -0
  119. data/ext/libmongocrypt/libmongocrypt/src/mlib/path.h +5 -5
  120. data/ext/libmongocrypt/libmongocrypt/src/mlib/path.test.c +2 -5
  121. data/ext/libmongocrypt/libmongocrypt/src/mlib/str.h +65 -58
  122. data/ext/libmongocrypt/libmongocrypt/src/mlib/str.test.c +3 -3
  123. data/ext/libmongocrypt/libmongocrypt/src/mlib/thread.h +1 -1
  124. data/ext/libmongocrypt/libmongocrypt/src/mlib/user-check.h +1 -1
  125. data/ext/libmongocrypt/libmongocrypt/src/mlib/windows-lean.h +2 -0
  126. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer-private.h +11 -0
  127. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-buffer.c +36 -3
  128. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo-private.h +1 -1
  129. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-cache-collinfo.c +4 -0
  130. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ciphertext-private.h +1 -1
  131. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto-private.h +4 -4
  132. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-crypto.c +29 -25
  133. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-datakey.c +3 -2
  134. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-decrypt.c +14 -7
  135. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-encrypt.c +463 -900
  136. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-private.h +5 -19
  137. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx-rewrap-many-datakey.c +12 -0
  138. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-ctx.c +5 -13
  139. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-dll-private.h +19 -2
  140. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-key-broker.c +9 -9
  141. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-kms-ctx.c +1 -1
  142. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking-private.h +3 -4
  143. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-marking.c +773 -584
  144. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts-private.h +0 -6
  145. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-opts.c +0 -1
  146. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-private.h +8 -13
  147. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-traverse-util.c +1 -1
  148. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt-util.c +7 -2
  149. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.c +53 -40
  150. data/ext/libmongocrypt/libmongocrypt/src/mongocrypt.h +17 -0
  151. data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_dll.c +5 -1
  152. data/ext/libmongocrypt/libmongocrypt/src/os_posix/os_mutex.c +1 -1
  153. data/ext/libmongocrypt/libmongocrypt/src/os_win/os_dll.c +3 -1
  154. data/ext/libmongocrypt/libmongocrypt/src/os_win/os_mutex.c +1 -1
  155. data/ext/libmongocrypt/libmongocrypt/src/unicode/case-fold-map.c +1434 -0
  156. data/ext/libmongocrypt/libmongocrypt/src/unicode/diacritic-fold-map.c +2884 -0
  157. data/ext/libmongocrypt/libmongocrypt/src/unicode/fold.c +139 -0
  158. data/ext/libmongocrypt/libmongocrypt/src/unicode/fold.h +58 -0
  159. data/ext/libmongocrypt/libmongocrypt/test/crypt_shared-stub.cpp +0 -14
  160. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/unencrypted/payload.json +2 -2
  161. data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/missing-key-id/collinfo.json +1 -0
  162. data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/no-fields/collinfo.json +1 -0
  163. data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/collinfo.json +1 -0
  164. data/ext/libmongocrypt/libmongocrypt/test/data/compact/anchor-pad/collinfo.json +1 -1
  165. data/ext/libmongocrypt/libmongocrypt/test/data/compact/anchor-pad/encrypted-payload-range-v2.json +20 -21
  166. data/ext/libmongocrypt/libmongocrypt/test/data/compact/missing-key-id/collinfo.json +2 -2
  167. data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-fields/collinfo.json +1 -1
  168. data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-range/collinfo.json +1 -1
  169. data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/collinfo.json +1 -1
  170. data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-field-config-map.json +6 -2
  171. data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-payload-range-v2.json +20 -21
  172. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/omitted/cmd-to-mongocryptd.json +1 -2
  173. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/omitted/collinfo.json +2 -2
  174. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/omitted/encrypted-payload.json +2 -3
  175. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/omitted/mongocryptd-reply.json +1 -2
  176. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved/cmd-to-mongocryptd.json +1 -2
  177. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved/collinfo.json +2 -2
  178. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved/encrypted-payload.json +2 -3
  179. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved/mongocryptd-reply.json +1 -2
  180. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_empty/cmd-to-mongocryptd.json +1 -2
  181. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_empty/collinfo.json +2 -2
  182. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_empty/mongocryptd-reply.json +1 -2
  183. data/ext/libmongocrypt/libmongocrypt/test/data/dollardb/preserved_fle1/collinfo.json +2 -1
  184. data/ext/libmongocrypt/libmongocrypt/test/data/efc/efc-extraField.json +0 -1
  185. data/ext/libmongocrypt/libmongocrypt/test/data/efc/efc-missingKeyId.json +0 -1
  186. data/ext/libmongocrypt/libmongocrypt/test/data/efc/efc-oneField-badVersionSet.json +23 -0
  187. data/ext/libmongocrypt/libmongocrypt/test/data/efc/efc-oneField-goodVersionSet.json +23 -0
  188. data/ext/libmongocrypt/libmongocrypt/test/data/efc/efc-oneField.json +0 -1
  189. data/ext/libmongocrypt/libmongocrypt/test/data/efc/efc-textSearchFields-badVersionSet.json +48 -0
  190. data/ext/libmongocrypt/libmongocrypt/test/data/efc/efc-textSearchFields-goodVersionSet.json +48 -0
  191. data/ext/libmongocrypt/libmongocrypt/test/data/efc/efc-textSearchFields.json +47 -0
  192. data/ext/libmongocrypt/libmongocrypt/test/data/efc/efc-twoFields.json +0 -1
  193. data/ext/libmongocrypt/libmongocrypt/test/data/encrypted-field-config-map.json +1 -3
  194. data/ext/libmongocrypt/libmongocrypt/test/data/explicit-decrypt/FLE1DeterministicEncryptedValue.json +8 -0
  195. data/ext/libmongocrypt/libmongocrypt/test/data/explicit-decrypt/FLE1EncryptionPlaceholder.json +8 -0
  196. data/ext/libmongocrypt/libmongocrypt/test/data/explicit-decrypt/FLE1RandomEncryptedValue.json +8 -0
  197. data/ext/libmongocrypt/libmongocrypt/test/data/explicit-decrypt/FLE2EncryptionPlaceholder.json +8 -0
  198. data/ext/libmongocrypt/libmongocrypt/test/data/explicit-decrypt/FLE2FindEqualityPayloadV2.json +8 -0
  199. data/ext/libmongocrypt/libmongocrypt/test/data/explicit-decrypt/FLE2IndexedEqualityEncryptedValue.json +8 -0
  200. data/ext/libmongocrypt/libmongocrypt/test/data/explicit-decrypt/FLE2IndexedEqualityEncryptedValueV2.json +8 -0
  201. data/ext/libmongocrypt/libmongocrypt/test/data/explicit-decrypt/FLE2IndexedRangeEncryptedValue.json +8 -0
  202. data/ext/libmongocrypt/libmongocrypt/test/data/explicit-decrypt/FLE2IndexedRangeEncryptedValueV2.json +8 -0
  203. data/ext/libmongocrypt/libmongocrypt/test/data/explicit-decrypt/FLE2InsertUpdatePayload-RangeV1.json +8 -0
  204. data/ext/libmongocrypt/libmongocrypt/test/data/{fle2-explicit/insert-indexed.json → explicit-decrypt/FLE2InsertUpdatePayload.json} +1 -1
  205. data/ext/libmongocrypt/libmongocrypt/test/data/explicit-decrypt/FLE2InsertUpdatePayloadV2-RangeV1.json +8 -0
  206. data/ext/libmongocrypt/libmongocrypt/test/data/explicit-decrypt/FLE2InsertUpdatePayloadV2-RangeV2.json +8 -0
  207. data/ext/libmongocrypt/libmongocrypt/test/data/explicit-decrypt/FLE2InsertUpdatePayloadV2.json +8 -0
  208. data/ext/libmongocrypt/libmongocrypt/test/data/explicit-decrypt/FLE2UnindexedEncryptedValue.json +8 -0
  209. data/ext/libmongocrypt/libmongocrypt/test/data/explicit-decrypt/FLE2UnindexedEncryptedValueV2.json +8 -0
  210. data/ext/libmongocrypt/libmongocrypt/test/data/find-with-encryptionInformation.json +0 -1
  211. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-explain/with-csfle/collinfo.json +2 -1
  212. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-explain/with-mongocryptd/collinfo.json +2 -1
  213. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-bad-str-encode-version/bad-collinfo.json +26 -0
  214. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-bad-str-encode-version/bad-create-cmd-mongocryptd-reply.json +51 -0
  215. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-bad-str-encode-version/bad-create-cmd-to-mongocryptd.json +45 -0
  216. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-bad-str-encode-version/bad-create-cmd.json +18 -0
  217. data/ext/libmongocrypt/libmongocrypt/test/data/{fle2-find-range/int32/encrypted-field-map.json → fle2-bad-str-encode-version/bad-encrypted-field-config-map.json} +7 -12
  218. data/ext/libmongocrypt/libmongocrypt/test/data/{fle2-insert → fle2-bad-str-encode-version}/encrypted-payload.json +4 -4
  219. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create/cmd-to-mongocryptd.json +1 -2
  220. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create/encrypted-field-config-map.json +1 -2
  221. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create-encrypted-collection/cmd-to-mongocryptd.json +44 -0
  222. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create-encrypted-collection/cmd.json +17 -0
  223. data/ext/libmongocrypt/libmongocrypt/test/data/{fle2-find-equality/encrypted-field-map.json → fle2-create-encrypted-collection/encrypted-field-config-map.json} +9 -8
  224. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create-encrypted-collection/encrypted-payload.json +17 -0
  225. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create-encrypted-collection/mongocryptd-reply.json +50 -0
  226. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create-encrypted-collection-encrypted-fields-unset-str-encode-version/cmd-to-mongocryptd.json +45 -0
  227. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create-encrypted-collection-encrypted-fields-unset-str-encode-version/mongocryptd-reply.json +51 -0
  228. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create-encrypted-collection-with-str-encode-version/cmd-to-mongocryptd.json +46 -0
  229. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create-encrypted-collection-with-str-encode-version/cmd.json +18 -0
  230. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create-encrypted-collection-with-str-encode-version/encrypted-field-config-map.json +25 -0
  231. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create-encrypted-collection-with-str-encode-version/encrypted-payload.json +18 -0
  232. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create-encrypted-collection-with-str-encode-version/mongocryptd-reply.json +52 -0
  233. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/collinfo.json +1 -1
  234. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/encrypted-field-config-map.json +0 -1
  235. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/encrypted-payload-v2.json +57 -59
  236. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/mongocryptd-reply.json +63 -64
  237. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/collinfo.json +1 -1
  238. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/encrypted-field-config-map.json +0 -1
  239. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/encrypted-payload-v2.json +64 -66
  240. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/mongocryptd-reply.json +69 -70
  241. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/collinfo.json +1 -1
  242. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-csfle/encrypted-payload.json +1 -2
  243. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-mongocryptd/cmd-to-mongocryptd.json +1 -2
  244. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-mongocryptd/collinfo.json +2 -2
  245. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-mongocryptd/encrypted-payload.json +2 -3
  246. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explain/with-mongocryptd/mongocryptd-reply.json +1 -2
  247. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-explicit/cmd-to-mongocryptd.json +0 -1
  248. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-explicit/cmd-to-mongod.json +0 -1
  249. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-explicit/reply-from-mongocryptd.json +0 -1
  250. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-field-map.json +1 -1
  251. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/encrypted-payload.json +6 -4
  252. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date-v2/mongocryptd-reply.json +1 -1
  253. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-field-map.json +1 -1
  254. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/encrypted-payload.json +6 -4
  255. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision-v2/mongocryptd-reply.json +2 -2
  256. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-field-map.json +1 -1
  257. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/encrypted-payload.json +6 -4
  258. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-v2/mongocryptd-reply.json +1 -1
  259. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision-v2/encrypted-payload.json +14 -6
  260. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-field-map.json +1 -1
  261. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/encrypted-payload.json +6 -4
  262. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-v2/mongocryptd-reply.json +1 -1
  263. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-field-map.json +1 -1
  264. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/encrypted-payload.json +6 -4
  265. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32-v2/mongocryptd-reply.json +1 -1
  266. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-field-map.json +1 -1
  267. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/encrypted-payload.json +6 -4
  268. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64-v2/mongocryptd-reply.json +1 -1
  269. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double/encrypted-payload-v2.json +1 -1
  270. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double-precision/encrypted-payload-v2.json +1 -1
  271. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32/encrypted-payload-v2.json +1 -1
  272. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-openinterval/encrypted-payload-v2.json +1 -1
  273. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-field-map.json +1 -1
  274. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/encrypted-payload.json +6 -4
  275. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date-v2/mongocryptd-reply.json +1 -1
  276. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-field-map.json +1 -1
  277. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/encrypted-payload.json +6 -4
  278. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision-v2/mongocryptd-reply.json +1 -1
  279. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-field-map.json +1 -1
  280. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/encrypted-payload.json +6 -4
  281. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-v2/mongocryptd-reply.json +1 -1
  282. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision-v2/encrypted-payload.json +14 -6
  283. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-field-map.json +1 -1
  284. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/encrypted-payload.json +6 -4
  285. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-v2/mongocryptd-reply.json +1 -1
  286. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32/encrypted-field-map.json +0 -1
  287. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-field-map.json +1 -1
  288. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/encrypted-payload.json +3 -3
  289. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32-v2/mongocryptd-reply.json +1 -1
  290. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-field-map.json +1 -1
  291. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/encrypted-payload.json +6 -4
  292. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64-v2/mongocryptd-reply.json +1 -1
  293. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/encrypted-payload-v2.json +1 -1
  294. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/encrypted-payload-v2.json +1 -1
  295. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32/encrypted-payload-v2.json +1 -1
  296. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/encrypted-payload-v2.json +1 -1
  297. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-text-search/cmd.json +9 -0
  298. data/ext/libmongocrypt/libmongocrypt/test/data/{fle2-find-range/double → fle2-insert-text-search}/encrypted-field-map.json +10 -9
  299. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-text-search/encrypted-payload.json +47 -0
  300. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-text-search/mongocryptd-reply.json +55 -0
  301. data/ext/libmongocrypt/libmongocrypt/test/data/{fle2-find-range/double-precision → fle2-insert-text-search-with-str-encode-version}/encrypted-field-map.json +12 -13
  302. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-text-search-with-str-encode-version/encrypted-payload.json +47 -0
  303. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-text-search-with-str-encode-version/mongocryptd-reply.json +55 -0
  304. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2-with-str-encode-version/cmd.json +9 -0
  305. data/ext/libmongocrypt/libmongocrypt/test/data/{fle2-insert → fle2-insert-v2-with-str-encode-version}/encrypted-field-map.json +2 -2
  306. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-v2-with-str-encode-version/encrypted-payload.json +40 -0
  307. data/ext/libmongocrypt/libmongocrypt/test/data/{fle2-insert → fle2-insert-v2-with-str-encode-version}/mongocryptd-reply.json +2 -2
  308. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-text-search-create-encrypted-collection/cmd-to-mongocryptd.json +55 -0
  309. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-text-search-create-encrypted-collection/cmd.json +22 -0
  310. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-text-search-create-encrypted-collection/encrypted-field-config-map.json +29 -0
  311. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-text-search-create-encrypted-collection/encrypted-payload.json +23 -0
  312. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-text-search-create-encrypted-collection/mongocryptd-reply.json +61 -0
  313. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-text-search-create-encrypted-collection-with-str-encode-version/cmd-to-mongocryptd.json +56 -0
  314. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-text-search-create-encrypted-collection-with-str-encode-version/cmd.json +23 -0
  315. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-text-search-create-encrypted-collection-with-str-encode-version/encrypted-field-config-map.json +30 -0
  316. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-text-search-create-encrypted-collection-with-str-encode-version/encrypted-payload.json +23 -0
  317. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-text-search-create-encrypted-collection-with-str-encode-version/mongocryptd-reply.json +62 -0
  318. data/ext/libmongocrypt/libmongocrypt/test/data/iev-v2/FLECrudTest-insertOneText.json +20 -0
  319. data/ext/libmongocrypt/libmongocrypt/test/data/iev-v2/FLECrudTest-insertOneTextLarge.json +930 -0
  320. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle/cmd-to-mongocryptd.json +60 -0
  321. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle/cmd.json +14 -0
  322. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle/collInfo-c1.json +39 -0
  323. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle/collInfo-c2.json +39 -0
  324. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle-facet/cmd.json +20 -0
  325. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle-mismatch/cmd.json +14 -0
  326. data/ext/libmongocrypt/libmongocrypt/{bindings/java/mongocrypt/src/test/resources/collection-info.json → test/data/lookup/csfle-mismatch/collInfo-c1.json} +13 -11
  327. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle-mismatch/collInfo-c3.json +39 -0
  328. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle-nested/cmd.json +24 -0
  329. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle-only-schemaMap/cmd-to-mongocryptd.json +60 -0
  330. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle-only-schemaMap/cmd.json +14 -0
  331. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle-only-schemaMap/schemaMap.json +40 -0
  332. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle-schemaMap/cmd-to-mongocryptd.json +60 -0
  333. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle-schemaMap/cmd.json +14 -0
  334. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle-schemaMap/collInfo-c1.json +39 -0
  335. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle-schemaMap/schemaMap.json +21 -0
  336. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle-self/cmd-to-mongocryptd.json +34 -0
  337. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle-self/cmd.json +14 -0
  338. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle-self/collInfo-c1.json +39 -0
  339. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle-sibling/cmd-to-mongocryptd.json +49 -0
  340. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle-sibling/cmd.json +14 -0
  341. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle-sibling/collInfo-c1.json +39 -0
  342. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle-sibling/collInfo-c2.json +29 -0
  343. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle-sibling/reply-from-mongocryptd.json +18 -0
  344. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle-unionWith/cmd.json +21 -0
  345. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle-view/cmd.json +14 -0
  346. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle-view/collInfo-c1.json +39 -0
  347. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/csfle-view/collInfo-v1.json +11 -0
  348. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/csfle/csfle/cmd-to-mongocryptd.json +65 -0
  349. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/csfle/csfle/cmd-to-mongod.json +26 -0
  350. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/csfle/csfle/cmd.json +19 -0
  351. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/csfle/csfle/collInfo-c1.json +39 -0
  352. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/csfle/csfle/collInfo-c2.json +39 -0
  353. data/ext/libmongocrypt/libmongocrypt/{bindings/java/mongocrypt/src/test/resources/keys/ABCDEFAB123498761234123456789012-local-document.json → test/data/lookup/mixed/csfle/csfle/key-doc.json} +4 -4
  354. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/csfle/csfle/reply-from-mongocryptd.json +33 -0
  355. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/csfle/no-schema/cmd-to-mongocryptd.json +47 -0
  356. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/csfle/no-schema/cmd-to-mongod.json +26 -0
  357. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/csfle/no-schema/cmd.json +19 -0
  358. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/csfle/no-schema/collInfo-c1.json +39 -0
  359. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/csfle/no-schema/collInfo-c2.json +17 -0
  360. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/csfle/no-schema/key-doc.json +30 -0
  361. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/csfle/no-schema/reply-from-mongocryptd.json +33 -0
  362. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/csfle/qe/cmd-to-mongocryptd.json +70 -0
  363. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/csfle/qe/cmd.json +19 -0
  364. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/csfle/qe/collInfo-c1.json +39 -0
  365. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/csfle/qe/collInfo-c2.json +42 -0
  366. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/no-schema/csfle/cmd-to-mongocryptd.json +47 -0
  367. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/no-schema/csfle/cmd-to-mongod.json +26 -0
  368. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/no-schema/csfle/cmd.json +19 -0
  369. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/no-schema/csfle/collInfo-c1.json +17 -0
  370. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/no-schema/csfle/collInfo-c2.json +39 -0
  371. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/no-schema/csfle/key-doc.json +30 -0
  372. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/no-schema/csfle/reply-from-mongocryptd.json +33 -0
  373. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/no-schema/no-schema/cmd-to-mongocryptd.json +29 -0
  374. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/no-schema/no-schema/cmd-to-mongod.json +19 -0
  375. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/no-schema/no-schema/cmd.json +19 -0
  376. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/no-schema/no-schema/collInfo-c1.json +17 -0
  377. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/no-schema/no-schema/collInfo-c2.json +17 -0
  378. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/no-schema/no-schema/reply-from-mongocryptd.json +26 -0
  379. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/no-schema/qe/cmd-to-mongocryptd.json +53 -0
  380. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/no-schema/qe/cmd-to-mongod.json +58 -0
  381. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/no-schema/qe/cmd.json +19 -0
  382. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/no-schema/qe/collInfo-c1.json +17 -0
  383. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/no-schema/qe/collInfo-c2.json +42 -0
  384. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/no-schema/qe/key-doc.json +30 -0
  385. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/no-schema/qe/reply-from-mongocryptd.json +65 -0
  386. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/qe/csfle/cmd-to-mongocryptd.json +70 -0
  387. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/qe/csfle/cmd.json +19 -0
  388. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/qe/csfle/collInfo-c1.json +42 -0
  389. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/qe/csfle/collInfo-c2.json +39 -0
  390. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/qe/no-schema/cmd-to-mongocryptd.json +53 -0
  391. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/qe/no-schema/cmd-to-mongod.json +56 -0
  392. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/qe/no-schema/cmd.json +19 -0
  393. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/qe/no-schema/collInfo-c1.json +42 -0
  394. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/qe/no-schema/collInfo-c2.json +17 -0
  395. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/qe/no-schema/key-doc.json +30 -0
  396. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/qe/no-schema/reply-from-mongocryptd.json +63 -0
  397. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/qe/qe/cmd-to-mongocryptd.json +66 -0
  398. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/qe/qe/cmd-to-mongod.json +71 -0
  399. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/qe/qe/cmd.json +19 -0
  400. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/qe/qe/collInfo-c1.json +42 -0
  401. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/qe/qe/collInfo-c2.json +42 -0
  402. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/qe/qe/key-doc.json +30 -0
  403. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/mixed/qe/qe/reply-from-mongocryptd.json +78 -0
  404. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe/cmd-to-mongocryptd.json +61 -0
  405. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe/cmd-to-mongod.json +14 -0
  406. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe/cmd.json +14 -0
  407. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe/collInfo-c1.json +42 -0
  408. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe/collInfo-c2.json +42 -0
  409. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe/reply-from-mongocryptd.json +68 -0
  410. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe-encryptedFieldsMap/cmd-to-mongocryptd.json +66 -0
  411. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe-encryptedFieldsMap/cmd-to-mongod.json +71 -0
  412. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe-encryptedFieldsMap/cmd.json +19 -0
  413. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe-encryptedFieldsMap/collInfo-c1.json +42 -0
  414. data/ext/libmongocrypt/libmongocrypt/test/data/{fle2-insert-unindexed/encrypted-field-map.json → lookup/qe-encryptedFieldsMap/encryptedFieldsMap.json} +6 -7
  415. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe-encryptedFieldsMap/key-doc.json +30 -0
  416. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe-encryptedFieldsMap/reply-from-mongocryptd.json +78 -0
  417. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe-self/cmd-to-mongocryptd.json +46 -0
  418. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe-self/cmd-to-mongod.json +53 -0
  419. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe-self/cmd.json +19 -0
  420. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe-self/collInfo-c1.json +42 -0
  421. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe-self/key-doc.json +30 -0
  422. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe-self/reply-from-mongocryptd.json +58 -0
  423. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe-with-payload/cmd-to-mongocryptd.json +66 -0
  424. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe-with-payload/cmd-to-mongod.json +75 -0
  425. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe-with-payload/cmd.json +19 -0
  426. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe-with-payload/collInfo-c1.json +42 -0
  427. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe-with-payload/collInfo-c2.json +42 -0
  428. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe-with-payload/key-doc.json +30 -0
  429. data/ext/libmongocrypt/libmongocrypt/test/data/lookup/qe-with-payload/reply-from-mongocryptd.json +78 -0
  430. data/ext/libmongocrypt/libmongocrypt/test/data/{fle2-create/mongocryptd-ismaster.json → mongocryptd-ismaster-17.json} +1 -1
  431. data/ext/libmongocrypt/libmongocrypt/test/data/mongocryptd-ismaster-26.json +12 -0
  432. data/ext/libmongocrypt/libmongocrypt/test/data/schema-broker/collinfo-encryptedFields.json +42 -0
  433. data/ext/libmongocrypt/libmongocrypt/test/data/schema-broker/collinfo-encryptedFields2.json +42 -0
  434. data/ext/libmongocrypt/libmongocrypt/test/data/schema-broker/collinfo-jsonSchema.json +43 -0
  435. data/ext/libmongocrypt/libmongocrypt/test/data/schema-broker/collinfo-noSchema.json +21 -0
  436. data/ext/libmongocrypt/libmongocrypt/test/data/schema-broker/create-with-jsonSchema.json +24 -0
  437. data/ext/libmongocrypt/libmongocrypt/test/data/schema-broker/encryptedFields.json +20 -0
  438. data/ext/libmongocrypt/libmongocrypt/test/data/schema-broker/encryptedFields2.json +20 -0
  439. data/ext/libmongocrypt/libmongocrypt/test/data/schema-broker/encryptedFieldsMap.json +42 -0
  440. data/ext/libmongocrypt/libmongocrypt/test/data/schema-broker/jsonSchema.json +19 -0
  441. data/ext/libmongocrypt/libmongocrypt/test/data/schema-broker/jsonSchema2.json +19 -0
  442. data/ext/libmongocrypt/libmongocrypt/test/data/schema-broker/schemaMap.json +40 -0
  443. data/ext/libmongocrypt/libmongocrypt/test/data/tokens/mc.json +36 -2
  444. data/ext/libmongocrypt/libmongocrypt/test/data/tokens/server.json +36 -2
  445. data/ext/libmongocrypt/libmongocrypt/test/example-state-machine.c +5 -5
  446. data/ext/libmongocrypt/libmongocrypt/test/test-dll.cpp +11 -5
  447. data/ext/libmongocrypt/libmongocrypt/test/test-gcp-auth.c +2 -2
  448. data/ext/libmongocrypt/libmongocrypt/test/test-mc-efc.c +74 -6
  449. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-encryption-placeholder.c +457 -0
  450. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-equality-payload-v2.c +20 -1
  451. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-range-payload-v2.c +2 -18
  452. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-find-text-payload.c +320 -0
  453. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev-v2.c +286 -24
  454. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iev.c +1 -1
  455. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup-v2.c +24 -17
  456. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-iup.c +24 -1
  457. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-payload-uev.c +2 -2
  458. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-rfds.c +10 -7
  459. data/ext/libmongocrypt/libmongocrypt/test/test-mc-fle2-tag-and-encrypted-metadata-block.c +36 -1
  460. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-edge-generation.c +12 -17
  461. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-encoding.c +58 -63
  462. data/ext/libmongocrypt/libmongocrypt/test/test-mc-range-mincover.c +69 -85
  463. data/ext/libmongocrypt/libmongocrypt/test/test-mc-rangeopts.c +7 -22
  464. data/ext/libmongocrypt/libmongocrypt/test/test-mc-reader.c +5 -5
  465. data/ext/libmongocrypt/libmongocrypt/test/test-mc-schema-broker.c +1124 -0
  466. data/ext/libmongocrypt/libmongocrypt/test/test-mc-text-search-str-encode.c +1336 -0
  467. data/ext/libmongocrypt/libmongocrypt/test/test-mc-tokens.c +165 -37
  468. data/ext/libmongocrypt/libmongocrypt/test/test-mc-writer.c +10 -10
  469. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert-match-bson.c +16 -21
  470. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-assert.h +55 -26
  471. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-buffer.c +29 -4
  472. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cache.c +5 -4
  473. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ciphertext.c +13 -13
  474. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-cleanup.c +49 -55
  475. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-compact.c +64 -67
  476. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-hooks.c +19 -19
  477. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto-std-hooks.c +4 -0
  478. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-crypto.c +41 -10
  479. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-csfle-lib.c +33 -2
  480. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-decrypt.c +247 -149
  481. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-encrypt.c +1342 -1229
  482. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-rewrap-many-datakey.c +28 -1
  483. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-ctx-setopt.c +50 -91
  484. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-datakey.c +1 -1
  485. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-dll.c +7 -4
  486. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-endpoint.c +1 -1
  487. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kek.c +2 -2
  488. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-key-cache.c +9 -11
  489. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-ctx.c +2 -2
  490. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-kms-responses.c +2 -2
  491. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-local-kms.c +1 -1
  492. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-log.c +2 -2
  493. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-marking.c +1101 -161
  494. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt-status.c +1 -1
  495. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.c +157 -82
  496. data/ext/libmongocrypt/libmongocrypt/test/test-mongocrypt.h +38 -6
  497. data/ext/libmongocrypt/libmongocrypt/test/test-named-kms-providers.c +11 -11
  498. data/ext/libmongocrypt/libmongocrypt/test/test-unicode-fold.c +101 -0
  499. data/ext/libmongocrypt/libmongocrypt/test/util/HELP.autogen +1 -1
  500. data/ext/libmongocrypt/libmongocrypt/test/util/csfle.c +1 -1
  501. data/ext/libmongocrypt/libmongocrypt/test/util/util.c +5 -5
  502. data/ext/libmongocrypt/libmongocrypt/test/util/util.h +7 -6
  503. data/lib/libmongocrypt_helper/version.rb +2 -2
  504. metadata +219 -165
  505. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/README.md +0 -36
  506. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/benchmarks/src/main/java/com/mongodb/crypt/benchmark/BenchmarkRunner.java +0 -217
  507. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/benchmarks/src/main/resources/keyDocument.json +0 -24
  508. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/build.gradle.kts +0 -354
  509. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradle/wrapper/gradle-wrapper.jar +0 -0
  510. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradle/wrapper/gradle-wrapper.properties +0 -5
  511. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradlew +0 -234
  512. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/gradlew.bat +0 -89
  513. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/settings.gradle.kts +0 -1
  514. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/BinaryHolder.java +0 -45
  515. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CAPI.java +0 -1165
  516. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CAPIHelper.java +0 -96
  517. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/CipherCallback.java +0 -92
  518. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/DisposableMemory.java +0 -31
  519. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/JULLogger.java +0 -130
  520. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/Logger.java +0 -144
  521. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/Loggers.java +0 -50
  522. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MacCallback.java +0 -60
  523. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MessageDigestCallback.java +0 -55
  524. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoAwsKmsProviderOptions.java +0 -104
  525. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCrypt.java +0 -100
  526. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCryptContext.java +0 -137
  527. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCryptContextImpl.java +0 -164
  528. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCryptException.java +0 -67
  529. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCryptImpl.java +0 -423
  530. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCryptOptions.java +0 -284
  531. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoCrypts.java +0 -38
  532. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoDataKeyOptions.java +0 -125
  533. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoExplicitEncryptOptions.java +0 -227
  534. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoKeyDecryptor.java +0 -76
  535. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoKeyDecryptorImpl.java +0 -105
  536. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoLocalKmsProviderOptions.java +0 -83
  537. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/MongoRewrapManyDataKeyOptions.java +0 -104
  538. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/SLF4JLogger.java +0 -110
  539. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/SecureRandomCallback.java +0 -51
  540. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/SigningRSAESPKCSCallback.java +0 -76
  541. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/java/com/mongodb/crypt/capi/package-info.java +0 -18
  542. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/resources/META-INF/native-image/jni-config.json +0 -180
  543. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/main/resources/META-INF/native-image/reflect-config.json +0 -134
  544. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/java/com/mongodb/crypt/capi/MongoCryptTest.java +0 -389
  545. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/command-reply.json +0 -13
  546. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/command.json +0 -6
  547. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/encrypted-command-reply.json +0 -16
  548. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/encrypted-command.json +0 -11
  549. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/encrypted-value.json +0 -6
  550. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit-v2/int32/encrypted-payload.json +0 -26
  551. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit-v2/int32/key-filter.json +0 -19
  552. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit-v2/int32/rangeopts.json +0 -14
  553. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/fle2-find-range-explicit-v2/int32/value-to-encrypt.json +0 -20
  554. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/json-schema.json +0 -15
  555. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/key-document.json +0 -36
  556. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/key-filter-keyAltName.json +0 -14
  557. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/key-filter.json +0 -19
  558. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/kms-reply.txt +0 -6
  559. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/list-collections-filter.json +0 -3
  560. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/mongocryptd-command.json +0 -22
  561. data/ext/libmongocrypt/libmongocrypt/bindings/java/mongocrypt/src/test/resources/mongocryptd-reply.json +0 -18
  562. data/ext/libmongocrypt/libmongocrypt/bindings/python/libmongocrypt-version.txt +0 -1
  563. data/ext/libmongocrypt/libmongocrypt/bindings/python/strip_header.py +0 -50
  564. data/ext/libmongocrypt/libmongocrypt/bindings/python/update-sbom.sh +0 -14
  565. data/ext/libmongocrypt/libmongocrypt/etc/silk-create-asset-group.sh +0 -70
  566. data/ext/libmongocrypt/libmongocrypt/test/data/bulkWrite/jsonSchema/cmd.json +0 -20
  567. data/ext/libmongocrypt/libmongocrypt/test/data/cleanup/success/encrypted-payload.json +0 -29
  568. data/ext/libmongocrypt/libmongocrypt/test/data/collection-info-no-schema.json +0 -19
  569. data/ext/libmongocrypt/libmongocrypt/test/data/compact/no-range/encrypted-field-config-map.json +0 -47
  570. data/ext/libmongocrypt/libmongocrypt/test/data/compact/success/encrypted-payload.json +0 -29
  571. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-collMod/insert/cmd.json +0 -8
  572. data/ext/libmongocrypt/libmongocrypt/test/data/fle1-collMod/insert/collinfo.json +0 -9
  573. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-create/ismaster-to-mongocryptd.json +0 -3
  574. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/empty/encrypted-payload.json +0 -91
  575. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-delete/success/encrypted-payload.json +0 -98
  576. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/find-indexed-contentionFactor1.json +0 -8
  577. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-contentionFactor1.json +0 -8
  578. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-explicit/insert-indexed-same-user-and-index-key.json +0 -8
  579. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality/cmd.json +0 -6
  580. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality/encrypted-payload.json +0 -41
  581. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-equality/mongocryptd-reply.json +0 -19
  582. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date/cmd.json +0 -10
  583. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date/encrypted-field-map.json +0 -28
  584. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date/encrypted-payload.json +0 -42
  585. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/date/mongocryptd-reply.json +0 -50
  586. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128/cmd.json +0 -6
  587. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128/encrypted-field-map.json +0 -28
  588. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128/encrypted-payload.json +0 -42
  589. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128/mongocryptd-reply.json +0 -50
  590. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision/cmd.json +0 -6
  591. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision/encrypted-field-map.json +0 -31
  592. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision/encrypted-payload.json +0 -51
  593. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/decimal128-precision/mongocryptd-reply.json +0 -59
  594. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double/cmd.json +0 -8
  595. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double/encrypted-payload.json +0 -42
  596. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double/mongocryptd-reply.json +0 -50
  597. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision/cmd.json +0 -8
  598. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision/encrypted-payload.json +0 -45
  599. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/double-precision/mongocryptd-reply.json +0 -53
  600. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32/cmd.json +0 -8
  601. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32/encrypted-payload.json +0 -42
  602. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int32/mongocryptd-reply.json +0 -50
  603. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64/cmd.json +0 -8
  604. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64/encrypted-field-map.json +0 -28
  605. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64/encrypted-payload.json +0 -42
  606. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range/int64/mongocryptd-reply.json +0 -50
  607. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double/encrypted-payload.json +0 -26
  608. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/double-precision/encrypted-payload.json +0 -26
  609. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32/encrypted-payload.json +0 -26
  610. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-nominmax/encrypted-payload-v2.json +0 -26
  611. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-find-range-explicit/int32-openinterval/encrypted-payload.json +0 -16
  612. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/cmd.json +0 -13
  613. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/encrypted-field-map.json +0 -28
  614. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/encrypted-payload.json +0 -45
  615. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/date/mongocryptd-reply.json +0 -53
  616. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/cmd.json +0 -9
  617. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/encrypted-field-map.json +0 -28
  618. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/encrypted-payload.json +0 -45
  619. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128/mongocryptd-reply.json +0 -53
  620. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/cmd.json +0 -9
  621. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/encrypted-field-map.json +0 -31
  622. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/encrypted-payload.json +0 -54
  623. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/decimal128-precision/mongocryptd-reply.json +0 -62
  624. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/cmd.json +0 -11
  625. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/encrypted-field-map.json +0 -28
  626. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/encrypted-payload.json +0 -45
  627. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double/mongocryptd-reply.json +0 -53
  628. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/cmd.json +0 -11
  629. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/encrypted-field-map.json +0 -31
  630. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/encrypted-payload.json +0 -48
  631. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/double-precision/mongocryptd-reply.json +0 -56
  632. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32/encrypted-payload.json +0 -45
  633. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int32/mongocryptd-reply.json +0 -53
  634. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/cmd.json +0 -11
  635. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/encrypted-field-map.json +0 -28
  636. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/encrypted-payload.json +0 -45
  637. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range/int64/mongocryptd-reply.json +0 -53
  638. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double/encrypted-payload.json +0 -8
  639. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/double-precision/encrypted-payload.json +0 -8
  640. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/int32-nominmax/encrypted-payload-v2.json +0 -8
  641. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-range-explicit/sparsity-2/encrypted-payload.json +0 -8
  642. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed/cmd.json +0 -9
  643. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed/encrypted-payload.json +0 -14
  644. data/ext/libmongocrypt/libmongocrypt/test/data/fle2-insert-unindexed/mongocryptd-reply.json +0 -46
  645. data/ext/libmongocrypt/libmongocrypt/test/data/schema.json +0 -19
  646. /data/ext/libmongocrypt/libmongocrypt/bindings/python/{build-manylinux-wheel.sh → scripts/build-manylinux-wheel.sh} +0 -0
  647. /data/ext/libmongocrypt/libmongocrypt/test/data/{fle2-explicit/find-indexed.json → explicit-decrypt/FLE2FindEqualityPayload.json} +0 -0
  648. /data/ext/libmongocrypt/libmongocrypt/test/data/{fle2-insert → fle2-insert-text-search-with-str-encode-version}/cmd.json +0 -0
@@ -0,0 +1,1336 @@
1
+ /*
2
+ * Copyright 2024-present MongoDB, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ #include "mongocrypt.h"
18
+ #include "test-mongocrypt-assert.h"
19
+ #include "test-mongocrypt.h"
20
+
21
+ #include "mc-fle2-encryption-placeholder-private.h"
22
+ #include "mc-str-encode-string-sets-private.h"
23
+ #include "mc-text-search-str-encode-private.h"
24
+ #include "unicode/fold.h"
25
+ #include <stdint.h>
26
+ #include <string.h>
27
+
28
+ static uint32_t get_utf8_codepoint_length(const char *buf, uint32_t len) {
29
+ const char *cur = buf;
30
+ const char *end = buf + len;
31
+ uint32_t codepoint_len = 0;
32
+ while (cur < end) {
33
+ cur = bson_utf8_next_char(cur);
34
+ codepoint_len++;
35
+ }
36
+ return codepoint_len;
37
+ }
38
+
39
+ static void test_nofold_suffix_prefix_case(_mongocrypt_tester_t *tester,
40
+ const char *str,
41
+ uint32_t lb,
42
+ uint32_t ub,
43
+ bool casef,
44
+ bool diacf,
45
+ int foldable_codepoints) {
46
+ TEST_PRINTF("Testing nofold suffix/prefix case: str=\"%s\", lb=%u, ub=%u, casef=%d, diacf=%d\n",
47
+ str,
48
+ lb,
49
+ ub,
50
+ casef,
51
+ diacf);
52
+ uint32_t byte_len = (uint32_t)strlen(str);
53
+ uint32_t unfolded_codepoint_len = byte_len == 0 ? 1 : get_utf8_codepoint_length(str, byte_len);
54
+ uint32_t folded_codepoint_len = byte_len == 0 ? 0 : unfolded_codepoint_len - foldable_codepoints;
55
+ uint32_t padded_len = 16 * (uint32_t)((byte_len + 5 + 15) / 16) - 5;
56
+ uint32_t max_affix_len = BSON_MIN(ub, folded_codepoint_len);
57
+ uint32_t n_real_affixes = max_affix_len >= lb ? max_affix_len - lb + 1 : 0;
58
+ uint32_t n_affixes = BSON_MIN(ub, padded_len) - lb + 1;
59
+ uint32_t n_padding = n_affixes - n_real_affixes;
60
+
61
+ mc_str_encode_sets_t *sets;
62
+ mongocrypt_status_t *status = mongocrypt_status_new();
63
+ for (int suffix = 0; suffix <= 1; suffix++) {
64
+ if (suffix) {
65
+ mc_FLE2TextSearchInsertSpec_t spec = {.v = str,
66
+ .len = byte_len,
67
+ .suffix = {{lb, ub}, true},
68
+ .casef = casef,
69
+ .diacf = diacf};
70
+ sets = mc_text_search_str_encode(&spec, status);
71
+ } else {
72
+ mc_FLE2TextSearchInsertSpec_t spec = {.v = str,
73
+ .len = byte_len,
74
+ .prefix = {{lb, ub}, true},
75
+ .casef = casef,
76
+ .diacf = diacf};
77
+ sets = mc_text_search_str_encode(&spec, status);
78
+ }
79
+ ASSERT_OR_PRINT(sets, status);
80
+ ASSERT_CMPUINT32(sets->base_string->codepoint_len, ==, folded_codepoint_len + 1);
81
+ if (!casef && !diacf) {
82
+ ASSERT_CMPUINT32(sets->base_string->buf.len, ==, byte_len + 1);
83
+ ASSERT_CMPINT(0, ==, memcmp(sets->base_string->buf.data, str, byte_len));
84
+ }
85
+ ASSERT_CMPUINT8(sets->base_string->buf.data[sets->base_string->buf.len - 1], ==, (uint8_t)0xFF);
86
+ ASSERT(sets->substring_set == NULL);
87
+ ASSERT_CMPUINT32(sets->exact.len, ==, sets->base_string->buf.len - 1);
88
+ ASSERT_CMPINT(0, ==, memcmp(sets->exact.data, sets->base_string->buf.data, sets->exact.len));
89
+
90
+ if (lb > padded_len) {
91
+ ASSERT(sets->suffix_set == NULL);
92
+ ASSERT(sets->prefix_set == NULL);
93
+ goto CONTINUE;
94
+ }
95
+
96
+ TEST_PRINTF("Expecting: n_real_affixes: %u, n_affixes: %u, n_padding: %u\n",
97
+ n_real_affixes,
98
+ n_affixes,
99
+ n_padding);
100
+
101
+ mc_affix_set_t *set;
102
+ if (suffix) {
103
+ ASSERT(sets->prefix_set == NULL);
104
+ set = sets->suffix_set;
105
+ } else {
106
+ ASSERT(sets->suffix_set == NULL);
107
+ set = sets->prefix_set;
108
+ }
109
+ ASSERT(set != NULL);
110
+
111
+ mc_affix_set_iter_t it;
112
+ mc_affix_set_iter_init(&it, set);
113
+ const char *affix;
114
+
115
+ uint32_t idx = 0;
116
+ uint32_t affix_len = 0;
117
+ uint32_t affix_count = 0;
118
+ uint32_t total_real_affix_count = 0;
119
+ while (mc_affix_set_iter_next(&it, &affix, &affix_len, &affix_count)) {
120
+ // Since all substrings are just views on the base string, we can use pointer math to find our start and
121
+ // end indices.
122
+ TEST_PRINTF("Affix starting %lld, ending %lld, count %u\n",
123
+ (long long)((uint8_t *)affix - sets->base_string->buf.data),
124
+ (long long)((uint8_t *)affix - sets->base_string->buf.data + affix_len),
125
+ affix_count);
126
+ if (affix_len == sets->base_string->buf.len) {
127
+ // This is padding, so there should be no more entries due to how we ordered them
128
+ ASSERT(!mc_affix_set_iter_next(&it, NULL, NULL, NULL));
129
+ break;
130
+ }
131
+
132
+ ASSERT_CMPUINT32(affix_len, <=, sets->base_string->buf.len - 1);
133
+ ASSERT_CMPUINT32(0, <, affix_len);
134
+
135
+ // We happen to always order from smallest to largest in the suffix/prefix algorithm, which makes our
136
+ // life slightly easier when testing.
137
+ if (suffix) {
138
+ uint32_t start_offset = sets->base_string->codepoint_offsets[folded_codepoint_len - (lb + idx)];
139
+ ASSERT_CMPPTR((uint8_t *)affix, ==, sets->base_string->buf.data + start_offset);
140
+ ASSERT_CMPUINT32(affix_len,
141
+ ==,
142
+ sets->base_string->codepoint_offsets[folded_codepoint_len] - start_offset);
143
+ } else {
144
+ uint32_t end_offset = sets->base_string->codepoint_offsets[lb + idx];
145
+ ASSERT_CMPPTR((uint8_t *)affix, ==, sets->base_string->buf.data);
146
+ ASSERT_CMPUINT32(affix_len, ==, end_offset);
147
+ }
148
+ // The count should always be 1, except for padding.
149
+ ASSERT_CMPUINT32(1, ==, affix_count);
150
+ total_real_affix_count++;
151
+ idx++;
152
+ }
153
+ ASSERT_CMPUINT32(total_real_affix_count, ==, n_real_affixes);
154
+ if (affix_len == sets->base_string->buf.len) {
155
+ // Padding
156
+ ASSERT_CMPPTR((uint8_t *)affix, ==, sets->base_string->buf.data);
157
+ ASSERT_CMPUINT32(affix_count, ==, n_padding);
158
+ } else {
159
+ // No padding found
160
+ ASSERT_CMPUINT32(n_padding, ==, 0);
161
+ }
162
+ CONTINUE:
163
+ mc_str_encode_sets_destroy(sets);
164
+ }
165
+ mongocrypt_status_destroy(status);
166
+ }
167
+
168
+ static uint32_t calc_number_of_substrings(uint32_t len, uint32_t lb, uint32_t ub) {
169
+ uint32_t ret = 0;
170
+ // Calculate the long way to make sure our math in calc_number_of_substrings is correct
171
+ for (uint32_t i = 0; i < len; i++) {
172
+ uint32_t max_sublen = BSON_MIN(ub, len - i);
173
+ uint32_t n_substrings = max_sublen < lb ? 0 : max_sublen - lb + 1;
174
+ ret += n_substrings;
175
+ }
176
+ return ret;
177
+ }
178
+
179
+ static uint32_t calc_unique_substrings(const mc_utf8_string_with_bad_char_t *str, uint32_t lb, uint32_t ub) {
180
+ uint32_t len = str->codepoint_len - 1; // eliminate last 0xff CP
181
+ if (len < lb) {
182
+ return 0;
183
+ }
184
+ // Bruteforce to make sure our hashset is working as expected.
185
+ uint8_t *idx_is_dupe = bson_malloc0(len);
186
+ uint32_t dupes = 0;
187
+ for (uint32_t ss_len = lb; ss_len <= BSON_MIN(len, ub); ss_len++) {
188
+ for (uint32_t i = 0; i < len - ss_len; i++) {
189
+ // Already checked
190
+ if (idx_is_dupe[i]) {
191
+ continue;
192
+ }
193
+ for (uint32_t j = i + 1; j <= len - ss_len; j++) {
194
+ // Already counted
195
+ if (idx_is_dupe[j]) {
196
+ continue;
197
+ }
198
+ uint32_t i_start_byte = str->codepoint_offsets[i];
199
+ uint32_t i_end_byte = str->codepoint_offsets[i + ss_len];
200
+ uint32_t j_start_byte = str->codepoint_offsets[j];
201
+ uint32_t j_end_byte = str->codepoint_offsets[j + ss_len];
202
+ if (i_end_byte - i_start_byte == j_end_byte - j_start_byte
203
+ && memcmp(&str->buf.data[i_start_byte], &str->buf.data[j_start_byte], i_end_byte - i_start_byte)
204
+ == 0) {
205
+ idx_is_dupe[j] = 1;
206
+ dupes++;
207
+ }
208
+ }
209
+ }
210
+ memset(idx_is_dupe, 0, len);
211
+ }
212
+ bson_free(idx_is_dupe);
213
+ return calc_number_of_substrings(len, lb, ub) - dupes;
214
+ }
215
+
216
+ static void test_nofold_substring_case(_mongocrypt_tester_t *tester,
217
+ const char *str,
218
+ uint32_t lb,
219
+ uint32_t ub,
220
+ uint32_t mlen,
221
+ bool casef,
222
+ bool diacf,
223
+ int foldable_codepoints) {
224
+ TEST_PRINTF("Testing nofold substring case: str=\"%s\", lb=%u, ub=%u, mlen=%u, casef=%d, diacf=%d\n",
225
+ str,
226
+ lb,
227
+ ub,
228
+ mlen,
229
+ casef,
230
+ diacf);
231
+ uint32_t byte_len = (uint32_t)strlen(str);
232
+ uint32_t unfolded_codepoint_len = byte_len == 0 ? 1 : get_utf8_codepoint_length(str, byte_len);
233
+ uint32_t folded_codepoint_len = byte_len == 0 ? 0 : unfolded_codepoint_len - foldable_codepoints;
234
+ uint32_t padded_len = 16 * (uint32_t)((byte_len + 5 + 15) / 16) - 5;
235
+ uint32_t n_substrings = calc_number_of_substrings(BSON_MIN(padded_len, mlen), lb, ub);
236
+
237
+ mongocrypt_status_t *status = mongocrypt_status_new();
238
+ mc_str_encode_sets_t *sets;
239
+ mc_FLE2TextSearchInsertSpec_t spec = {.v = str,
240
+ .len = byte_len,
241
+ .substr = {{mlen, lb, ub}, true},
242
+ .casef = casef,
243
+ .diacf = diacf};
244
+ sets = mc_text_search_str_encode(&spec, status);
245
+ if (unfolded_codepoint_len > mlen) {
246
+ ASSERT_FAILS_STATUS(sets, status, "longer than the maximum length");
247
+ mongocrypt_status_destroy(status);
248
+ return;
249
+ }
250
+ ASSERT_OR_PRINT(sets, status);
251
+ mongocrypt_status_destroy(status);
252
+ ASSERT_CMPUINT32(sets->base_string->codepoint_len, ==, folded_codepoint_len + 1);
253
+ if (!casef && !diacf) {
254
+ ASSERT_CMPUINT32(sets->base_string->buf.len, ==, byte_len + 1);
255
+ ASSERT_CMPINT(0, ==, memcmp(sets->base_string->buf.data, str, byte_len));
256
+ }
257
+
258
+ ASSERT_CMPUINT8(sets->base_string->buf.data[sets->base_string->buf.len - 1], ==, (uint8_t)0xFF);
259
+ ASSERT(sets->suffix_set == NULL);
260
+ ASSERT(sets->prefix_set == NULL);
261
+ ASSERT_CMPUINT32(sets->exact.len, ==, sets->base_string->buf.len - 1);
262
+ ASSERT_CMPINT(0, ==, memcmp(sets->exact.data, sets->base_string->buf.data, sets->base_string->buf.len - 1));
263
+
264
+ if (lb > padded_len) {
265
+ ASSERT(sets->substring_set == NULL);
266
+ goto cleanup;
267
+ } else {
268
+ ASSERT(sets->substring_set != NULL);
269
+ }
270
+
271
+ uint32_t n_real_substrings = calc_unique_substrings(sets->base_string, lb, ub);
272
+ uint32_t n_padding = n_substrings - n_real_substrings;
273
+
274
+ TEST_PRINTF("Expecting: n_real_substrings: %u, n_substrings: %u, n_padding: %u\n",
275
+ n_real_substrings,
276
+ n_substrings,
277
+ n_padding);
278
+
279
+ mc_substring_set_t *set = sets->substring_set;
280
+ mc_substring_set_iter_t it;
281
+ mc_substring_set_iter_init(&it, set);
282
+ const char *substring;
283
+
284
+ uint32_t substring_len = 0;
285
+ uint32_t substring_count = 0;
286
+ uint32_t total_real_substring_count = 0;
287
+ while (mc_substring_set_iter_next(&it, &substring, &substring_len, &substring_count)) {
288
+ TEST_PRINTF("Substring starting %lld, ending %lld, count %u: \"%.*s\"\n",
289
+ (long long)((uint8_t *)substring - sets->base_string->buf.data),
290
+ (long long)((uint8_t *)substring - sets->base_string->buf.data + substring_len),
291
+ substring_count,
292
+ substring_len,
293
+ substring);
294
+ if (substring_len == sets->base_string->buf.len) {
295
+ // This is padding, so there should be no more entries due to how we ordered them
296
+ ASSERT(!mc_substring_set_iter_next(&it, NULL, NULL, NULL));
297
+ break;
298
+ }
299
+
300
+ ASSERT_CMPPTR((uint8_t *)substring + substring_len,
301
+ <=,
302
+ sets->base_string->buf.data + sets->base_string->buf.len);
303
+ ASSERT_CMPUINT32(substring_len, <=, sets->base_string->buf.len - 1);
304
+ ASSERT_CMPUINT32(0, <, substring_len);
305
+ ASSERT_CMPUINT32(1, ==, substring_count);
306
+ total_real_substring_count++;
307
+ }
308
+ ASSERT_CMPUINT32(total_real_substring_count, ==, n_real_substrings);
309
+ if (substring_len == sets->base_string->buf.len) {
310
+ // Padding
311
+ ASSERT_CMPPTR((uint8_t *)substring, ==, sets->base_string->buf.data);
312
+ ASSERT_CMPUINT32(substring_count, ==, n_padding);
313
+ } else {
314
+ // No padding found
315
+ ASSERT_CMPUINT32(n_padding, ==, 0);
316
+ }
317
+ cleanup:
318
+ mc_str_encode_sets_destroy(sets);
319
+ }
320
+
321
+ static void test_nofold_substring_case_multiple_mlen(_mongocrypt_tester_t *tester,
322
+ const char *str,
323
+ uint32_t lb,
324
+ uint32_t ub,
325
+ uint32_t unfolded_codepoint_len,
326
+ bool casef,
327
+ bool diacf,
328
+ int foldable_codepoints) {
329
+ if (unfolded_codepoint_len > 1) {
330
+ // mlen < unfolded_codepoint_len
331
+ test_nofold_substring_case(tester, str, lb, ub, unfolded_codepoint_len - 1, casef, diacf, foldable_codepoints);
332
+ }
333
+ // mlen = unfolded_codepoint_len
334
+ test_nofold_substring_case(tester, str, lb, ub, unfolded_codepoint_len, casef, diacf, foldable_codepoints);
335
+ // mlen > unfolded_codepoint_len
336
+ test_nofold_substring_case(tester, str, lb, ub, unfolded_codepoint_len + 1, casef, diacf, foldable_codepoints);
337
+ // mlen >> unfolded_codepoint_len
338
+ test_nofold_substring_case(tester, str, lb, ub, unfolded_codepoint_len + 64, casef, diacf, foldable_codepoints);
339
+
340
+ uint32_t byte_len = (uint32_t)strlen(str);
341
+ if (byte_len > 1) {
342
+ // mlen < byte_len
343
+ test_nofold_substring_case(tester, str, lb, ub, byte_len - 1, casef, diacf, foldable_codepoints);
344
+ }
345
+ if (byte_len > 0) {
346
+ // mlen = byte_len
347
+ test_nofold_substring_case(tester, str, lb, ub, byte_len, casef, diacf, foldable_codepoints);
348
+ }
349
+ // mlen > byte_len
350
+ test_nofold_substring_case(tester, str, lb, ub, byte_len + 1, casef, diacf, foldable_codepoints);
351
+ // mlen = padded_len
352
+ test_nofold_substring_case(tester,
353
+ str,
354
+ lb,
355
+ ub,
356
+ 16 * (uint32_t)((byte_len + 5 + 15) / 16) - 5,
357
+ casef,
358
+ diacf,
359
+ foldable_codepoints);
360
+ // mlen >> byte_len
361
+ test_nofold_substring_case(tester, str, lb, ub, byte_len + 64, casef, diacf, foldable_codepoints);
362
+ }
363
+
364
+ static const char *normal_ascii_strings[] = {
365
+ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
366
+ "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F",
367
+ "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
368
+ static const char *ascii_diacritics[] = {"^", "`"};
369
+ static const char *normal_unicode_strings[] = {"ぁ", "あ", "ぃ", "い", "ぅ", "う", "ぇ", "え", "ぉ", "お", "か", "が",
370
+ "き", "ぎ", "く", "け", "Ѐ", "Ё", "Ђ", "Ѓ", "Є", "Ѕ", "І", "Ї",
371
+ "Ј", "Љ", "Њ", "Ћ", "Ќ", "Ѝ", "Ў", "Џ", "𓀀", "𓀁", "𓀂", "𓀃",
372
+ "𓀄", "𓀅", "𓀆", "𓀇", "𓀈", "𓀉", "𓀊", "𓀋", "𓀌", "𓀍", "𓀎", "𓀏"};
373
+ static const char *unicode_diacritics[] = {"̀", "́", "̂", "̃", "̄", "̅", "̆", "̇", "̈", "̉", "̊", "̋", "̌", "̍", "̎",
374
+ "̏", "᷄", "᷅", "᷆", "᷇", "᷈", "᷉", "᷊", "᷋", "᷌", "᷍", "᷎", "᷏", "︠", "︡",
375
+ "︢", "︣", "︤", "︥", "︦", "︧", "︨", "︩", "︪", "︫", "︬", "︭", "︮", "︯"};
376
+
377
+ // Build a random string which has unfolded_len codepoints, but folds to folded_len codepoints after diacritic folding.
378
+ static char *build_random_string_to_fold(uint32_t folded_len, uint32_t unfolded_len) {
379
+ // 1/3 to generate all unicode, 1/3 to be half and half, 1/3 to be all ascii.
380
+ int ascii_ratio = rand() % 3;
381
+ ASSERT_CMPUINT32(unfolded_len, >=, folded_len);
382
+ // Max size in bytes is # unicode characters * 4 bytes for each character + 1 null terminator.
383
+ char *str = malloc(unfolded_len * 4 + 1);
384
+ char *ptr = str;
385
+ uint32_t folded_size = 0;
386
+ uint32_t diacritics = unfolded_len - folded_len;
387
+ int dia_prob = (diacritics * 1000) / unfolded_len;
388
+ for (uint32_t n_codepoints = 0; n_codepoints < unfolded_len; n_codepoints++) {
389
+ const char *src_ptr;
390
+ bool must_add_diacritic = folded_size == folded_len;
391
+ bool must_add_normal = n_codepoints - folded_size == diacritics;
392
+ if (must_add_diacritic || (!must_add_normal && (rand() % 1000 < dia_prob))) {
393
+ // Add diacritic.
394
+ if (rand() % 2 < ascii_ratio) {
395
+ int i = rand() % (sizeof(ascii_diacritics) / sizeof(char *));
396
+ src_ptr = ascii_diacritics[i];
397
+ } else {
398
+ int i = rand() % (sizeof(unicode_diacritics) / sizeof(char *));
399
+ src_ptr = unicode_diacritics[i];
400
+ }
401
+ } else {
402
+ // Add normal character.
403
+ if (rand() % 2 < ascii_ratio) {
404
+ int i = rand() % (sizeof(normal_ascii_strings) / sizeof(char *));
405
+ src_ptr = normal_ascii_strings[i];
406
+ } else {
407
+ int i = rand() % (sizeof(normal_unicode_strings) / sizeof(char *));
408
+ src_ptr = normal_unicode_strings[i];
409
+ }
410
+ folded_size++;
411
+ }
412
+ strcpy(ptr, src_ptr);
413
+ ptr += strlen(src_ptr);
414
+ }
415
+
416
+ uint32_t len = (uint32_t)(ptr - str);
417
+ // ptr points to the final null character, include that in the final string.
418
+ str = realloc(str, len + 1);
419
+
420
+ // Make sure we did everything right.
421
+ ASSERT_CMPUINT32(unfolded_len, ==, get_utf8_codepoint_length(str, len));
422
+ mongocrypt_status_t *status = mongocrypt_status_new();
423
+ char *out_str;
424
+ size_t out_len;
425
+ ASSERT_OK_STATUS(unicode_fold(str, len, kUnicodeFoldRemoveDiacritics, &out_str, &out_len, status), status);
426
+ ASSERT_CMPUINT32(folded_len, ==, get_utf8_codepoint_length(out_str, (uint32_t)out_len));
427
+ bson_free(out_str);
428
+ mongocrypt_status_destroy(status);
429
+ return str;
430
+ }
431
+
432
+ static void suffix_prefix_run_folding_case(_mongocrypt_tester_t *tester,
433
+ const char *short_s,
434
+ const char *medium_s,
435
+ const char *long_s,
436
+ bool casef,
437
+ bool diacf,
438
+ int foldable_codepoints) {
439
+ // LB > 16
440
+ test_nofold_suffix_prefix_case(tester, short_s, 17, 19, casef, diacf, foldable_codepoints);
441
+ // Simple cases
442
+ test_nofold_suffix_prefix_case(tester, short_s, 2, 4, casef, diacf, foldable_codepoints);
443
+ test_nofold_suffix_prefix_case(tester, short_s, 3, 6, casef, diacf, foldable_codepoints);
444
+ // LB = UB
445
+ test_nofold_suffix_prefix_case(tester, short_s, 2, 2, casef, diacf, foldable_codepoints);
446
+ test_nofold_suffix_prefix_case(tester, short_s, 9, 9, casef, diacf, foldable_codepoints);
447
+ // UB = len
448
+ test_nofold_suffix_prefix_case(tester, short_s, 2, 9, casef, diacf, foldable_codepoints);
449
+ // 16 > UB > len
450
+ test_nofold_suffix_prefix_case(tester, short_s, 2, 14, casef, diacf, foldable_codepoints);
451
+ // UB = 16
452
+ test_nofold_suffix_prefix_case(tester, short_s, 2, 16, casef, diacf, foldable_codepoints);
453
+ // UB > 16
454
+ test_nofold_suffix_prefix_case(tester, short_s, 2, 19, casef, diacf, foldable_codepoints);
455
+ // UB > 32
456
+ test_nofold_suffix_prefix_case(tester, short_s, 2, 35, casef, diacf, foldable_codepoints);
457
+ // 16 >= LB > len
458
+ test_nofold_suffix_prefix_case(tester, short_s, 12, 19, casef, diacf, foldable_codepoints);
459
+ test_nofold_suffix_prefix_case(tester, short_s, 12, 16, casef, diacf, foldable_codepoints);
460
+ test_nofold_suffix_prefix_case(tester, short_s, 16, 19, casef, diacf, foldable_codepoints);
461
+ test_nofold_suffix_prefix_case(tester, short_s, 12, 35, casef, diacf, foldable_codepoints);
462
+ test_nofold_suffix_prefix_case(tester, short_s, 16, 35, casef, diacf, foldable_codepoints);
463
+
464
+ // len = 16 cases
465
+ // LB > 16
466
+ test_nofold_suffix_prefix_case(tester, medium_s, 17, 19, casef, diacf, foldable_codepoints);
467
+ // Simple cases
468
+ test_nofold_suffix_prefix_case(tester, medium_s, 2, 4, casef, diacf, foldable_codepoints);
469
+ test_nofold_suffix_prefix_case(tester, medium_s, 3, 6, casef, diacf, foldable_codepoints);
470
+ // LB = UB
471
+ test_nofold_suffix_prefix_case(tester, medium_s, 2, 2, casef, diacf, foldable_codepoints);
472
+ test_nofold_suffix_prefix_case(tester, medium_s, 16, 16, casef, diacf, foldable_codepoints);
473
+ // UB = len
474
+ test_nofold_suffix_prefix_case(tester, medium_s, 2, 16, casef, diacf, foldable_codepoints);
475
+ // UB > len
476
+ test_nofold_suffix_prefix_case(tester, medium_s, 2, 19, casef, diacf, foldable_codepoints);
477
+ // UB = 32
478
+ test_nofold_suffix_prefix_case(tester, medium_s, 2, 32, casef, diacf, foldable_codepoints);
479
+ // UB > 32
480
+ test_nofold_suffix_prefix_case(tester, medium_s, 2, 35, casef, diacf, foldable_codepoints);
481
+ // LB = len
482
+ test_nofold_suffix_prefix_case(tester, medium_s, 16, 19, casef, diacf, foldable_codepoints);
483
+ test_nofold_suffix_prefix_case(tester, medium_s, 16, 35, casef, diacf, foldable_codepoints);
484
+
485
+ // len > 16 cases
486
+ // LB > 32
487
+ test_nofold_suffix_prefix_case(tester, long_s, 33, 38, casef, diacf, foldable_codepoints);
488
+ // Simple cases
489
+ test_nofold_suffix_prefix_case(tester, long_s, 2, 4, casef, diacf, foldable_codepoints);
490
+ test_nofold_suffix_prefix_case(tester, long_s, 3, 6, casef, diacf, foldable_codepoints);
491
+ // LB < 16 <= UB <= len
492
+ test_nofold_suffix_prefix_case(tester, long_s, 3, 18, casef, diacf, foldable_codepoints);
493
+ test_nofold_suffix_prefix_case(tester, long_s, 3, 16, casef, diacf, foldable_codepoints);
494
+ test_nofold_suffix_prefix_case(tester, long_s, 3, 27, casef, diacf, foldable_codepoints);
495
+ // 16 <= LB < UB <= len
496
+ test_nofold_suffix_prefix_case(tester, long_s, 18, 24, casef, diacf, foldable_codepoints);
497
+ test_nofold_suffix_prefix_case(tester, long_s, 16, 24, casef, diacf, foldable_codepoints);
498
+ test_nofold_suffix_prefix_case(tester, long_s, 18, 27, casef, diacf, foldable_codepoints);
499
+ test_nofold_suffix_prefix_case(tester, long_s, 16, 27, casef, diacf, foldable_codepoints);
500
+ // LB = UB
501
+ test_nofold_suffix_prefix_case(tester, long_s, 3, 3, casef, diacf, foldable_codepoints);
502
+ test_nofold_suffix_prefix_case(tester, long_s, 16, 16, casef, diacf, foldable_codepoints);
503
+ test_nofold_suffix_prefix_case(tester, long_s, 27, 27, casef, diacf, foldable_codepoints);
504
+ // 32 > UB > len
505
+ test_nofold_suffix_prefix_case(tester, long_s, 3, 29, casef, diacf, foldable_codepoints);
506
+ test_nofold_suffix_prefix_case(tester, long_s, 18, 29, casef, diacf, foldable_codepoints);
507
+ // UB = 32
508
+ test_nofold_suffix_prefix_case(tester, long_s, 3, 32, casef, diacf, foldable_codepoints);
509
+ test_nofold_suffix_prefix_case(tester, long_s, 18, 32, casef, diacf, foldable_codepoints);
510
+ test_nofold_suffix_prefix_case(tester, long_s, 27, 32, casef, diacf, foldable_codepoints);
511
+ // UB > 32
512
+ test_nofold_suffix_prefix_case(tester, long_s, 3, 35, casef, diacf, foldable_codepoints);
513
+ test_nofold_suffix_prefix_case(tester, long_s, 18, 35, casef, diacf, foldable_codepoints);
514
+ test_nofold_suffix_prefix_case(tester, long_s, 27, 32, casef, diacf, foldable_codepoints);
515
+ // UB > 48
516
+ test_nofold_suffix_prefix_case(tester, long_s, 3, 49, casef, diacf, foldable_codepoints);
517
+ test_nofold_suffix_prefix_case(tester, long_s, 18, 49, casef, diacf, foldable_codepoints);
518
+ test_nofold_suffix_prefix_case(tester, long_s, 27, 32, casef, diacf, foldable_codepoints);
519
+ // 32 >= LB > len
520
+ test_nofold_suffix_prefix_case(tester, long_s, 28, 30, casef, diacf, foldable_codepoints);
521
+ test_nofold_suffix_prefix_case(tester, long_s, 28, 28, casef, diacf, foldable_codepoints);
522
+ test_nofold_suffix_prefix_case(tester, long_s, 28, 32, casef, diacf, foldable_codepoints);
523
+ test_nofold_suffix_prefix_case(tester, long_s, 28, 34, casef, diacf, foldable_codepoints);
524
+ test_nofold_suffix_prefix_case(tester, long_s, 28, 49, casef, diacf, foldable_codepoints);
525
+ test_nofold_suffix_prefix_case(tester, long_s, 32, 32, casef, diacf, foldable_codepoints);
526
+ test_nofold_suffix_prefix_case(tester, long_s, 32, 34, casef, diacf, foldable_codepoints);
527
+ test_nofold_suffix_prefix_case(tester, long_s, 32, 49, casef, diacf, foldable_codepoints);
528
+ }
529
+
530
+ static const uint32_t UNFOLDED_CASES[] = {0, 1, 3, 16};
531
+ // Predefined lengths to test a variety of cases
532
+ static const uint32_t SHORT_LEN = 9;
533
+ static const uint32_t MEDIUM_LEN = 16;
534
+ static const uint32_t LONG_LEN = 27;
535
+
536
+ static void _test_text_search_str_encode_suffix_prefix(_mongocrypt_tester_t *tester) {
537
+ unsigned int seed = (unsigned int)time(0);
538
+ TEST_PRINTF("Testing with seed: %u", seed);
539
+ srand(seed);
540
+ // Run diacritic folding and case+diacritic folding for a variety of folded/unfolded sizes.
541
+ for (uint32_t i = 0; i < sizeof(UNFOLDED_CASES) / sizeof(UNFOLDED_CASES[0]); i++) {
542
+ char *short_s = build_random_string_to_fold(SHORT_LEN, SHORT_LEN + UNFOLDED_CASES[i]);
543
+ char *medium_s = build_random_string_to_fold(MEDIUM_LEN, MEDIUM_LEN + UNFOLDED_CASES[i]);
544
+ char *long_s = build_random_string_to_fold(LONG_LEN, LONG_LEN + UNFOLDED_CASES[i]);
545
+ for (int casef = 0; casef <= 1; casef++) {
546
+ suffix_prefix_run_folding_case(tester,
547
+ short_s,
548
+ medium_s,
549
+ long_s,
550
+ casef,
551
+ true /* diacf */,
552
+ UNFOLDED_CASES[i]);
553
+ }
554
+ bson_free(short_s);
555
+ bson_free(medium_s);
556
+ bson_free(long_s);
557
+ }
558
+ // Run case folding and no folding for different sizes. Only unfolded size matters.
559
+ char *short_s = build_random_string_to_fold(SHORT_LEN, SHORT_LEN);
560
+ char *medium_s = build_random_string_to_fold(MEDIUM_LEN, MEDIUM_LEN);
561
+ char *long_s = build_random_string_to_fold(LONG_LEN, LONG_LEN);
562
+ for (int casef = 0; casef <= 1; casef++) {
563
+ suffix_prefix_run_folding_case(tester, short_s, medium_s, long_s, casef, false /* diacf*/, 0);
564
+ }
565
+ bson_free(short_s);
566
+ bson_free(medium_s);
567
+ bson_free(long_s);
568
+ }
569
+
570
+ static void substring_run_folding_case(_mongocrypt_tester_t *tester,
571
+ const char *short_s,
572
+ uint32_t short_unfolded_codepoint_len,
573
+ const char *medium_s,
574
+ uint32_t medium_unfolded_codepoint_len,
575
+ const char *long_s,
576
+ uint32_t long_unfolded_codepoint_len,
577
+ bool casef,
578
+ bool diacf,
579
+ int foldable_codepoints) {
580
+ // LB > 16
581
+ test_nofold_substring_case_multiple_mlen(tester,
582
+ short_s,
583
+ 17,
584
+ 19,
585
+ short_unfolded_codepoint_len,
586
+ casef,
587
+ diacf,
588
+ foldable_codepoints);
589
+ // Simple cases
590
+ test_nofold_substring_case_multiple_mlen(tester,
591
+ short_s,
592
+ 2,
593
+ 4,
594
+ short_unfolded_codepoint_len,
595
+ casef,
596
+ diacf,
597
+ foldable_codepoints);
598
+ test_nofold_substring_case_multiple_mlen(tester,
599
+ short_s,
600
+ 3,
601
+ 6,
602
+ short_unfolded_codepoint_len,
603
+ casef,
604
+ diacf,
605
+ foldable_codepoints);
606
+ // LB = UB
607
+ test_nofold_substring_case_multiple_mlen(tester,
608
+ short_s,
609
+ 2,
610
+ 2,
611
+ short_unfolded_codepoint_len,
612
+ casef,
613
+ diacf,
614
+ foldable_codepoints);
615
+ test_nofold_substring_case_multiple_mlen(tester,
616
+ short_s,
617
+ 9,
618
+ 9,
619
+ short_unfolded_codepoint_len,
620
+ casef,
621
+ diacf,
622
+ foldable_codepoints);
623
+ // UB = len
624
+ test_nofold_substring_case_multiple_mlen(tester,
625
+ short_s,
626
+ 2,
627
+ 9,
628
+ short_unfolded_codepoint_len,
629
+ casef,
630
+ diacf,
631
+ foldable_codepoints);
632
+ // 16 > UB > len
633
+ test_nofold_substring_case_multiple_mlen(tester,
634
+ short_s,
635
+ 2,
636
+ 14,
637
+ short_unfolded_codepoint_len,
638
+ casef,
639
+ diacf,
640
+ foldable_codepoints);
641
+ // UB = 16
642
+ test_nofold_substring_case_multiple_mlen(tester,
643
+ short_s,
644
+ 2,
645
+ 16,
646
+ short_unfolded_codepoint_len,
647
+ casef,
648
+ diacf,
649
+ foldable_codepoints);
650
+ // UB > 16
651
+ test_nofold_substring_case_multiple_mlen(tester,
652
+ short_s,
653
+ 2,
654
+ 19,
655
+ short_unfolded_codepoint_len,
656
+ casef,
657
+ diacf,
658
+ foldable_codepoints);
659
+ // UB > 32
660
+ test_nofold_substring_case_multiple_mlen(tester,
661
+ short_s,
662
+ 2,
663
+ 35,
664
+ short_unfolded_codepoint_len,
665
+ casef,
666
+ diacf,
667
+ foldable_codepoints);
668
+ // 16 >= LB > len
669
+ test_nofold_substring_case_multiple_mlen(tester,
670
+ short_s,
671
+ 12,
672
+ 19,
673
+ short_unfolded_codepoint_len,
674
+ casef,
675
+ diacf,
676
+ foldable_codepoints);
677
+ test_nofold_substring_case_multiple_mlen(tester,
678
+ short_s,
679
+ 12,
680
+ 16,
681
+ short_unfolded_codepoint_len,
682
+ casef,
683
+ diacf,
684
+ foldable_codepoints);
685
+ test_nofold_substring_case_multiple_mlen(tester,
686
+ short_s,
687
+ 16,
688
+ 19,
689
+ short_unfolded_codepoint_len,
690
+ casef,
691
+ diacf,
692
+ foldable_codepoints);
693
+ test_nofold_substring_case_multiple_mlen(tester,
694
+ short_s,
695
+ 12,
696
+ 35,
697
+ short_unfolded_codepoint_len,
698
+ casef,
699
+ diacf,
700
+ foldable_codepoints);
701
+ test_nofold_substring_case_multiple_mlen(tester,
702
+ short_s,
703
+ 16,
704
+ 35,
705
+ short_unfolded_codepoint_len,
706
+ casef,
707
+ diacf,
708
+ foldable_codepoints);
709
+
710
+ // len = 16 cases
711
+ // LB > 16
712
+ test_nofold_substring_case_multiple_mlen(tester,
713
+ medium_s,
714
+ 17,
715
+ 19,
716
+ medium_unfolded_codepoint_len,
717
+ casef,
718
+ diacf,
719
+ foldable_codepoints);
720
+ // Simple cases
721
+ test_nofold_substring_case_multiple_mlen(tester,
722
+ medium_s,
723
+ 2,
724
+ 4,
725
+ medium_unfolded_codepoint_len,
726
+ casef,
727
+ diacf,
728
+ foldable_codepoints);
729
+ test_nofold_substring_case_multiple_mlen(tester,
730
+ medium_s,
731
+ 3,
732
+ 6,
733
+ medium_unfolded_codepoint_len,
734
+ casef,
735
+ diacf,
736
+ foldable_codepoints);
737
+ // LB = UB
738
+ test_nofold_substring_case_multiple_mlen(tester,
739
+ medium_s,
740
+ 2,
741
+ 2,
742
+ medium_unfolded_codepoint_len,
743
+ casef,
744
+ diacf,
745
+ foldable_codepoints);
746
+ test_nofold_substring_case_multiple_mlen(tester,
747
+ medium_s,
748
+ 16,
749
+ 16,
750
+ medium_unfolded_codepoint_len,
751
+ casef,
752
+ diacf,
753
+ foldable_codepoints);
754
+ // UB = len
755
+ test_nofold_substring_case_multiple_mlen(tester,
756
+ medium_s,
757
+ 2,
758
+ 16,
759
+ medium_unfolded_codepoint_len,
760
+ casef,
761
+ diacf,
762
+ foldable_codepoints);
763
+ // UB > len
764
+ test_nofold_substring_case_multiple_mlen(tester,
765
+ medium_s,
766
+ 2,
767
+ 19,
768
+ medium_unfolded_codepoint_len,
769
+ casef,
770
+ diacf,
771
+ foldable_codepoints);
772
+ // UB = 32
773
+ test_nofold_substring_case_multiple_mlen(tester,
774
+ medium_s,
775
+ 2,
776
+ 32,
777
+ medium_unfolded_codepoint_len,
778
+ casef,
779
+ diacf,
780
+ foldable_codepoints);
781
+ // UB > 32
782
+ test_nofold_substring_case_multiple_mlen(tester,
783
+ medium_s,
784
+ 2,
785
+ 35,
786
+ medium_unfolded_codepoint_len,
787
+ casef,
788
+ diacf,
789
+ foldable_codepoints);
790
+ // LB = len
791
+ test_nofold_substring_case_multiple_mlen(tester,
792
+ medium_s,
793
+ 16,
794
+ 19,
795
+ medium_unfolded_codepoint_len,
796
+ casef,
797
+ diacf,
798
+ foldable_codepoints);
799
+ test_nofold_substring_case_multiple_mlen(tester,
800
+ medium_s,
801
+ 16,
802
+ 35,
803
+ medium_unfolded_codepoint_len,
804
+ casef,
805
+ diacf,
806
+ foldable_codepoints);
807
+
808
+ // len > 16 cases
809
+ // LB > 32
810
+ test_nofold_substring_case_multiple_mlen(tester,
811
+ long_s,
812
+ 33,
813
+ 38,
814
+ long_unfolded_codepoint_len,
815
+ casef,
816
+ diacf,
817
+ foldable_codepoints);
818
+ // Simple cases
819
+ test_nofold_substring_case_multiple_mlen(tester,
820
+ long_s,
821
+ 2,
822
+ 4,
823
+ long_unfolded_codepoint_len,
824
+ casef,
825
+ diacf,
826
+ foldable_codepoints);
827
+ test_nofold_substring_case_multiple_mlen(tester,
828
+ long_s,
829
+ 3,
830
+ 6,
831
+ long_unfolded_codepoint_len,
832
+ casef,
833
+ diacf,
834
+ foldable_codepoints);
835
+ // LB < 16 <= UB <= len
836
+ test_nofold_substring_case_multiple_mlen(tester,
837
+ long_s,
838
+ 3,
839
+ 18,
840
+ long_unfolded_codepoint_len,
841
+ casef,
842
+ diacf,
843
+ foldable_codepoints);
844
+ test_nofold_substring_case_multiple_mlen(tester,
845
+ long_s,
846
+ 3,
847
+ 16,
848
+ long_unfolded_codepoint_len,
849
+ casef,
850
+ diacf,
851
+ foldable_codepoints);
852
+ test_nofold_substring_case_multiple_mlen(tester,
853
+ long_s,
854
+ 3,
855
+ 27,
856
+ long_unfolded_codepoint_len,
857
+ casef,
858
+ diacf,
859
+ foldable_codepoints);
860
+ // 16 <= LB < UB <= len
861
+ test_nofold_substring_case_multiple_mlen(tester,
862
+ long_s,
863
+ 18,
864
+ 24,
865
+ long_unfolded_codepoint_len,
866
+ casef,
867
+ diacf,
868
+ foldable_codepoints);
869
+ test_nofold_substring_case_multiple_mlen(tester,
870
+ long_s,
871
+ 16,
872
+ 24,
873
+ long_unfolded_codepoint_len,
874
+ casef,
875
+ diacf,
876
+ foldable_codepoints);
877
+ test_nofold_substring_case_multiple_mlen(tester,
878
+ long_s,
879
+ 18,
880
+ 27,
881
+ long_unfolded_codepoint_len,
882
+ casef,
883
+ diacf,
884
+ foldable_codepoints);
885
+ test_nofold_substring_case_multiple_mlen(tester,
886
+ long_s,
887
+ 16,
888
+ 27,
889
+ long_unfolded_codepoint_len,
890
+ casef,
891
+ diacf,
892
+ foldable_codepoints);
893
+ // LB = UB
894
+ test_nofold_substring_case_multiple_mlen(tester,
895
+ long_s,
896
+ 3,
897
+ 3,
898
+ long_unfolded_codepoint_len,
899
+ casef,
900
+ diacf,
901
+ foldable_codepoints);
902
+ test_nofold_substring_case_multiple_mlen(tester,
903
+ long_s,
904
+ 16,
905
+ 16,
906
+ long_unfolded_codepoint_len,
907
+ casef,
908
+ diacf,
909
+ foldable_codepoints);
910
+ test_nofold_substring_case_multiple_mlen(tester,
911
+ long_s,
912
+ 27,
913
+ 27,
914
+ long_unfolded_codepoint_len,
915
+ casef,
916
+ diacf,
917
+ foldable_codepoints);
918
+ // 32 > UB > len
919
+ test_nofold_substring_case_multiple_mlen(tester,
920
+ long_s,
921
+ 3,
922
+ 29,
923
+ long_unfolded_codepoint_len,
924
+ casef,
925
+ diacf,
926
+ foldable_codepoints);
927
+ test_nofold_substring_case_multiple_mlen(tester,
928
+ long_s,
929
+ 18,
930
+ 29,
931
+ long_unfolded_codepoint_len,
932
+ casef,
933
+ diacf,
934
+ foldable_codepoints);
935
+ // UB = 32
936
+ test_nofold_substring_case_multiple_mlen(tester,
937
+ long_s,
938
+ 3,
939
+ 32,
940
+ long_unfolded_codepoint_len,
941
+ casef,
942
+ diacf,
943
+ foldable_codepoints);
944
+ test_nofold_substring_case_multiple_mlen(tester,
945
+ long_s,
946
+ 18,
947
+ 32,
948
+ long_unfolded_codepoint_len,
949
+ casef,
950
+ diacf,
951
+ foldable_codepoints);
952
+ test_nofold_substring_case_multiple_mlen(tester,
953
+ long_s,
954
+ 27,
955
+ 32,
956
+ long_unfolded_codepoint_len,
957
+ casef,
958
+ diacf,
959
+ foldable_codepoints);
960
+ // UB > 32
961
+ test_nofold_substring_case_multiple_mlen(tester,
962
+ long_s,
963
+ 3,
964
+ 35,
965
+ long_unfolded_codepoint_len,
966
+ casef,
967
+ diacf,
968
+ foldable_codepoints);
969
+ test_nofold_substring_case_multiple_mlen(tester,
970
+ long_s,
971
+ 18,
972
+ 35,
973
+ long_unfolded_codepoint_len,
974
+ casef,
975
+ diacf,
976
+ foldable_codepoints);
977
+ test_nofold_substring_case_multiple_mlen(tester,
978
+ long_s,
979
+ 27,
980
+ 32,
981
+ long_unfolded_codepoint_len,
982
+ casef,
983
+ diacf,
984
+ foldable_codepoints);
985
+ // UB > 48
986
+ test_nofold_substring_case_multiple_mlen(tester,
987
+ long_s,
988
+ 3,
989
+ 49,
990
+ long_unfolded_codepoint_len,
991
+ casef,
992
+ diacf,
993
+ foldable_codepoints);
994
+ test_nofold_substring_case_multiple_mlen(tester,
995
+ long_s,
996
+ 18,
997
+ 49,
998
+ long_unfolded_codepoint_len,
999
+ casef,
1000
+ diacf,
1001
+ foldable_codepoints);
1002
+ test_nofold_substring_case_multiple_mlen(tester,
1003
+ long_s,
1004
+ 27,
1005
+ 32,
1006
+ long_unfolded_codepoint_len,
1007
+ casef,
1008
+ diacf,
1009
+ foldable_codepoints);
1010
+ // 32 >= LB > len
1011
+ test_nofold_substring_case_multiple_mlen(tester,
1012
+ long_s,
1013
+ 28,
1014
+ 30,
1015
+ long_unfolded_codepoint_len,
1016
+ casef,
1017
+ diacf,
1018
+ foldable_codepoints);
1019
+ test_nofold_substring_case_multiple_mlen(tester,
1020
+ long_s,
1021
+ 28,
1022
+ 28,
1023
+ long_unfolded_codepoint_len,
1024
+ casef,
1025
+ diacf,
1026
+ foldable_codepoints);
1027
+ test_nofold_substring_case_multiple_mlen(tester,
1028
+ long_s,
1029
+ 28,
1030
+ 32,
1031
+ long_unfolded_codepoint_len,
1032
+ casef,
1033
+ diacf,
1034
+ foldable_codepoints);
1035
+ test_nofold_substring_case_multiple_mlen(tester,
1036
+ long_s,
1037
+ 28,
1038
+ 34,
1039
+ long_unfolded_codepoint_len,
1040
+ casef,
1041
+ diacf,
1042
+ foldable_codepoints);
1043
+ test_nofold_substring_case_multiple_mlen(tester,
1044
+ long_s,
1045
+ 28,
1046
+ 49,
1047
+ long_unfolded_codepoint_len,
1048
+ casef,
1049
+ diacf,
1050
+ foldable_codepoints);
1051
+ test_nofold_substring_case_multiple_mlen(tester,
1052
+ long_s,
1053
+ 32,
1054
+ 32,
1055
+ long_unfolded_codepoint_len,
1056
+ casef,
1057
+ diacf,
1058
+ foldable_codepoints);
1059
+ test_nofold_substring_case_multiple_mlen(tester,
1060
+ long_s,
1061
+ 32,
1062
+ 34,
1063
+ long_unfolded_codepoint_len,
1064
+ casef,
1065
+ diacf,
1066
+ foldable_codepoints);
1067
+ test_nofold_substring_case_multiple_mlen(tester,
1068
+ long_s,
1069
+ 32,
1070
+ 49,
1071
+ long_unfolded_codepoint_len,
1072
+ casef,
1073
+ diacf,
1074
+ foldable_codepoints);
1075
+ }
1076
+
1077
+ static void _test_text_search_str_encode_substring(_mongocrypt_tester_t *tester) {
1078
+ unsigned int seed = (unsigned int)time(0);
1079
+ TEST_PRINTF("Testing with seed: %u", seed);
1080
+ srand(seed);
1081
+ // Run diacritic folding and case+diacritic folding for a variety of folded/unfolded sizes.
1082
+ for (uint32_t i = 0; i < sizeof(UNFOLDED_CASES) / sizeof(UNFOLDED_CASES[0]); i++) {
1083
+ char *short_s = build_random_string_to_fold(SHORT_LEN, SHORT_LEN + UNFOLDED_CASES[i]);
1084
+ char *medium_s = build_random_string_to_fold(MEDIUM_LEN, MEDIUM_LEN + UNFOLDED_CASES[i]);
1085
+ char *long_s = build_random_string_to_fold(LONG_LEN, LONG_LEN + UNFOLDED_CASES[i]);
1086
+ for (int casef = 0; casef <= 1; casef++) {
1087
+ substring_run_folding_case(tester,
1088
+ short_s,
1089
+ SHORT_LEN + UNFOLDED_CASES[i],
1090
+ medium_s,
1091
+ MEDIUM_LEN + UNFOLDED_CASES[i],
1092
+ long_s,
1093
+ LONG_LEN + UNFOLDED_CASES[i],
1094
+ casef,
1095
+ true /* diacf */,
1096
+ UNFOLDED_CASES[i]);
1097
+ }
1098
+ bson_free(short_s);
1099
+ bson_free(medium_s);
1100
+ bson_free(long_s);
1101
+ }
1102
+ // Run case folding and no folding for different sizes. Only unfolded size matters.
1103
+ char *short_s = build_random_string_to_fold(SHORT_LEN, SHORT_LEN);
1104
+ char *medium_s = build_random_string_to_fold(MEDIUM_LEN, MEDIUM_LEN);
1105
+ char *long_s = build_random_string_to_fold(LONG_LEN, LONG_LEN);
1106
+ for (int casef = 0; casef <= 1; casef++) {
1107
+ substring_run_folding_case(tester,
1108
+ short_s,
1109
+ SHORT_LEN,
1110
+ medium_s,
1111
+ MEDIUM_LEN,
1112
+ long_s,
1113
+ LONG_LEN,
1114
+ casef,
1115
+ false /* diacf */,
1116
+ 0);
1117
+ }
1118
+ bson_free(short_s);
1119
+ bson_free(medium_s);
1120
+ bson_free(long_s);
1121
+ }
1122
+
1123
+ static void _test_text_search_str_encode_multiple(_mongocrypt_tester_t *tester) {
1124
+ mc_FLE2TextSearchInsertSpec_t spec = {.v = "123456789",
1125
+ .len = 9,
1126
+ .substr = {{20, 9, 9}, true},
1127
+ .suffix = {{1, 5}, true},
1128
+ .prefix = {{6, 8}, true}};
1129
+ mongocrypt_status_t *status = mongocrypt_status_new();
1130
+ mc_str_encode_sets_t *sets = mc_text_search_str_encode(&spec, status);
1131
+ // Ensure that we ran tree generation for suffix, prefix, and substring successfully by checking the first entry of
1132
+ // each.
1133
+ const char *str;
1134
+ uint32_t len, count;
1135
+
1136
+ ASSERT_OR_PRINT(sets, status);
1137
+ mongocrypt_status_destroy(status);
1138
+ ASSERT(sets->suffix_set != NULL);
1139
+ mc_affix_set_iter_t it;
1140
+ mc_affix_set_iter_init(&it, sets->suffix_set);
1141
+ ASSERT(mc_affix_set_iter_next(&it, &str, &len, &count));
1142
+ ASSERT_CMPUINT32(len, ==, 1);
1143
+ ASSERT_CMPUINT8((uint8_t)*str, ==, (uint8_t)'9');
1144
+ ASSERT_CMPUINT32(count, ==, 1);
1145
+
1146
+ ASSERT(sets->prefix_set != NULL);
1147
+ mc_affix_set_iter_init(&it, sets->prefix_set);
1148
+ ASSERT(mc_affix_set_iter_next(&it, &str, &len, &count));
1149
+ ASSERT_CMPUINT32(len, ==, 6);
1150
+ ASSERT_CMPINT(0, ==, memcmp("123456", str, 6));
1151
+ ASSERT_CMPUINT32(count, ==, 1);
1152
+
1153
+ ASSERT(sets->substring_set != NULL);
1154
+ mc_substring_set_iter_t ss_it;
1155
+ mc_substring_set_iter_init(&ss_it, sets->substring_set);
1156
+ ASSERT(mc_substring_set_iter_next(&ss_it, &str, &len, &count));
1157
+ ASSERT_CMPUINT32(len, ==, 9);
1158
+ ASSERT_CMPINT(0, ==, memcmp("123456789", str, 9));
1159
+ ASSERT_CMPUINT32(count, ==, 1);
1160
+
1161
+ ASSERT_CMPUINT32(sets->exact.len, ==, 9);
1162
+ ASSERT_CMPINT(0, ==, memcmp(sets->exact.data, str, 9));
1163
+
1164
+ mc_str_encode_sets_destroy(sets);
1165
+ }
1166
+
1167
+ static void _test_text_search_str_encode_bad_string(_mongocrypt_tester_t *tester) {
1168
+ mongocrypt_status_t *status = mongocrypt_status_new();
1169
+ mc_FLE2TextSearchInsertSpec_t spec = {.v = "\xff\xff\xff\xff\xff\xff\xff\xff\xff",
1170
+ .len = 9,
1171
+ .substr = {{20, 4, 7}, true},
1172
+ .suffix = {{1, 5}, true},
1173
+ .prefix = {{6, 8}, true}};
1174
+ mc_str_encode_sets_t *sets = mc_text_search_str_encode(&spec, status);
1175
+ ASSERT_FAILS_STATUS(sets, status, "not valid UTF-8");
1176
+ mc_str_encode_sets_destroy(sets);
1177
+ mongocrypt_status_destroy(status);
1178
+ }
1179
+
1180
+ static void _test_text_search_str_encode_empty_string(_mongocrypt_tester_t *tester) {
1181
+ for (int casef = 0; casef <= 1; casef++) {
1182
+ for (int diacf = 0; diacf <= 1; diacf++) {
1183
+ test_nofold_suffix_prefix_case(tester, "", 1, 1, casef, diacf, 0);
1184
+ test_nofold_suffix_prefix_case(tester, "", 1, 2, casef, diacf, 0);
1185
+ test_nofold_suffix_prefix_case(tester, "", 2, 3, casef, diacf, 0);
1186
+ test_nofold_suffix_prefix_case(tester, "", 1, 16, casef, diacf, 0);
1187
+ test_nofold_suffix_prefix_case(tester, "", 1, 17, casef, diacf, 0);
1188
+ test_nofold_suffix_prefix_case(tester, "", 2, 16, casef, diacf, 0);
1189
+ test_nofold_suffix_prefix_case(tester, "", 2, 17, casef, diacf, 0);
1190
+
1191
+ test_nofold_substring_case_multiple_mlen(tester, "", 1, 1, 1, casef, diacf, 0);
1192
+ test_nofold_substring_case_multiple_mlen(tester, "", 1, 2, 1, casef, diacf, 0);
1193
+ test_nofold_substring_case_multiple_mlen(tester, "", 2, 3, 1, casef, diacf, 0);
1194
+ test_nofold_substring_case_multiple_mlen(tester, "", 1, 16, 1, casef, diacf, 0);
1195
+ test_nofold_substring_case_multiple_mlen(tester, "", 1, 17, 1, casef, diacf, 0);
1196
+ test_nofold_substring_case_multiple_mlen(tester, "", 2, 16, 1, casef, diacf, 0);
1197
+ test_nofold_substring_case_multiple_mlen(tester, "", 2, 17, 1, casef, diacf, 0);
1198
+ }
1199
+ }
1200
+ }
1201
+
1202
+ // Tests mc_text_search_str_query() fails on invalid utf-8.
1203
+ static void _test_text_search_str_query_bad_string(_mongocrypt_tester_t *tester) {
1204
+ mongocrypt_status_t *status = mongocrypt_status_new();
1205
+ _mongocrypt_buffer_t out;
1206
+ mc_FLE2TextSearchInsertSpec_t spec = {.v = "\xff\xff\xff\xff\xff\xff\xff\xff\xff", .len = 9};
1207
+
1208
+ bool res = mc_text_search_str_query(&spec, &out, status);
1209
+ ASSERT_FAILS_STATUS(res, status, "not valid UTF-8");
1210
+ mongocrypt_status_destroy(status);
1211
+ }
1212
+
1213
+ // Tests mc_text_search_str_query() checks the input string codepoint length against lb and ub
1214
+ // for substring, suffix, and prefix queries, and not for exact queres.
1215
+ static void _test_text_search_str_query_bounds_checking(_mongocrypt_tester_t *tester) {
1216
+ mc_FLE2TextSearchInsertSpec_t substrSpec = {.substr = {{.mlen = 20, .lb = 4, .ub = 7}, .set = true}};
1217
+ mc_FLE2TextSearchInsertSpec_t suffixSpec = {.suffix = {{.lb = 4, .ub = 7}, .set = true}};
1218
+ mc_FLE2TextSearchInsertSpec_t prefixSpec = {.prefix = {{.lb = 4, .ub = 7}, .set = true}};
1219
+ mc_FLE2TextSearchInsertSpec_t *specs[3] = {&substrSpec, &suffixSpec, &prefixSpec};
1220
+
1221
+ char *short_str = build_random_string_to_fold(3, 5);
1222
+ char *long_str = build_random_string_to_fold(8, 10);
1223
+
1224
+ mongocrypt_status_t *status = mongocrypt_status_new();
1225
+ _mongocrypt_buffer_t out;
1226
+
1227
+ for (int i = 0; i < 3; i++) {
1228
+ // long_str always fails regardless of folding
1229
+ for (int d = 0; d < 2; d++) {
1230
+ specs[i]->v = long_str;
1231
+ specs[i]->len = (uint32_t)strlen(specs[i]->v);
1232
+ specs[i]->diacf = d;
1233
+ ASSERT_FAILS_STATUS(mc_text_search_str_query(specs[i], &out, status),
1234
+ status,
1235
+ "longer than the maximum query length");
1236
+ _mongocrypt_buffer_cleanup(&out);
1237
+ _mongocrypt_status_reset(status);
1238
+ }
1239
+ // short_str only fails if diacritic folding is on
1240
+ specs[i]->v = short_str;
1241
+ specs[i]->len = (uint32_t)strlen(specs[i]->v);
1242
+ specs[i]->diacf = true;
1243
+ ASSERT_FAILS_STATUS(mc_text_search_str_query(specs[i], &out, status),
1244
+ status,
1245
+ "shorter than the minimum query length");
1246
+ _mongocrypt_buffer_cleanup(&out);
1247
+ _mongocrypt_status_reset(status);
1248
+
1249
+ specs[i]->diacf = false;
1250
+ ASSERT_OK_STATUS(mc_text_search_str_query(specs[i], &out, status), status);
1251
+ _mongocrypt_buffer_cleanup(&out);
1252
+ _mongocrypt_status_reset(status);
1253
+ }
1254
+
1255
+ // test no bounds checking performed if no substr/suffix/prefix specs
1256
+ mc_FLE2TextSearchInsertSpec_t exactSpecShort = {.diacf = true, .v = short_str, .len = (uint32_t)strlen(short_str)};
1257
+ mc_FLE2TextSearchInsertSpec_t exactSpecLong = {.diacf = true, .v = long_str, .len = (uint32_t)strlen(long_str)};
1258
+ ASSERT_OK_STATUS(mc_text_search_str_query(&exactSpecShort, &out, status), status);
1259
+ _mongocrypt_buffer_cleanup(&out);
1260
+ _mongocrypt_status_reset(status);
1261
+ ASSERT_OK_STATUS(mc_text_search_str_query(&exactSpecLong, &out, status), status);
1262
+
1263
+ _mongocrypt_buffer_cleanup(&out);
1264
+ mongocrypt_status_destroy(status);
1265
+ bson_free(short_str);
1266
+ bson_free(long_str);
1267
+ }
1268
+
1269
+ // Tests mc_text_search_str_query() rejects empty string input for substr/suffix/prefix queries,
1270
+ // but not for exact match queries.
1271
+ static void _test_text_search_str_query_empty_string(_mongocrypt_tester_t *tester) {
1272
+ mc_FLE2TextSearchInsertSpec_t substrSpec = {.substr = {{20, 4, 7}, true}, .v = "", .len = 0};
1273
+ mc_FLE2TextSearchInsertSpec_t suffixSpec = {.suffix = {{4, 7}, true}, .v = "", .len = 0};
1274
+ mc_FLE2TextSearchInsertSpec_t prefixSpec = {.prefix = {{4, 7}, true}, .v = "", .len = 0};
1275
+ mc_FLE2TextSearchInsertSpec_t exactSpec = {.v = "", .len = 0};
1276
+ mc_FLE2TextSearchInsertSpec_t *specs[3] = {&substrSpec, &suffixSpec, &prefixSpec};
1277
+ mongocrypt_status_t *status = mongocrypt_status_new();
1278
+ _mongocrypt_buffer_t out;
1279
+ for (int i = 0; i < 3; i++) {
1280
+ ASSERT_FAILS_STATUS(mc_text_search_str_query(specs[i], &out, status), status, "string value cannot be empty");
1281
+ _mongocrypt_buffer_cleanup(&out);
1282
+ _mongocrypt_status_reset(status);
1283
+ }
1284
+
1285
+ ASSERT_OK_STATUS(mc_text_search_str_query(&exactSpec, &out, status), status);
1286
+ _mongocrypt_buffer_cleanup(&out);
1287
+ mongocrypt_status_destroy(status);
1288
+ }
1289
+
1290
+ // Tests mc_text_search_str_query() performs folding per the diacf and casef parameters.
1291
+ static void _test_text_search_str_query_folding(_mongocrypt_tester_t *tester) {
1292
+ const char *testStr = "Düsseldorf";
1293
+ const char *diacFoldStr = "Dusseldorf";
1294
+ const char *caseFoldStr = "düsseldorf";
1295
+ const char *bothFoldStr = "dusseldorf";
1296
+ mc_FLE2TextSearchInsertSpec_t spec = {.v = testStr, .len = (uint32_t)strlen(testStr)};
1297
+ mongocrypt_status_t *status = mongocrypt_status_new();
1298
+ _mongocrypt_buffer_t out;
1299
+
1300
+ spec.diacf = true;
1301
+ ASSERT_OK_STATUS(mc_text_search_str_query(&spec, &out, status), status);
1302
+ ASSERT_CMPUINT32((uint32_t)strlen(diacFoldStr) + 5, ==, out.len); // +5 for BSON overhead
1303
+ ASSERT_STREQUAL(diacFoldStr, (const char *)(out.data + 4)); // +4 skips past 32-bit size field
1304
+
1305
+ _mongocrypt_buffer_cleanup(&out);
1306
+ _mongocrypt_status_reset(status);
1307
+
1308
+ spec.casef = true;
1309
+ spec.diacf = false;
1310
+ ASSERT_OK_STATUS(mc_text_search_str_query(&spec, &out, status), status);
1311
+ ASSERT_CMPUINT32((uint32_t)strlen(caseFoldStr) + 5, ==, out.len);
1312
+ ASSERT_STREQUAL(caseFoldStr, (const char *)(out.data + 4));
1313
+
1314
+ _mongocrypt_buffer_cleanup(&out);
1315
+ _mongocrypt_status_reset(status);
1316
+
1317
+ spec.diacf = true;
1318
+ ASSERT_OK_STATUS(mc_text_search_str_query(&spec, &out, status), status);
1319
+ ASSERT_CMPUINT32((uint32_t)strlen(bothFoldStr) + 5, ==, out.len);
1320
+ ASSERT_STREQUAL(bothFoldStr, (const char *)(out.data + 4));
1321
+
1322
+ _mongocrypt_buffer_cleanup(&out);
1323
+ mongocrypt_status_destroy(status);
1324
+ }
1325
+
1326
+ void _mongocrypt_tester_install_text_search_str_encode(_mongocrypt_tester_t *tester) {
1327
+ INSTALL_TEST(_test_text_search_str_encode_suffix_prefix);
1328
+ INSTALL_TEST(_test_text_search_str_encode_substring);
1329
+ INSTALL_TEST(_test_text_search_str_encode_multiple);
1330
+ INSTALL_TEST(_test_text_search_str_encode_bad_string);
1331
+ INSTALL_TEST(_test_text_search_str_encode_empty_string);
1332
+ INSTALL_TEST(_test_text_search_str_query_bad_string);
1333
+ INSTALL_TEST(_test_text_search_str_query_bounds_checking);
1334
+ INSTALL_TEST(_test_text_search_str_query_empty_string);
1335
+ INSTALL_TEST(_test_text_search_str_query_folding);
1336
+ }