Skip to content

Commit 228bf37

Browse files
committed
NODE-910 Correctly handle bufferMaxEntries=0 when using authenticated connection in combination with connectWithNoPrimary=true
1 parent 24493de commit 228bf37

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

test/functional/authentication_tests.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,6 +1561,7 @@ exports.shouldCorrectlyAuthAgainstReplicaSetAdminDbUsingMongoClient = {
15611561

15621562
db_p.admin().addUser("me", "secret", {w:3, wtimeout:25000}, function runWhatever(err, result) {
15631563
// console.log("--------------------------------------------- 2")
1564+
// process.exit(0)
15641565

15651566
db_p.close();
15661567

test/functional/replset_connection_tests.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,3 +1474,28 @@ exports['Should correctly modify the server reconnectTries for all replset insta
14741474
});
14751475
}
14761476
}
1477+
1478+
/**
1479+
* @ignore
1480+
*/
1481+
exports['Should correctly connect to a replicaset with auth options, bufferMaxEntries and connectWithNoPrimary'] = {
1482+
metadata: { requires: { topology: 'replicaset' } },
1483+
1484+
// The actual test we wish to run
1485+
test: function(configuration, test) {
1486+
var mongo = configuration.require
1487+
, MongoClient = mongo.MongoClient
1488+
1489+
var url = f("mongodb://me:secret@localhost:%s,localhost:%s/integration_test_?replicaSet=%s"
1490+
, configuration.port + 1, configuration.port + 2, configuration.replicasetName)
1491+
1492+
MongoClient.connect(url, {
1493+
connectWithNoPrimary:true,
1494+
bufferMaxEntries: 0,
1495+
}, function(err, db) {
1496+
test.ok(err);
1497+
test.ok(err.message.indexOf('no connection available for operation and number of stored operation') == -1);
1498+
test.done();
1499+
});
1500+
}
1501+
}

0 commit comments

Comments
 (0)