summaryrefslogtreecommitdiff
path: root/jstests/auth/scram-credentials-invalid.js
diff options
context:
space:
mode:
Diffstat (limited to 'jstests/auth/scram-credentials-invalid.js')
-rw-r--r--jstests/auth/scram-credentials-invalid.js75
1 files changed, 36 insertions, 39 deletions
diff --git a/jstests/auth/scram-credentials-invalid.js b/jstests/auth/scram-credentials-invalid.js
index c5553c31f26..282c5c06cc9 100644
--- a/jstests/auth/scram-credentials-invalid.js
+++ b/jstests/auth/scram-credentials-invalid.js
@@ -2,43 +2,40 @@
// user with invalid SCRAM-SHA-1 credentials fails gracefully.
(function() {
- 'use strict';
-
- function runTest(mongod) {
- assert(mongod);
- const admin = mongod.getDB('admin');
- const test = mongod.getDB('test');
-
- admin.createUser({user: 'admin', pwd: 'pass', roles: jsTest.adminUserRoles});
- assert(admin.auth('admin', 'pass'));
-
- test.createUser({user: 'user', pwd: 'pass', roles: jsTest.basicUserRoles});
-
- // Give the test user an invalid set of SCRAM-SHA-1 credentials.
- assert.eq(admin.system.users
- .update({_id: "test.user"}, {
- $set: {
- "credentials.SCRAM-SHA-1": {
- salt: "AAAA",
- storedKey: "AAAA",
- serverKey: "AAAA",
- iterationCount: 10000
- }
- }
- })
- .nModified,
- 1,
- "Should have updated one document for user@test");
- admin.logout();
-
- const error = assert.throws(function() {
- test._authOrThrow({user: 'user', pwd: 'pass'});
- });
-
- assert.eq(error, "Error: credential document SCRAM-SHA-1 failed validation");
- }
-
- const mongod = MongoRunner.runMongod({auth: "", useLogFiles: true});
- runTest(mongod);
- MongoRunner.stopMongod(mongod);
+'use strict';
+
+function runTest(mongod) {
+ assert(mongod);
+ const admin = mongod.getDB('admin');
+ const test = mongod.getDB('test');
+
+ admin.createUser({user: 'admin', pwd: 'pass', roles: jsTest.adminUserRoles});
+ assert(admin.auth('admin', 'pass'));
+
+ test.createUser({user: 'user', pwd: 'pass', roles: jsTest.basicUserRoles});
+
+ // Give the test user an invalid set of SCRAM-SHA-1 credentials.
+ assert.eq(
+ admin.system.users
+ .update({_id: "test.user"}, {
+ $set: {
+ "credentials.SCRAM-SHA-1":
+ {salt: "AAAA", storedKey: "AAAA", serverKey: "AAAA", iterationCount: 10000}
+ }
+ })
+ .nModified,
+ 1,
+ "Should have updated one document for user@test");
+ admin.logout();
+
+ const error = assert.throws(function() {
+ test._authOrThrow({user: 'user', pwd: 'pass'});
+ });
+
+ assert.eq(error, "Error: credential document SCRAM-SHA-1 failed validation");
+}
+
+const mongod = MongoRunner.runMongod({auth: "", useLogFiles: true});
+runTest(mongod);
+MongoRunner.stopMongod(mongod);
})();