File: auth2.js

package info (click to toggle)
mongodb 1%3A3.2.11-2%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 196,404 kB
  • sloc: cpp: 1,412,793; ansic: 504,961; python: 78,522; perl: 5,837; sh: 5,661; java: 4,202; makefile: 1,784; pascal: 617; xml: 176; asm: 128
file content (23 lines) | stat: -rw-r--r-- 673 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var st = new ShardingTest({
    keyFile: 'jstests/libs/key1',
    shards: 2,
    chunkSize: 1,
    verbose: 2,
    other: {nopreallocj: 1, verbose: 2, useHostname: true, configOptions: {verbose: 2}}
});

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();