Skip to content

Commit

Permalink
tests: move test_mariadb_auth into test_connection
Browse files Browse the repository at this point in the history
  • Loading branch information
grooverdan committed Oct 1, 2021
1 parent e1ac86e commit af21955
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 47 deletions.
8 changes: 0 additions & 8 deletions .github/workflows/test.yaml
Expand Up @@ -12,15 +12,12 @@ jobs:
include:
- db: "mariadb:10.2"
py: "3.9"
mariadb_auth: true

- db: "mariadb:10.3"
py: "3.8"
mariadb_auth: true

- db: "mariadb:10.5"
py: "3.7"
mariadb_auth: true

- db: "mysql:5.6"
py: "3.6"
Expand Down Expand Up @@ -89,11 +86,6 @@ jobs:
docker cp mysqld:/var/lib/mysql/client-cert.pem "${HOME}"
pytest -v --cov --cov-config .coveragerc tests/test_auth.py;
- name: Run MariaDB auth test
if: ${{ matrix.mariadb_auth }}
run: |
pytest -v --cov --cov-config .coveragerc tests/test_mariadb_auth.py
- name: Report coverage
run: coveralls --service=github
env:
Expand Down
15 changes: 0 additions & 15 deletions ci/docker-entrypoint-initdb.d/mariadb.sql
@@ -1,17 +1,2 @@
/*M!100401 CREATE USER nopass_ed25519 IDENTIFIED VIA ed25519 USING PASSWORD('') */;
/*M!100401 CREATE USER user_ed25519 IDENTIFIED VIA ed25519 USING PASSWORD('pass_ed25519') */;
/*M!100122 INSTALL SONAME "auth_ed25519" */;
--
-- MariaDB [(none)]> select ed25519_password("");
-- +---------------------------------------------+
-- | ed25519_password("") |
-- +---------------------------------------------+
-- | 4LH+dBF+G5W2CKTyId8xR3SyDqZoQjUNUVNxx8aWbG4 |
-- +---------------------------------------------+
--

/*M!100401 CREATE USER nopass_ed25519 IDENTIFIED VIA ed25519 USING '4LH+dBF+G5W2CKTyId8xR3SyDqZoQjUNUVNxx8aWbG4' */;
/*M!100401 CREATE USER user_ed25519 IDENTIFIED VIA ed25519 USING PASSWORD('pass_ed25519') */;
/*M!100122 CREATE FUNCTION ed25519_password RETURNS STRING SONAME "auth_ed25519.so" */;
/*M!100203 EXECUTE IMMEDIATE CONCAT('CREATE USER IF NOT EXISTS nopass_ed25519 IDENTIFIED VIA ed25519 USING "', ed25519_password("") ,'";') */;
/*M!100203 EXECUTE IMMEDIATE CONCAT('CREATE USER IF NOT EXISTS user_ed25519 IDENTIFIED VIA ed25519 USING "', ed25519_password("pass_ed25519") ,'";') */;
32 changes: 32 additions & 0 deletions pymysql/tests/test_connection.py
Expand Up @@ -53,6 +53,7 @@ class TestAuthentication(base.PyMySQLTestCase):
pam_found = False
mysql_old_password_found = False
sha256_password_found = False
ed25519_found = False

import os

Expand Down Expand Up @@ -97,6 +98,8 @@ class TestAuthentication(base.PyMySQLTestCase):
mysql_old_password_found = True
elif r[0] == "sha256_password":
sha256_password_found = True
elif r[0] == "ed25519":
ed25519_found = True
# else:
# print("plugin: %r" % r[0])

Expand Down Expand Up @@ -412,6 +415,35 @@ def testAuthSHA256(self):
with self.assertRaises(pymysql.err.OperationalError):
pymysql.connect(user="pymysql_sha256", **db)

@pytest.mark.skipif(not ed25519_found, reason="no ed25519 authention plugin")
def testAuthEd25519(self):
db = self.db.copy()
del db["password"]
conn = self.connect()
c = conn.cursor()
c.execute("select ed25519_password(''), ed25519_password('ed25519_password')")
for r in c:
empty_pass = r[0].decode("ascii")
non_empty_pass = r[1].decode("ascii")

with TempUser(
c,
"pymysql_ed25519",
self.databases[0]["database"],
"ed25519",
empty_pass,
) as u:
pymysql.connect(user="pymysql_ed25519", password="", **db)

with TempUser(
c,
"pymysql_ed25519",
self.databases[0]["database"],
"ed25519",
non_empty_pass,
) as u:
pymysql.connect(user="pymysql_ed25519", password="ed25519_password", **db)


class TestConnection(base.PyMySQLTestCase):
def test_utf8mb4(self):
Expand Down
24 changes: 0 additions & 24 deletions tests/test_mariadb_auth.py

This file was deleted.

0 comments on commit af21955

Please sign in to comment.