|
1 | | -from nose.tools import ( |
2 | | - raises, |
3 | | -) |
| 1 | +import pytest |
4 | 2 | import datajoint as dj |
5 | | -from . import CONN_INFO |
6 | 3 | from pymysql.err import OperationalError |
7 | 4 |
|
8 | 5 |
|
9 | | -class TestTLS: |
10 | | - @staticmethod |
11 | | - def test_secure_connection(): |
12 | | - result = ( |
13 | | - dj.conn(reset=True, **CONN_INFO) |
14 | | - .query("SHOW STATUS LIKE 'Ssl_cipher';") |
15 | | - .fetchone()[1] |
16 | | - ) |
17 | | - assert len(result) > 0 |
| 6 | +def test_secure_connection(db_creds_test, connection_test): |
| 7 | + result = ( |
| 8 | + dj.conn(reset=True, **db_creds_test) |
| 9 | + .query("SHOW STATUS LIKE 'Ssl_cipher';") |
| 10 | + .fetchone()[1] |
| 11 | + ) |
| 12 | + assert len(result) > 0 |
18 | 13 |
|
19 | | - @staticmethod |
20 | | - def test_insecure_connection(): |
21 | | - result = ( |
22 | | - dj.conn(use_tls=False, reset=True, **CONN_INFO) |
23 | | - .query("SHOW STATUS LIKE 'Ssl_cipher';") |
24 | | - .fetchone()[1] |
25 | | - ) |
26 | | - assert result == "" |
27 | 14 |
|
28 | | - @staticmethod |
29 | | - @raises(OperationalError) |
30 | | - def test_reject_insecure(): |
| 15 | +def test_insecure_connection(db_creds_test, connection_test): |
| 16 | + result = ( |
| 17 | + dj.conn(use_tls=False, reset=True, **db_creds_test) |
| 18 | + .query("SHOW STATUS LIKE 'Ssl_cipher';") |
| 19 | + .fetchone()[1] |
| 20 | + ) |
| 21 | + assert result == "" |
| 22 | + |
| 23 | + |
| 24 | +def test_reject_insecure(db_creds_test, connection_test): |
| 25 | + with pytest.raises(OperationalError): |
31 | 26 | dj.conn( |
32 | | - CONN_INFO["host"], user="djssl", password="djssl", use_tls=False, reset=True |
| 27 | + db_creds_test["host"], user="djssl", password="djssl", use_tls=False, reset=True |
33 | 28 | ).query("SHOW STATUS LIKE 'Ssl_cipher';").fetchone()[1] |
0 commit comments