Skip to content

Commit 46e779d

Browse files
make byte sequence more unique
1 parent 971a65c commit 46e779d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

.evergreen/install-mongodb-client-encryption.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ set -o xtrace # Write all commands first to stderr
1010
set -o errexit # Exit the script with error if any of the commands fail
1111

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

1616
if [ -n "${LIBMONGOCRYPT_VERSION}" ]; then

test/integration/node-specific/bson-options/utf8_validation.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ describe('class MongoDBResponse', () => {
159159
);
160160
});
161161

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

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

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

191191
const document = {
192-
field: 'é'
192+
field: 'é'.repeat(8)
193193
};
194194

195195
await collection.insertOne(document);

0 commit comments

Comments
 (0)