blob: 71c976586d7a1a83de22a4c0bfa012cce2ec64a1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
// Test that you can still authenticate a replset connection to a RS with no primary (SERVER-6665).
(function () {
var NODE_COUNT = 3;
var rs = new ReplSetTest({"nodes" : NODE_COUNT, keyFile : "jstests/libs/key1"});
var nodes = rs.startSet();
rs.initiate();
// Add user
var master = rs.getMaster();
master.getDB("admin").createUser({user: "admin", pwd: "pwd", roles: ["root"]}, {w: NODE_COUNT});
// Can authenticate replset connection when whole set is up.
var conn = new Mongo(rs.getURL());
assert(conn.getDB('admin').auth('admin', 'pwd'));
assert.writeOK(conn.getDB('admin').foo.insert({a:1}, { writeConcern: { w: NODE_COUNT } }));
// Make sure there is no primary
rs.stop(0);
rs.stop(1);
rs.waitForState(nodes[2], rs.SECONDARY);
// Make sure you can still authenticate a replset connection with no primary
var conn2 = new Mongo(rs.getURL());
conn2.setSlaveOk(true);
assert(conn2.getDB('admin').auth({user:'admin', pwd:'pwd', mechanism:"SCRAM-SHA-1"}));
assert.eq(1, conn2.getDB('admin').foo.findOne().a);
rs.stopSet();
}());
|