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