forked from mongodb/mongo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommands_builtin_roles_nonexistent.js
33 lines (30 loc) · 1.1 KB
/
commands_builtin_roles_nonexistent.js
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
30
31
32
33
/**
* Validates the test configuration in commands_builtin_roles.js
*
* Makes sure that none of the test cases reference roles
* that aren't part of the global "roles" array.
*/
import {roles} from "jstests/auth/lib/commands_builtin_roles.js";
import {authCommandsLib} from "jstests/auth/lib/commands_lib.js";
function checkForNonExistentRoles() {
const tests = authCommandsLib.tests;
for (let i = 0; i < tests.length; i++) {
const test = tests[i];
for (let j = 0; j < test.testcases.length; j++) {
let testcase = test.testcases[j];
for (let role in testcase.roles) {
let roleExists = false;
for (let k = 0; k < roles.length; k++) {
if (roles[k].key === role) {
roleExists = true;
break;
}
}
assert(roleExists,
"Role " + role + " found in test: " + test.testname +
", but doesn't exist in roles array");
}
}
}
}
checkForNonExistentRoles();