Skip to content

Commit 4a70e59

Browse files
chore(ci): skip rangePreview alogirthm related tests for server version >= 8.0.0-alpha (#1891)
1 parent bb1ce6b commit 4a70e59

File tree

1 file changed

+137
-130
lines changed

1 file changed

+137
-130
lines changed

packages/e2e-tests/test/e2e-fle.spec.ts

Lines changed: 137 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -715,146 +715,153 @@ describe('FLE tests', function () {
715715
// Since there is only one field to be encrypted hence there would only be one DEK in our keyvault collection
716716
expect(parseInt(dekCount.trim(), 10)).to.equal(1);
717717
});
718-
it('allows explicit range encryption with bypassQueryAnalysis', async function () {
719-
// No --cryptSharedLibPath since bypassQueryAnalysis is also a community edition feature
720-
const shell = TestShell.start({ args: ['--nodb'] });
721-
const uri = JSON.stringify(await testServer.connectionString());
722-
723-
await shell.waitForPrompt();
724718

725-
await shell.executeLine(`{
726-
client = Mongo(${uri}, {
727-
keyVaultNamespace: '${dbname}.keyVault',
728-
kmsProviders: { local: { key: 'A'.repeat(128) } },
729-
bypassQueryAnalysis: true
730-
});
731-
732-
keyVault = client.getKeyVault();
733-
clientEncryption = client.getClientEncryption();
734-
735-
// Create necessary data key
736-
dataKey = keyVault.createKey('local');
737-
738-
rangeOptions = {
739-
sparsity: Long(1),
740-
min: new Date('1970'),
741-
max: new Date('2100')
742-
};
743-
coll = client.getDB('${dbname}').encryptiontest;
744-
client.getDB('${dbname}').createCollection('encryptiontest', {
745-
encryptedFields: {
746-
fields: [{
747-
keyId: dataKey,
748-
path: 'v',
749-
bsonType: 'date',
750-
queries: [{
751-
queryType: 'rangePreview',
752-
contention: 4,
753-
...rangeOptions
719+
context('using rangePreview algorithm', function () {
720+
// TODO(MONGOSH-1742): Server 8.0 drops "rangePreview" algorithm and adds
721+
// "range". Re-enable these when the change is finalized
722+
skipIfServerVersion(testServer, '>= 8.0.0-alpha');
723+
724+
it('allows explicit range encryption with bypassQueryAnalysis', async function () {
725+
// No --cryptSharedLibPath since bypassQueryAnalysis is also a community edition feature
726+
const shell = TestShell.start({ args: ['--nodb'] });
727+
const uri = JSON.stringify(await testServer.connectionString());
728+
729+
await shell.waitForPrompt();
730+
731+
await shell.executeLine(`{
732+
client = Mongo(${uri}, {
733+
keyVaultNamespace: '${dbname}.keyVault',
734+
kmsProviders: { local: { key: 'A'.repeat(128) } },
735+
bypassQueryAnalysis: true
736+
});
737+
738+
keyVault = client.getKeyVault();
739+
clientEncryption = client.getClientEncryption();
740+
741+
// Create necessary data key
742+
dataKey = keyVault.createKey('local');
743+
744+
rangeOptions = {
745+
sparsity: Long(1),
746+
min: new Date('1970'),
747+
max: new Date('2100')
748+
};
749+
coll = client.getDB('${dbname}').encryptiontest;
750+
client.getDB('${dbname}').createCollection('encryptiontest', {
751+
encryptedFields: {
752+
fields: [{
753+
keyId: dataKey,
754+
path: 'v',
755+
bsonType: 'date',
756+
queries: [{
757+
queryType: 'rangePreview',
758+
contention: 4,
759+
...rangeOptions
760+
}]
754761
}]
755-
}]
762+
}
763+
});
764+
765+
// Encrypt and insert data encrypted with specified data key
766+
for (let year = 1990; year < 2010; year++) {
767+
const insertPayload = clientEncryption.encrypt(
768+
dataKey,
769+
new Date(year + '-02-02T12:45:16.277Z'),
770+
{
771+
algorithm: 'RangePreview',
772+
contentionFactor: 4,
773+
rangeOptions
774+
});
775+
coll.insertOne({ v: insertPayload, year });
756776
}
777+
}`);
778+
expect(
779+
await shell.executeLine('({ count: coll.countDocuments() })')
780+
).to.include('{ count: 20 }');
781+
782+
await shell.executeLine(`{
783+
findPayload = clientEncryption.encryptExpression(dataKey, {
784+
$and: [ { v: {$gt: new Date('1992')} }, { v: {$lt: new Date('1999')} } ]
785+
}, {
786+
algorithm: 'RangePreview',
787+
queryType: 'rangePreview',
788+
contentionFactor: 4,
789+
rangeOptions
757790
});
758-
759-
// Encrypt and insert data encrypted with specified data key
760-
for (let year = 1990; year < 2010; year++) {
761-
const insertPayload = clientEncryption.encrypt(
762-
dataKey,
763-
new Date(year + '-02-02T12:45:16.277Z'),
764-
{
765-
algorithm: 'RangePreview',
766-
contentionFactor: 4,
767-
rangeOptions
768-
});
769-
coll.insertOne({ v: insertPayload, year });
770-
}
771-
}`);
772-
expect(
773-
await shell.executeLine('({ count: coll.countDocuments() })')
774-
).to.include('{ count: 20 }');
775-
776-
await shell.executeLine(`{
777-
findPayload = clientEncryption.encryptExpression(dataKey, {
778-
$and: [ { v: {$gt: new Date('1992')} }, { v: {$lt: new Date('1999')} } ]
779-
}, {
780-
algorithm: 'RangePreview',
781-
queryType: 'rangePreview',
782-
contentionFactor: 4,
783-
rangeOptions
784-
});
785-
}`);
786-
787-
// Make sure the find payload allows searching for the encrypted values
788-
const out = await shell.executeLine(
789-
"\
790-
coll.find(findPayload) \
791-
.toArray() \
792-
.map(d => d.year) \
793-
.sort() \
794-
.join(',')"
795-
);
796-
expect(out).to.include('1992,1993,1994,1995,1996,1997,1998');
797-
});
798-
799-
it('allows automatic range encryption', async function () {
800-
// TODO(MONGOSH-1550): On s390x, we are using the 6.0.x RHEL7 shared library,
801-
// which does not support QE rangePreview. That's just fine for preview, but
802-
// we should switch to the 7.0.x RHEL8 shared library for Range GA.
803-
if (process.arch === 's390x') {
804-
return this.skip();
805-
}
806-
807-
const shell = TestShell.start({
808-
args: ['--nodb', `--cryptSharedLibPath=${cryptLibrary}`],
791+
}`);
792+
793+
// Make sure the find payload allows searching for the encrypted values
794+
const out = await shell.executeLine(
795+
"\
796+
coll.find(findPayload) \
797+
.toArray() \
798+
.map(d => d.year) \
799+
.sort() \
800+
.join(',')"
801+
);
802+
expect(out).to.include('1992,1993,1994,1995,1996,1997,1998');
809803
});
810-
const uri = JSON.stringify(await testServer.connectionString());
811804

