Files
@ 3dd7f39302f8
Branch filter:
Location: majic-ansible-roles/roles/database_server/tests/test_default.py - annotation
3dd7f39302f8
3.0 KiB
text/x-python
MAR-29: Implemented tests for php_website role:
- Install some additional tools for testing everything.
- Updated test playbook to change allowed extensions for running PHP scripts on
parameters-optional.
- Updated error page to use correct extension for parameters-optional test
instance.
- Expanded rewrite configuration slightly for parameters-optional.
- Install libmariadb-client-lgpl-dev-compat to test mysql_config symlink
creation.
- Deploy a number of PHP pages used for testing if pages are served correctly.
- Set file permissions on deployed PHP FPM pool configuraiton files.
- Use expanded syntax when deploying TLS keys/certificates in order to avoid
issues with TAB mangling.
- Fixed set-up of Strict-Transport-Security header when HTTPS enforcement is
disabled.
- Added a number of PHP and static test pages.
- Wrote tests covering full functionality of the role.
- Install some additional tools for testing everything.
- Updated test playbook to change allowed extensions for running PHP scripts on
parameters-optional.
- Updated error page to use correct extension for parameters-optional test
instance.
- Expanded rewrite configuration slightly for parameters-optional.
- Install libmariadb-client-lgpl-dev-compat to test mysql_config symlink
creation.
- Deploy a number of PHP pages used for testing if pages are served correctly.
- Set file permissions on deployed PHP FPM pool configuraiton files.
- Use expanded syntax when deploying TLS keys/certificates in order to avoid
issues with TAB mangling.
- Fixed set-up of Strict-Transport-Security header when HTTPS enforcement is
disabled.
- Added a number of PHP and static test pages.
- Wrote tests covering full functionality of the role.
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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 18f93a9a8b05 | import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
'.molecule/ansible_inventory').get_hosts('all')
def test_installed_packages(Package):
"""
Tests if the correct packages have been installed.
"""
assert Package('mariadb-client').is_installed
assert Package('mariadb-server').is_installed
assert Package('python-mysqldb').is_installed
def test_service(Service):
"""
Tests if the database server service is enabled on boot and running.
"""
service = Service('mysql')
assert service.is_enabled
assert service.is_running
def test_root_password(Command):
"""
Tests if the root password has been set correctly.
"""
login = Command("mysql -uroot -proot_password -BNe 'show databases'")
assert login.rc == 0
assert "information_schema" in login.stdout
assert "mysql" in login.stdout
assert "performance_schema" in login.stdout
def test_root_my_cnf(File, Sudo):
"""
Tests if the root my.cnf configuration has been set-up with correct
user/password and permissions.
"""
with Sudo():
my_cnf = File('/root/.my.cnf')
assert my_cnf.is_file
assert my_cnf.user == 'root'
assert my_cnf.group == 'root'
assert my_cnf.mode == 0o400
assert "user=root" in my_cnf.content
assert "password=root_password" in my_cnf.content
def test_root_my_cnf_login(Command, Sudo):
"""
Tets if the database server root login works using just the my.cnf
configuration file.
"""
with Sudo():
login = Command("mysql -BNe 'show databases'")
assert "information_schema" in login.stdout
assert "mysql" in login.stdout
assert "performance_schema" in login.stdout
def test_utf8_configuration_file(File):
"""
Tests if UTF-8 database server configuration file has been deployed
correctly.
"""
config = File('/etc/mysql/conf.d/utf8.cnf')
assert config.is_file
assert config.user == 'root'
assert config.group == 'root'
assert config.mode == 0o644
def test_utf8_configuration(Command):
"""
Tests if UTF-8 configuration has been applied correctly to server.
"""
assert Command("mysql -uroot -proot_password -BNe 'drop database if exists test'").rc == 0
assert Command("mysql -uroot -proot_password -BNe 'create database test'").rc == 0
check_server = Command("mysql -uroot -proot_password test -BNe 'select @@character_set_server; select @@collation_server'")
assert check_server.rc == 0
assert check_server.stdout == "utf8\nutf8_general_ci"
check_database = Command("mysql -uroot -proot_password test -BNe 'select @@character_set_database; select @@collation_database'")
assert check_database.rc == 0
assert check_database.stdout == "utf8\nutf8_general_ci"
check_database = Command("mysql -uroot -proot_password -BNe 'select @@character_set_connection; select @@collation_connection'")
assert check_database.rc == 0
assert check_database.stdout == "utf8\nutf8_general_ci"
|