Files
@ b3e67fd6c0c1
Branch filter:
Location: majic-ansible-roles/roles/database/molecule/default/tests/test_default.py - annotation
b3e67fd6c0c1
1.5 KiB
text/x-python
MAR-187: Reorder the deprecation tasks for xmpp_server role to make the runs reliable:
- Deprecated apt repository really needs to be removed first in case
it has an unresolvable URL (so the backports repository cache update
would trigger correctly).
- Use the file removal for Prosody repository as well to make sure the
file is dropped.
- Deprecated apt repository really needs to be removed first in case
it has an unresolvable URL (so the backports repository cache update
would trigger correctly).
- Use the file removal for Prosody repository as well to make sure the
file is dropped.
fdba88395073 fdba88395073 c6e7675e63f9 c6e7675e63f9 fdba88395073 c6e7675e63f9 d62b3adec462 c6e7675e63f9 c6e7675e63f9 8278ff584984 862402d2c45b 862402d2c45b 862402d2c45b c6e7675e63f9 8278ff584984 8278ff584984 862402d2c45b 862402d2c45b 18195f35a1bf 862402d2c45b 862402d2c45b 8278ff584984 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 8278ff584984 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 8278ff584984 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 85d033089f0e 85d033089f0e cfe67ad68fc5 8278ff584984 862402d2c45b 862402d2c45b 18195f35a1bf 862402d2c45b 8278ff584984 18195f35a1bf 18195f35a1bf 18195f35a1bf cfe67ad68fc5 cfe67ad68fc5 | import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('parameters-*')
def test_database_created(host):
"""
Tests if database has been created.
"""
with host.sudo():
show_databases = host.run("mysql -BNe \"show databases like 'testdb'\"")
assert show_databases.rc == 0
assert show_databases.stdout == "testdb\n"
def test_database_user_login(host):
"""
Tests database user login.
"""
login = host.run("mysql -utestdb -ptestdbpassword -BNe 'show databases'")
assert login.rc == 0
def test_database_user_permissions(host):
"""
Tests if database user has been granted correct permissions on the database.
"""
expected_usage = "GRANT USAGE ON *.* TO `testdb`@`localhost` IDENTIFIED BY PASSWORD '*676852B7FAE972722AD20D6E74781D6B1A100544'"
expected_privileges = "GRANT ALL PRIVILEGES ON `testdb`.* TO `testdb`@`localhost`"
visible_databases = host.run("mysql -utestdb -ptestdbpassword -BNe 'show databases'")
assert visible_databases.rc == 0
assert visible_databases.stdout == "information_schema\ntestdb\n"
with host.sudo():
permissions_command = host.run("mysql -BNe 'show grants for testdb@localhost'")
permissions = permissions_command.stdout.rstrip().split("\n")
assert len(permissions) == 2
assert expected_usage in permissions
assert expected_privileges in permissions
|