@@ -1009,12 +1009,22 @@ describe('FLE tests', function () {
10091009 ecoll.insertOne({ data: ce.encrypt(keyId, 'admin_explicit_test.pdf', explicitOpts) });
10101010 }` ) ;
10111011 const prefixResults = await shell . executeLine (
1012- 'coll.find({$expr: { $and: [{$encStrContains : {substring : "admin_", input: "$data"}}] }}, { __safeContent__: 0 }).toArray()'
1012+ 'coll.find({$expr: { $and: [{$encStrStartsWith : {prefix : "admin_", input: "$data"}}] }}, { __safeContent__: 0 }).toArray()'
10131013 ) ;
1014- expect ( prefixResults ) . to . have . length ( 2 ) ;
1014+ expect ( prefixResults ) . to . have . length ( 3 ) ;
10151015 expect ( prefixResults ) . to . include ( 'admin_user_123.txt' ) ;
10161016 expect ( prefixResults ) . to . include ( 'admin_super_456.pdf' ) ;
10171017 expect ( prefixResults ) . to . include ( 'admin_explicit_test.pdf' ) ;
1018+
1019+ const explicitPrefixResult = await shell . executeLine ( `
1020+ ecoll.findOne({$expr: { $and: [{$encStrStartsWith: {prefix:
1021+ ce.encrypt(keyId, 'admin_', { ...explicitOpts, queryType: 'prefixPreview' }), input: '$data'}}] }},
1022+ { __safeContent__: 0 })
1023+ ` ) ;
1024+ expect ( explicitPrefixResult ) . to . have . length ( 3 ) ;
1025+ expect ( explicitPrefixResult ) . to . include ( 'admin_user_123.txt' ) ;
1026+ expect ( explicitPrefixResult ) . to . include ( 'admin_super_456.pdf' ) ;
1027+ expect ( explicitPrefixResult ) . to . include ( 'admin_explicit_test.pdf' ) ;
10181028 } ) ;
10191029
10201030 it ( 'allows queryable encryption with suffix searches' , async function ( ) {
@@ -1030,12 +1040,22 @@ describe('FLE tests', function () {
10301040 }` ) ;
10311041
10321042 const suffixResults = await shell . executeLine (
1033- 'coll.find({$expr: { $and: [{$encStrContains : {substring : ".pdf", input: "$data"}}] }}, { __safeContent__: 0 }).toArray()'
1043+ 'coll.find({$expr: { $and: [{$encStrEndsWith : { suffix : ".pdf", input: "$data"}}] }}, { __safeContent__: 0 }).toArray()'
10341044 ) ;
10351045 expect ( suffixResults ) . to . have . length ( 3 ) ;
10361046 expect ( suffixResults ) . to . include ( 'admin_super_456.pdf' ) ;
10371047 expect ( suffixResults ) . to . include ( 'user_regular_789.pdf' ) ;
10381048 expect ( suffixResults ) . to . include ( 'admin_explicit_test.pdf' ) ;
1049+
1050+ const explicitSuffixResult = await shell . executeLine ( `
1051+ ecoll.findOne({$expr: { $and: [{$encStrEndsWith: {suffix:
1052+ ce.encrypt(keyId, '.pdf', { ...explicitOpts, queryType: 'suffixPreview' }), input: '$data'}}] }},
1053+ { __safeContent__: 0 })
1054+ ` ) ;
1055+ expect ( explicitSuffixResult ) . to . have . length ( 3 ) ;
1056+ expect ( explicitSuffixResult ) . to . include ( 'admin_super_456.pdf' ) ;
1057+ expect ( explicitSuffixResult ) . to . include ( 'user_regular_789.pdf' ) ;
1058+ expect ( explicitSuffixResult ) . to . include ( 'admin_explicit_test.pdf' ) ;
10391059 } ) ;
10401060
10411061 it ( 'allows queryable encryption with substring searches' , async function ( ) {
@@ -1050,13 +1070,6 @@ describe('FLE tests', function () {
10501070 // Add explicit encryption data
10511071 ecoll.insertOne({ data: ce.encrypt(keyId, 'explicit_user', explicitOpts) });
10521072 }` ) ;
1053- // Test substring search returning multiple documents
1054- const substringResults = await shell . executeLine (
1055- 'coll.find({$expr: { $and: [{$encStrContains: {substring: "user", input: "$data"}}] }}, { __safeContent__: 0 }).toArray()'
1056- ) ;
1057- expect ( substringResults ) . to . have . length ( 2 ) ;
1058- expect ( substringResults ) . to . include ( 'user_regular_789.pdf' ) ;
1059- expect ( substringResults ) . to . include ( 'admin_user_123.txt' ) ;
10601073
10611074 const testingSubstringResult = await shell . executeLine (
10621075 'coll.find({$expr: { $and: [{$encStrContains: {substring: "user", input: "$data"}}] }}, { __safeContent__: 0 }).toArray()'
0 commit comments