-
Notifications
You must be signed in to change notification settings - Fork 695
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Converts config tests to testinfra "host" pragma
The old sytanx of automatic module imports as part of the test function args has been deprecated since testinfra v1.6.0 (2017-04-21). It's still working, but planned to be dropped as of testinfra v2.0. Took the opportunity to convert our checks throughout.
- Loading branch information
Conor Schaefer
committed
Feb 5, 2019
1 parent
db583f9
commit 66ac605
Showing
27 changed files
with
366 additions
and
358 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
testinfra_hosts = ["app-staging"] | ||
|
||
|
||
def test_haveged_config(File): | ||
def test_haveged_config(host): | ||
""" | ||
Ensure haveged's low entrop watermark is sufficiently high. | ||
""" | ||
f = File('/etc/default/haveged') | ||
f = host.file('/etc/default/haveged') | ||
assert f.is_file | ||
assert f.user == 'root' | ||
assert f.group == 'root' | ||
assert oct(f.mode) == '0644' | ||
assert f.contains('^DAEMON_ARGS="-w 2400"$') | ||
|
||
|
||
def test_haveged_no_duplicate_lines(Command): | ||
def test_haveged_no_duplicate_lines(host): | ||
""" | ||
Regression test to check for duplicate entries. Earlier playbooks | ||
for configuring the SD instances needlessly appended the `DAEMON_ARGS` | ||
line everytime the playbook was run. Fortunately the duplicate lines don't | ||
break the service, but it's still poor form. | ||
""" | ||
c = Command("uniq --repeated /etc/default/haveged") | ||
c = host.run("uniq --repeated /etc/default/haveged") | ||
assert c.rc == 0 | ||
assert c.stdout == "" | ||
|
||
|
||
def test_haveged_is_running(Service, Sudo): | ||
def test_haveged_is_running(host): | ||
""" | ||
Ensure haveged service is running, to provide additional entropy. | ||
""" | ||
# Sudo is necessary to read /proc when running under grsecurity, | ||
# sudo is necessary to read /proc when running under grsecurity, | ||
# which the App hosts do. Not technically necessary under development. | ||
with Sudo(): | ||
s = Service("haveged") | ||
with host.sudo(): | ||
s = host.service("haveged") | ||
assert s.is_running | ||
assert s.is_enabled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.