Files
@ 36e1c9460cd6
Branch filter:
Location: majic-ansible-roles/roles/database/tests/test_default.py - annotation
36e1c9460cd6
1.4 KiB
text/x-python
MAR-27: Added initial scaffolding for testing mail_forwarder role:
- Fixed issues reported by Ansible linting check (some mode-related syntax and
one ignore.
- Added Molecule configuration for testing mandatory and optional
parameters. Covers both Debian Jessie and Debian Stretch.
- Added test playbook for setting-up the test instances. A helper relay mail
server.
- Updated both mail_server and mail_forwarder to fall-back to using
native (/etc/hosts) resolving if DNS fails. Solves issue with test environment
not having proper DNS set-up for all domains etc.
- Added a number of data/config files associated with tests.
- Added dummy test file.
- Fixed issues reported by Ansible linting check (some mode-related syntax and
one ignore.
- Added Molecule configuration for testing mandatory and optional
parameters. Covers both Debian Jessie and Debian Stretch.
- Added test playbook for setting-up the test instances. A helper relay mail
server.
- Updated both mail_server and mail_forwarder to fall-back to using
native (/etc/hosts) resolving if DNS fails. Solves issue with test environment
not having proper DNS set-up for all domains etc.
- Added a number of data/config files associated with tests.
- Added dummy test file.
c6e7675e63f9 c6e7675e63f9 c6e7675e63f9 c6e7675e63f9 c6e7675e63f9 c6e7675e63f9 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b c6e7675e63f9 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b | import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
'.molecule/ansible_inventory').get_hosts('all')
def test_database_created(Command, Sudo):
"""
Tests if database has been created.
"""
with Sudo():
show_databases = Command("mysql -BNe \"show databases like 'testdb'\"")
assert show_databases.rc == 0
assert show_databases.stdout == "testdb"
def test_database_user_login(Command):
"""
Tests database user login.
"""
login = Command("mysql -utestdb -ptestdbpassword -BNe 'show databases'")
assert login.rc == 0
def test_database_user_permissions(Command, Sudo):
"""
Tests if database user has been granted correct permissions on the database.
"""
visible_databases = Command("mysql -utestdb -ptestdbpassword -BNe 'show databases'")
assert visible_databases.rc == 0
assert visible_databases.stdout == "information_schema\ntestdb"
with Sudo():
permissions = Command("mysql -BNe 'show grants for testdb@localhost'")
assert len(permissions.stdout.split("\n")) == 2
assert "GRANT USAGE ON *.* TO 'testdb'@'localhost' IDENTIFIED BY PASSWORD '*676852B7FAE972722AD20D6E74781D6B1A100544'" in permissions.stdout.split("\n")
assert "GRANT ALL PRIVILEGES ON `testdb`.* TO 'testdb'@'localhost'" in permissions.stdout.split("\n")
|