summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/configExpand_exec_digest.js
blob: e01c1fcd1d656e75b049ae9521e598cd5ab0cc97 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Test config file expansion using EXEC with digests.

(function() {
'use strict';

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

// hash === SHA256HMAC('12345', 'secret')
const hash = 'f88c7ebe4740db59c873cecf5e1f18e3726a1ad64068a13d764b79028430ab0e';

// Simple positive case.
configExpandSuccess({
    setParameter: {
        scramIterationCount:
            {__exec: makeReflectionCmd('12345'), digest: hash, digest_key: '736563726574'}
    }
});

// Invalid digest length.
configExpandFailure({
    setParameter: {
        scramIteratorCount:
            {__exec: makeReflectionCmd('12345'), digest: '123', digest_key: '736563726574'}
    }
},
                    /digest: Not a valid, even length hex string/);

// Invalid characters.
configExpandFailure({
    setParameter: {
        scramIteratorCount:
            {__exec: makeReflectionCmd('12345'), digest: hash, digest_key: '736563X26574'}
    }
},
                    /digest_key: Not a valid, even length hex string/);

// Digest without key.
configExpandFailure(
    {setParameter: {scramIteratorCount: {__exec: makeReflectionCmd('12345'), digest: hash}}},
    /digest requires digest_key/);

// Empty digest_key.
configExpandFailure({
    setParameter:
        {scramIteratorCount: {__exec: makeReflectionCmd('12345'), digest: hash, digest_key: ''}}
},
                    /digest_key must not be empty/);

// Mismatched digests.
configExpandFailure({
    setParameter: {
        scramIteratorCount:
            {__exec: makeReflectionCmd('12345'), digest: hash, digest_key: '736563726575'}
    }
},
                    /does not match expected digest/);
})();