forked from jupyterhub/pamela
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_pampylho.py
41 lines (27 loc) · 835 Bytes
/
test_pampylho.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import getpass
import pytest
import pampylho
def test_pam_error_noargs():
e = pampylho.PAMError()
s = str(e)
r = repr(e)
assert 'Unknown' in s
assert 'Unknown' in r
def test_pam_error_errno():
en = 2
e = pampylho.PAMError(errno=en)
assert str(en) in str(e)
assert 'Unknown' not in str(e)
def test_auth_nouser():
with pytest.raises(pampylho.PAMError) as exc_info:
pampylho.authenticate('userdoesntexist', 'wrongpassword')
e = exc_info.value
assert 'Unknown' not in str(e)
def test_auth_badpassword():
with pytest.raises(pampylho.PAMError) as exc_info:
pampylho.authenticate(getpass.getuser(), 'wrongpassword')
e = exc_info.value
assert 'Unknown' not in str(e)
def test_all():
for name in pampylho.__all__:
getattr(pampylho, name)