diff options
Diffstat (limited to 'jstests/auth/autocomplete_auth.js')
-rw-r--r-- | jstests/auth/autocomplete_auth.js | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/jstests/auth/autocomplete_auth.js b/jstests/auth/autocomplete_auth.js index c0057bf1e52..35450ecbca6 100644 --- a/jstests/auth/autocomplete_auth.js +++ b/jstests/auth/autocomplete_auth.js @@ -15,38 +15,38 @@ const self = this; (function() { - 'use strict'; +'use strict'; - const testName = jsTest.name(); - const conn = MongoRunner.runMongod({auth: ''}); - const admin = conn.getDB('admin'); - admin.createUser({user: 'admin', pwd: 'pass', roles: jsTest.adminUserRoles}); - assert(admin.auth('admin', 'pass')); +const testName = jsTest.name(); +const conn = MongoRunner.runMongod({auth: ''}); +const admin = conn.getDB('admin'); +admin.createUser({user: 'admin', pwd: 'pass', roles: jsTest.adminUserRoles}); +assert(admin.auth('admin', 'pass')); - admin.getSiblingDB(testName).createRole({ - role: 'coachTicket', - privileges: [{resource: {db: testName, collection: 'coachClass'}, actions: ['find']}], - roles: [] - }); +admin.getSiblingDB(testName).createRole({ + role: 'coachTicket', + privileges: [{resource: {db: testName, collection: 'coachClass'}, actions: ['find']}], + roles: [] +}); - admin.getSiblingDB(testName).createUser( - {user: 'coachPassenger', pwd: 'password', roles: ['coachTicket']}); +admin.getSiblingDB(testName).createUser( + {user: 'coachPassenger', pwd: 'password', roles: ['coachTicket']}); - const testDB = conn.getDB(testName); - testDB.coachClass.insertOne({}); - testDB.businessClass.insertOne({}); +const testDB = conn.getDB(testName); +testDB.coachClass.insertOne({}); +testDB.businessClass.insertOne({}); - // Must use 'db' to test autocompletion. - self.db = new Mongo(conn.host).getDB(testName); - assert(db.auth('coachPassenger', 'password')); - const authzErrorCode = 13; - assert.commandFailedWithCode(db.runCommand({listCollections: 1}), authzErrorCode); - assert.commandWorked(db.runCommand({find: 'coachClass'})); - assert.commandFailedWithCode(db.runCommand({find: 'businessClass'}), authzErrorCode); - shellAutocomplete('db.'); - assert(__autocomplete__.includes('db.coachClass'), - `Completions should include 'coachClass': ${__autocomplete__}`); - assert(!__autocomplete__.includes('db.businessClass'), - `Completions should NOT include 'businessClass': ${__autocomplete__}`); - MongoRunner.stopMongod(conn); +// Must use 'db' to test autocompletion. +self.db = new Mongo(conn.host).getDB(testName); +assert(db.auth('coachPassenger', 'password')); +const authzErrorCode = 13; +assert.commandFailedWithCode(db.runCommand({listCollections: 1}), authzErrorCode); +assert.commandWorked(db.runCommand({find: 'coachClass'})); +assert.commandFailedWithCode(db.runCommand({find: 'businessClass'}), authzErrorCode); +shellAutocomplete('db.'); +assert(__autocomplete__.includes('db.coachClass'), + `Completions should include 'coachClass': ${__autocomplete__}`); +assert(!__autocomplete__.includes('db.businessClass'), + `Completions should NOT include 'businessClass': ${__autocomplete__}`); +MongoRunner.stopMongod(conn); })(); |