Files
@ c8d4251a6ea5
Branch filter:
Location: majic-ansible-roles/roles/database/molecule/default/tests/test_default.py - annotation
c8d4251a6ea5
1.4 KiB
text/x-python
MAR-131: Added support for specifying Python version in wsgi_website role:
- Introduced additional role parameter for specifying the Python
version.
- Updated tests to verify new functionality.
- Fixed existing tests to account for differences between Python 2 and
Python 3 - including changes to WSGI test applications.
- Updated documentation, documenting new parameter and fixing one
minor typo.
- Updated release notes.
- Bumped default version of Gunicorn/futures used.
- Introduced additional role parameter for specifying the Python
version.
- Updated tests to verify new functionality.
- Fixed existing tests to account for differences between Python 2 and
Python 3 - including changes to WSGI test applications.
- Updated documentation, documenting new parameter and fixing one
minor typo.
- Updated release notes.
- Bumped default version of Gunicorn/futures used.
fdba88395073 fdba88395073 c6e7675e63f9 c6e7675e63f9 fdba88395073 c6e7675e63f9 fdba88395073 c6e7675e63f9 c6e7675e63f9 8278ff584984 862402d2c45b 862402d2c45b 862402d2c45b c6e7675e63f9 8278ff584984 8278ff584984 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 8278ff584984 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 8278ff584984 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 8278ff584984 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 8278ff584984 862402d2c45b 862402d2c45b 862402d2c45b 862402d2c45b 8278ff584984 8278ff584984 862402d2c45b 862402d2c45b 862402d2c45b | import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts(['parameters-mandatory', 'parameters-optional'])
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"
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.
"""
visible_databases = host.run("mysql -utestdb -ptestdbpassword -BNe 'show databases'")
assert visible_databases.rc == 0
assert visible_databases.stdout == "information_schema\ntestdb"
with host.sudo():
permissions = host.run("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")
|