summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/configExpand_rest_permissions.js
blob: 49749dddb9e09a7dcb34dcd214ff3796ff63c1a8 (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
27
28
29
30
31
32
33
34
35
// Test config file expansion using REST when permissions are too loose.
// @tags: [requires_http_client]

(function() {
'use strict';

load('jstests/noPassthrough/libs/configExpand/lib.js');

if (_isWindows()) {
    print("Skipping test on windows");
    return;
}

const web = new ConfigExpandRestServer();
web.start();

const sicReflect = {
    setParameter: {scramIterationCount: {__rest: web.getStringReflectionURL('12345')}}
};

// Positive test just to be sure this works in a basic case before testing negatives.
configExpandSuccess(sicReflect, null, {configExpand: 'rest', chmod: 0o600});

// Still successful if writable by others, but not readable.
configExpandSuccess(sicReflect, null, {configExpand: 'rest', chmod: 0o622});

// Fail if readable by others.
const expect = /is readable by non-owner users/;
configExpandFailure(sicReflect, expect, {configExpand: 'rest', chmod: 0o666});
configExpandFailure(sicReflect, expect, {configExpand: 'rest', chmod: 0o644});
configExpandFailure(sicReflect, expect, {configExpand: 'rest', chmod: 0o660});
configExpandFailure(sicReflect, expect, {configExpand: 'rest', chmod: 0o606});

web.stop();
})();