812-
await shell.waitForPrompt();
805+
it('allows automatic range encryption', async function () {
806+
// TODO(MONGOSH-1550): On s390x, we are using the 6.0.x RHEL7 shared library,
807+
// which does not support QE rangePreview. That's just fine for preview, but
808+
// we should switch to the 7.0.x RHEL8 shared library for Range GA.
809+
if (process.arch === 's390x') {
810+
return this.skip();
811+
}
813812

814-
await shell.executeLine(`{
815-
client = Mongo(${uri}, {
816-
keyVaultNamespace: '${dbname}.keyVault',
817-
kmsProviders: { local: { key: 'A'.repeat(128) } }
813+
const shell = TestShell.start({
814+
args: ['--nodb', `--cryptSharedLibPath=${cryptLibrary}`],
818815
});
819-
820-
dataKey = client.getKeyVault().createKey('local');
821-
822-
coll = client.getDB('${dbname}').encryptiontest;
823-
client.getDB('${dbname}').createCollection('encryptiontest', {
824-
encryptedFields: {
825-
fields: [{
826-
keyId: dataKey,
827-
path: 'v',
828-
bsonType: 'date',
829-
queries: [{
830-
queryType: 'rangePreview',
831-
contention: 4,
832-
sparsity: 1,
833-
min: new Date('1970'),
834-
max: new Date('2100')
816+
const uri = JSON.stringify(await testServer.connectionString());
817+
818+
await shell.waitForPrompt();
819+
820+
await shell.executeLine(`{
821+
client = Mongo(${uri}, {
822+
keyVaultNamespace: '${dbname}.keyVault',
823+
kmsProviders: { local: { key: 'A'.repeat(128) } }
824+
});
825+
826+
dataKey = client.getKeyVault().createKey('local');
827+
828+
coll = client.getDB('${dbname}').encryptiontest;
829+
client.getDB('${dbname}').createCollection('encryptiontest', {
830+
encryptedFields: {
831+
fields: [{
832+
keyId: dataKey,
833+
path: 'v',
834+
bsonType: 'date',
835+
queries: [{
836+
queryType: 'rangePreview',
837+
contention: 4,
838+
sparsity: 1,
839+
min: new Date('1970'),
840+
max: new Date('2100')
841+
}]
835842
}]
836-
}]
843+
}
844+
});
845+
846+
for (let year = 1990; year < 2010; year++) {
847+
coll.insertOne({ v: new Date(year + '-02-02T12:45:16.277Z'), year })
837848
}
838-
});
839-
840-
for (let year = 1990; year < 2010; year++) {
841-
coll.insertOne({ v: new Date(year + '-02-02T12:45:16.277Z'), year })
842-
}
843-
}`);
844-
expect(
845-
await shell.executeLine('({ count: coll.countDocuments() })')
846-
).to.include('{ count: 20 }');
847-
848-
// Make sure the find payload allows searching for the encrypted values
849-
const out = await shell.executeLine(
850-
"\
851-
coll.find({ v: {$gt: new Date('1992'), $lt: new Date('1999') } }) \
852-
.toArray() \
853-
.map(d => d.year) \
854-
.sort() \
855-
.join(',')"
856-
);
857-
expect(out).to.include('1992,1993,1994,1995,1996,1997,1998');
849+
}`);
850+
expect(
851+
await shell.executeLine('({ count: coll.countDocuments() })')
852+
).to.include('{ count: 20 }');
853+
854+
// Make sure the find payload allows searching for the encrypted values
855+
const out = await shell.executeLine(
856+
"\
857+
coll.find({ v: {$gt: new Date('1992'), $lt: new Date('1999') } }) \
858+
.toArray() \
859+
.map(d => d.year) \
860+
.sort() \
861+
.join(',')"
862+
);
863+
expect(out).to.include('1992,1993,1994,1995,1996,1997,1998');
864+
});
858865
});
859866
});
860867

0 commit comments

Comments
 (0)