|
4 | 4 | import pytest
|
5 | 5 |
|
6 | 6 |
|
| 7 | +# You could parameterise these tests with this, but then pytest |
| 8 | +# does some funky stuff and spins up and tears down containers |
| 9 | +# per function call. Remember it would be |
| 10 | +# mysql_versions * event_loops * 4 auth tests ~= 3*2*4 ~= 24 tests |
| 11 | + |
| 12 | +# As the MySQL daemon restarts at least 3 times in the container |
| 13 | +# before it becomes stable, there's a sleep(10) so that's |
| 14 | +# around a 4min wait time. |
| 15 | + |
| 16 | +# @pytest.mark.parametrize("user,password,plugin", [ |
| 17 | +# ("nopass_sha256", None, 'sha256_password'), |
| 18 | +# ("user_sha256", 'pass_sha256', 'sha256_password'), |
| 19 | +# ("nopass_caching_sha2", None, 'caching_sha2_password'), |
| 20 | +# ("user_caching_sha2", 'pass_caching_sha2', 'caching_sha2_password'), |
| 21 | +# ]) |
| 22 | + |
| 23 | + |
| 24 | +@pytest.mark.mysql_verison('8.0') |
| 25 | +@pytest.mark.run_loop |
| 26 | +async def test_sha256_nopw(mysql_server, loop): |
| 27 | + connection_data = copy.copy(mysql_server['conn_params']) |
| 28 | + connection_data['user'] = 'nopass_sha256' |
| 29 | + connection_data['password'] = None |
| 30 | + |
| 31 | + async with create_pool(**connection_data, |
| 32 | + loop=loop) as pool: |
| 33 | + async with pool.get() as conn: |
| 34 | + # User doesnt have any permissions to look at DBs |
| 35 | + # But as 8.0 will default to caching_sha2_password |
| 36 | + assert conn._auth_plugin_used == 'sha256_password' |
| 37 | + |
| 38 | + |
| 39 | +@pytest.mark.mysql_verison('8.0') |
| 40 | +@pytest.mark.run_loop |
| 41 | +async def test_sha256_pw(mysql_server, loop): |
| 42 | + connection_data = copy.copy(mysql_server['conn_params']) |
| 43 | + connection_data['user'] = 'user_sha256' |
| 44 | + connection_data['password'] = 'pass_sha256' |
| 45 | + |
| 46 | + async with create_pool(**connection_data, |
| 47 | + loop=loop) as pool: |
| 48 | + async with pool.get() as conn: |
| 49 | + # User doesnt have any permissions to look at DBs |
| 50 | + # But as 8.0 will default to caching_sha2_password |
| 51 | + assert conn._auth_plugin_used == 'sha256_password' |
| 52 | + |
| 53 | + |
| 54 | +@pytest.mark.mysql_verison('8.0') |
| 55 | +@pytest.mark.run_loop |
| 56 | +async def test_cached_sha256_nopw(mysql_server, loop): |
| 57 | + connection_data = copy.copy(mysql_server['conn_params']) |
| 58 | + connection_data['user'] = 'nopass_caching_sha2' |
| 59 | + connection_data['password'] = None |
| 60 | + |
| 61 | + async with create_pool(**connection_data, |
| 62 | + loop=loop) as pool: |
| 63 | + async with pool.get() as conn: |
| 64 | + # User doesnt have any permissions to look at DBs |
| 65 | + # But as 8.0 will default to caching_sha2_password |
| 66 | + assert conn._auth_plugin_used == 'caching_sha2_password' |
| 67 | + |
| 68 | + |
7 | 69 | @pytest.mark.mysql_verison('8.0')
|
8 | 70 | @pytest.mark.run_loop
|
9 |
| -@pytest.mark.parametrize("user,password,plugin", [ |
10 |
| - ("nopass_sha256", None, 'sha256_password'), |
11 |
| - ("user_sha256", 'pass_sha256', 'sha256_password'), |
12 |
| - ("nopass_caching_sha2", None, 'caching_sha2_password'), |
13 |
| - ("user_caching_sha2", 'pass_caching_sha2', 'caching_sha2_password'), |
14 |
| -]) |
15 |
| -async def test_sha(mysql_server, loop, user, password, plugin): |
| 71 | +async def test_cached_sha256_pw(mysql_server, loop): |
16 | 72 | connection_data = copy.copy(mysql_server['conn_params'])
|
17 |
| - connection_data['user'] = user |
18 |
| - connection_data['password'] = password |
| 73 | + connection_data['user'] = 'user_caching_sha2' |
| 74 | + connection_data['password'] = 'pass_caching_sha2' |
19 | 75 |
|
20 | 76 | async with create_pool(**connection_data,
|
21 | 77 | loop=loop) as pool:
|
22 | 78 | async with pool.get() as conn:
|
23 | 79 | # User doesnt have any permissions to look at DBs
|
24 | 80 | # But as 8.0 will default to caching_sha2_password
|
25 |
| - assert conn._auth_plugin_used == plugin |
| 81 | + assert conn._auth_plugin_used == 'caching_sha2_password' |
0 commit comments