diff --git a/test/authentication_test.py b/test/authentication_test.py new file mode 100644 index 000000000..53394fbf7 --- /dev/null +++ b/test/authentication_test.py @@ -0,0 +1,43 @@ +import MySQLdb +from MySQLdb import OperationalError +from nose.tools import raises + +from proxysql_base_test import ProxySQLBaseTest + +class AuthenticationTest(ProxySQLBaseTest): + + DOCKER_COMPOSE_FILE = "./scenarios/1backend" + + def test_existing_user_with_correct_password_works(self): + version1 = self.run_query_mysql( + "SELECT @@version_comment LIMIT 1", "test", + return_result=True, + username="john", password="doe") + + version2 = self.run_query_proxysql( + "SELECT @@version_comment LIMIT 1", "test", + return_result=True, + username="john", password="doe") + + self.assertEqual(version1, version2) + + @raises(OperationalError) + def test_existing_user_with_correct_password_but_not_registerd_within_proxysql_does_not_work(self): + version1 = self.run_query_proxysql( + "SELECT @@version_comment LIMIT 1", "test", + return_result=True, + username="danny", password="white") + + @raises(OperationalError) + def test_existing_user_with_incorrect_password_does_not_work(self): + version = self.run_query_proxysql( + "SELECT @@version_comment LIMIT 1", "test", + return_result=True, + username="john", password="doe2") + + @raises(OperationalError) + def test_inexisting_user_with_random_password_does_not_work(self): + version = self.run_query_proxysql( + "SELECT @@version_comment LIMIT 1", "test", + return_result=True, + username="johnny", password="randomdoe") \ No newline at end of file