Skip to content

Commit

Permalink
make byte sequence more unique
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson committed Sep 4, 2024
1 parent 971a65c commit 46e779d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .evergreen/install-mongodb-client-encryption.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set -o xtrace # Write all commands first to stderr
set -o errexit # Exit the script with error if any of the commands fail

rm -rf mongodb-client-encryption
git clone https://github.com/mongodb-js/mongodb-client-encryption.git -b explicit-lifetime-chaining
git clone https://github.com/mongodb-js/mongodb-client-encryption.git
pushd mongodb-client-encryption

if [ -n "${LIBMONGOCRYPT_VERSION}" ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ describe('class MongoDBResponse', () => {
);
});

describe('utf8 validation with cursors', function () {
describe('utf8 validation with cursors' + i, function () {
let client: MongoClient;
let collection: Collection;

Expand All @@ -171,15 +171,15 @@ describe('utf8 validation with cursors', function () {
async function insertDocumentWithInvalidUTF8() {
const stub = sinon.stub(net.Socket.prototype, 'write').callsFake(function (...args) {
const providedBuffer = args[0].toString('hex');
const targetBytes = Buffer.from(').toString('hex');
const targetBytes = Buffer.from(document.field, 'utf-8').toString('hex');

if (providedBuffer.includes(targetBytes)) {
if (providedBuffer.split(targetBytes).length !== 2) {
sinon.restore();
const message = `expected exactly one c3a9 sequence, received ${providedBuffer.split(targetBytes).length}\n. command: ${inspect(deserialize(args[0]), { depth: Infinity })}`;
const message = `too many target bytes sequences: received ${providedBuffer.split(targetBytes).length}\n. command: ${inspect(deserialize(args[0]), { depth: Infinity })}`;
throw new Error(message);
}
const buffer = Buffer.from(providedBuffer.replace('c3a9', 'c301'), 'hex');
const buffer = Buffer.from(providedBuffer.replace(targetBytes, 'c301'.repeat(8)), 'hex');
const result = stub.wrappedMethod.apply(this, [buffer]);
sinon.restore();
return result;
Expand All @@ -189,7 +189,7 @@ describe('utf8 validation with cursors', function () {
});

const document = {
field: 'é'
field: 'é'.repeat(8)
};

await collection.insertOne(document);
Expand Down

0 comments on commit 46e779d

Please sign in to comment.