Skip to content

Commit ffc61b8

Browse files
committed
cp to tests
1 parent acb2ab3 commit ffc61b8

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/test_tls.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from nose.tools import (
2+
assert_true,
3+
assert_false,
4+
assert_equal,
5+
assert_list_equal,
6+
raises,
7+
)
8+
import datajoint as dj
9+
from . import CONN_INFO
10+
from pymysql.err import OperationalError
11+
12+
13+
class TestTLS:
14+
@staticmethod
15+
def test_secure_connection():
16+
result = (
17+
dj.conn(reset=True, **CONN_INFO)
18+
.query("SHOW STATUS LIKE 'Ssl_cipher';")
19+
.fetchone()[1]
20+
)
21+
assert_true(len(result) > 0)
22+
23+
@staticmethod
24+
def test_insecure_connection():
25+
result = (
26+
dj.conn(use_tls=False, reset=True, **CONN_INFO)
27+
.query("SHOW STATUS LIKE 'Ssl_cipher';")
28+
.fetchone()[1]
29+
)
30+
assert_equal(result, "")
31+
32+
@staticmethod
33+
@raises(OperationalError)
34+
def test_reject_insecure():
35+
dj.conn(
36+
CONN_INFO["host"], user="djssl", password="djssl", use_tls=False, reset=True
37+
).query("SHOW STATUS LIKE 'Ssl_cipher';").fetchone()[1]

0 commit comments

Comments
 (0)