summaryrefslogtreecommitdiff
path: root/jstests/selinux/lib/selinux_base_test.js
blob: 395cd19a1791de1f606a6e613939d1d8439a46cb (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
58
59
60
61
62
63
'use strict';

/**
 * An "abstract" base selinux test class, containing common functions that should be
 * assumed to be called by a test executor.
 *
 * Implementations for the test can extend this base clase in order to integrate
 * into evergreen/selinux_test_executor.sh
 *
 * NOTE: Implementations for this exist in both community and enterprise,
 * be cautious about modifying the base class.
 */
class SelinuxBaseTest {
    /**
     * Returns the "base" configuration per the rpm mongod.conf
     * Inheriting classes should use this base configuration and
     * extend the returned object as necessary
     */
    get config() {
        return {
            "systemLog": {
                "destination": "file",
                "logAppend": true,
                "path": "/var/log/mongodb/mongod.log",
                "verbosity": 0
            },
            "processManagement": {
                "pidFilePath": "/var/run/mongodb/mongod.pid",
                "timeZoneInfo": "/usr/share/zoneinfo"
            },
            "net": {"port": 27017, "bindIp": "127.0.0.1"},
            "storage": {"dbPath": "/var/lib/mongo"}
        };
    }

    // Notice: private definitions, e.g.: #sudo() are not
    // recognized by js linter, so leaving this declaration public
    sudo(script) {
        return run("sudo", "--non-interactive", "bash", "-c", script);
    }

    /**
     * Called by test executors (e.g. evergreen/selinux_test_executor.sh)
     * to set up the test environment
     */
    setup() {
    }

    /**
     * Called by test executors (e.g. evergreen/selinux_test_executor.sh)
     * to tear down test configurations at the end of the test run
     */
    teardown() {
    }

    /**
     * Called by test executors (e.g. evergreen/selinux_test_executor.sh)
     * to run the test. Inheriting classes must override this to run their tests
     */
    async run() {
        assert("override this function");
    }
}