-
Notifications
You must be signed in to change notification settings - Fork 694
/
Copy pathtest_securedrop_rqworker.py
52 lines (46 loc) · 1.61 KB
/
test_securedrop_rqworker.py
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
import testutils
sdvars = testutils.securedrop_test_vars
testinfra_hosts = [sdvars.app_hostname]
def test_securedrop_rqworker_service(host):
"""
Verify configuration of securedrop_rqworker systemd service.
"""
securedrop_test_vars = sdvars
service_file = "/lib/systemd/system/securedrop_rqworker.service"
expected_content = "\n".join(
[
"[Unit]",
"Description=SecureDrop rq worker",
"After=redis-server.service",
"Wants=redis-server.service",
"",
"[Service]",
'Environment=PYTHONPATH="{}:{}"'.format(
securedrop_test_vars.securedrop_code,
securedrop_test_vars.securedrop_venv_site_packages,
),
f"ExecStart={securedrop_test_vars.securedrop_venv_bin}/rqworker",
"PrivateDevices=yes",
"PrivateTmp=yes",
"ProtectSystem=full",
"ReadOnlyDirectories=/",
f"ReadWriteDirectories={securedrop_test_vars.securedrop_data}",
"Restart=always",
"RestartSec=10s",
"UMask=077",
f"User={securedrop_test_vars.securedrop_user}",
f"WorkingDirectory={securedrop_test_vars.securedrop_code}",
"",
"[Install]",
"WantedBy=multi-user.target\n",
]
)
f = host.file(service_file)
assert f.is_file
assert f.mode == 0o644
assert f.user == "root"
assert f.group == "root"
assert f.content_string == expected_content
s = host.service("securedrop_rqworker")
assert s.is_enabled
assert s.is_running