Skip to content

Commit 0a94b20

Browse files
committed
Migrate test_tls
1 parent 9974818 commit 0a94b20

File tree

1 file changed

+20
-25
lines changed

1 file changed

+20
-25
lines changed

tests/test_tls.py

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,28 @@
1-
from nose.tools import (
2-
raises,
3-
)
1+
import pytest
42
import datajoint as dj
5-
from . import CONN_INFO
63
from pymysql.err import OperationalError
74

85

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
1813

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 == ""
2714

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):
3126
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
3328
).query("SHOW STATUS LIKE 'Ssl_cipher';").fetchone()[1]

0 commit comments

Comments
 (0)