Skip to content

Commit c9d29e4

Browse files
committed
test
1 parent 311487f commit c9d29e4

File tree

5 files changed

+77
-27
lines changed

5 files changed

+77
-27
lines changed

.travis.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@ matrix:
3535
python: "3.4"
3636
- env:
3737
- DB=mysql:8.0
38+
- TEST_AUTH=yes
3839
python: "3.7-dev"
3940

4041
# different py version from 5.6 and 5.7 as cache seems to be based on py version
4142
# http://dev.mysql.com/downloads/mysql/5.7.html has latest development release version
4243
# really only need libaio1 for DB builds however libaio-dev is whitelisted for container builds and liaio1 isn't
4344
install:
44-
- pip install -U coveralls unittest2 coverage cryptography
45+
- pip install -U coveralls unittest2 coverage cryptography pytest
4546

4647
before_script:
4748
- ./.travis/initializedb.sh
@@ -51,6 +52,9 @@ before_script:
5152

5253
script:
5354
- coverage run ./runtests.py
55+
- if [ "${TEST_AUTH}" = "yes" ];
56+
then pytest -v tests
57+
fi
5458
- if [ ! -z "${DB}" ];
5559
then docker logs mysqld;
5660
fi

.travis/initializedb.sh

+9
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ if [ ! -z "${DB}" ]; then
3737
docker cp mysqld:/var/lib/mysql/server-cert.pem "${HOME}"
3838
docker cp mysqld:/var/lib/mysql/client-key.pem "${HOME}"
3939
docker cp mysqld:/var/lib/mysql/client-cert.pem "${HOME}"
40+
41+
# Test user for auth test
42+
mysql -e "
43+
CREATE USER
44+
user_sha256 IDENTIFIED WITH 'sha256_password' BY 'pass_sha256',
45+
nopass_sha256 IDENTIFIED WITH 'sha256_password',
46+
user_caching_sha2 IDENTIFIED WITH 'caching_sha2_password' BY 'pass_caching_sha2'
47+
nopass_caching_sha2 IDENTIFIED WITH 'caching_sha2_password'
48+
PASSWORD EXPIRE NEVER;"
4049
else
4150
WITH_PLUGIN=''
4251
fi

sha256_test.py

-26
This file was deleted.

tests/__init__.py

Whitespace-only changes.

tests/test_auth.py

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
"""Test for auth methods supported by MySQL 8"""
2+
3+
import os
4+
import pymysql
5+
6+
# pymysql.connections.DEBUG = True
7+
# pymysql._auth.DEBUG = True
8+
9+
host = "127.0.0.1"
10+
port = 3306
11+
12+
ca = os.expanduser("~/ca.pem")
13+
ssl = {'ca': ca, 'check_hostname': False}
14+
15+
16+
def test_sha256_no_password():
17+
con = pymysql.connect(user="nopass_sha256", host=host, port=port, ssl=None)
18+
con.close()
19+
20+
21+
def test_sha256_no_passowrd_ssl():
22+
con = pymysql.connect(user="nopass_sha256", host=host, port=port, ssl=ssl)
23+
con.close()
24+
25+
26+
def test_sha256_password():
27+
con = pymysql.connect(user="user_sha256", password="pass_sha256", host=host, port=port, ssl=None)
28+
con.close()
29+
30+
31+
def test_sha256_password_ssl():
32+
con = pymysql.connect(user="user_sha256", password="pass_sha256", host=host, port=port, ssl=ssl)
33+
con.close()
34+
35+
36+
def test_caching_sha2_no_password():
37+
con = pymysql.connect(user="nopass_caching_sha2", host=host, port=port, ssl=None)
38+
con.close()
39+
40+
41+
def test_caching_sha2_no_password():
42+
con = pymysql.connect(user="nopass_caching_sha2", host=host, port=port, ssl=ssl)
43+
con.close()
44+
45+
46+
def test_caching_sha2_password():
47+
con = pymysql.connect(user="user_caching_sha2", password="pass_caching_sha2", host=host, port=port, ssl=None)
48+
con.close()
49+
50+
# Fast path of caching sha2
51+
con = pymysql.connect(user="user_caching_sha2", password="pass_caching_sha2", host=host, port=port, ssl=None)
52+
con.query("FLUSH PRIVILEGES")
53+
con.close()
54+
55+
56+
def test_caching_sha2_password_ssl():
57+
con = pymysql.connect(user="user_caching_sha2", password="pass_caching_sha2", host=host, port=port, ssl=ssl)
58+
con.close()
59+
60+
# Fast path of caching sha2
61+
con = pymysql.connect(user="user_caching_sha2", password="pass_caching_sha2", host=host, port=port, ssl=None)
62+
con.query("FLUSH PRIVILEGES")
63+
con.close()

0 commit comments

Comments
 (0)