fix(docker): modify db configuration for new tests

A user that can create databases is now required for tests,
we use the 'root' user in Docker.

Added docker services:
---------------------
- mariadb_test - host localhost:13307

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-11-17 00:44:35 -08:00
parent fa43f6bc3e
commit fa26c8078b
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
12 changed files with 53 additions and 79 deletions

View file

@ -13,23 +13,18 @@ done
# Configure databases.
DATABASE="aurweb" # Persistent database for fastapi/php-fpm.
TEST_DB="aurweb_test" # Test database (ephemereal).
echo "Taking care of primary database '${DATABASE}'..."
mysql -u root -e "CREATE USER IF NOT EXISTS 'aur'@'localhost' IDENTIFIED BY 'aur';"
mysql -u root -e "CREATE USER IF NOT EXISTS 'aur'@'%' IDENTIFIED BY 'aur';"
mysql -u root -e "CREATE DATABASE IF NOT EXISTS $DATABASE;"
mysql -u root -e "GRANT ALL ON ${DATABASE}.* TO 'aur'@'localhost';"
mysql -u root -e "GRANT ALL ON ${DATABASE}.* TO 'aur'@'%';"
# Drop and create our test database.
echo "Dropping test database '$TEST_DB'..."
mysql -u root -e "DROP DATABASE IF EXISTS $TEST_DB;"
mysql -u root -e "CREATE DATABASE $TEST_DB;"
mysql -u root -e "GRANT ALL ON ${TEST_DB}.* TO 'aur'@'localhost';"
mysql -u root -e "GRANT ALL ON ${TEST_DB}.* TO 'aur'@'%';"
mysql -u root -e "CREATE USER IF NOT EXISTS 'aur'@'%' IDENTIFIED BY 'aur';"
mysql -u root -e "GRANT ALL ON aurweb.* TO 'aur'@'localhost';"
mysql -u root -e "GRANT ALL ON aurweb.* TO 'aur'@'%';"
echo "Created new '$TEST_DB'!"
mysql -u root -e "CREATE USER IF NOT EXISTS 'root'@'%' IDENTIFIED BY 'aur';"
mysql -u root -e "GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION;"
mysqladmin -uroot shutdown