-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathtest_auth.py
43 lines (39 loc) · 1.13 KB
/
test_auth.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
42
43
import smbc
def test_auth_succes(config):
ctx = smbc.Context()
ctx.optionNoAutoAnonymousLogin = True
cb = lambda se, sh, w, u, p: (w, config['username'], config['password'])
ctx.functionAuthData = cb
d = ctx.opendir(config['uri'])
assert d != None
def test_auth_failed_noauth(config):
ctx = smbc.Context()
ctx.optionNoAutoAnonymousLogin = True
try:
ctx.opendir(config['uri'])
except smbc.PermissionError:
assert True
else:
assert False
def test_auth_failed_nopass(config):
ctx = smbc.Context()
ctx.optionNoAutoAnonymousLogin = True
cb = lambda se, sh, w, u, p: (w, config['username'], "")
ctx.functionAuthData = cb
try:
ctx.opendir(config['uri'])
except smbc.PermissionError:
assert True
else:
assert False
def test_auth_failed_nouser(config):
ctx = smbc.Context()
ctx.optionNoAutoAnonymousLogin = True
cb = lambda se, sh, w, u, p: (w, "", config['password'])
ctx.functionAuthData = cb
try:
ctx.opendir(config['uri'])
except smbc.PermissionError:
assert True
else:
assert False