summaryrefslogtreecommitdiff
path: root/jstests/sharding/auth2.js
blob: d1d6cb20156f6908935f81eb1ce99d12b1a81d9b (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
(function() {
'use strict';

// TODO: Remove 'shardAsReplicaSet: false' when SERVER-32672 is fixed.
var st = new ShardingTest({
    shards: 2,
    other:
        {chunkSize: 1, useHostname: true, keyFile: 'jstests/libs/key1', shardAsReplicaSet: false},
});

var mongos = st.s;
var adminDB = mongos.getDB('admin');
var db = mongos.getDB('test');

adminDB.createUser({user: 'admin', pwd: 'password', roles: jsTest.adminUserRoles});

jsTestLog("Add user was successful");

// Test for SERVER-6549, make sure that repeatedly logging in always passes.
for (var i = 0; i < 100; i++) {
    adminDB = new Mongo(mongos.host).getDB('admin');
    assert(adminDB.auth('admin', 'password'), "Auth failed on attempt #: " + i);
}

st.stop();
})();