13
13
14
14
15
15
class TestLegacySASLDigestAuthentication (KazooTestHarness ):
16
-
17
16
def setUp (self ):
18
17
try :
19
18
import puresasl # NOQA
20
19
except ImportError :
21
- raise SkipTest (' PureSASL not available.' )
20
+ raise SkipTest (" PureSASL not available." )
22
21
23
- os .environ [' ZOOKEEPER_JAAS_AUTH' ] = ' digest'
22
+ os .environ [" ZOOKEEPER_JAAS_AUTH" ] = " digest"
24
23
self .setup_zookeeper ()
25
24
26
25
if TRAVIS_ZK_VERSION :
@@ -39,36 +38,35 @@ def test_connect_sasl_auth(self):
39
38
username = "jaasuser"
40
39
password = "jaas_password"
41
40
42
- acl = make_acl (' sasl' , credential = username , all = True )
41
+ acl = make_acl (" sasl" , credential = username , all = True )
43
42
44
43
sasl_auth = "%s:%s" % (username , password )
45
- client = self ._get_client (auth_data = [(' sasl' , sasl_auth )])
44
+ client = self ._get_client (auth_data = [(" sasl" , sasl_auth )])
46
45
47
46
client .start ()
48
47
try :
49
- client .create ('/1' , acl = (acl ,))
48
+ client .create ("/1" , acl = (acl ,))
50
49
# give ZK a chance to copy data to other node
51
50
time .sleep (0.1 )
52
51
self .assertRaises (NoAuthError , self .client .get , "/1" )
53
52
finally :
54
- client .delete ('/1' )
53
+ client .delete ("/1" )
55
54
client .stop ()
56
55
client .close ()
57
56
58
57
def test_invalid_sasl_auth (self ):
59
- client = self ._get_client (auth_data = [(' sasl' , ' baduser:badpassword' )])
58
+ client = self ._get_client (auth_data = [(" sasl" , " baduser:badpassword" )])
60
59
self .assertRaises (AuthFailedError , client .start )
61
60
62
61
63
62
class TestSASLDigestAuthentication (KazooTestHarness ):
64
-
65
63
def setUp (self ):
66
64
try :
67
65
import puresasl # NOQA
68
66
except ImportError :
69
- raise SkipTest (' PureSASL not available.' )
67
+ raise SkipTest (" PureSASL not available." )
70
68
71
- os .environ [' ZOOKEEPER_JAAS_AUTH' ] = ' digest'
69
+ os .environ [" ZOOKEEPER_JAAS_AUTH" ] = " digest"
72
70
self .setup_zookeeper ()
73
71
74
72
if TRAVIS_ZK_VERSION :
@@ -87,48 +85,51 @@ def test_connect_sasl_auth(self):
87
85
username = "jaasuser"
88
86
password = "jaas_password"
89
87
90
- acl = make_acl (' sasl' , credential = username , all = True )
88
+ acl = make_acl (" sasl" , credential = username , all = True )
91
89
92
90
client = self ._get_client (
93
- sasl_options = {'mechanism' : 'DIGEST-MD5' ,
94
- 'username' : username ,
95
- 'password' : password }
91
+ sasl_options = {
92
+ "mechanism" : "DIGEST-MD5" ,
93
+ "username" : username ,
94
+ "password" : password ,
95
+ }
96
96
)
97
97
client .start ()
98
98
try :
99
- client .create ('/1' , acl = (acl ,))
99
+ client .create ("/1" , acl = (acl ,))
100
100
# give ZK a chance to copy data to other node
101
101
time .sleep (0.1 )
102
102
self .assertRaises (NoAuthError , self .client .get , "/1" )
103
103
finally :
104
- client .delete ('/1' )
104
+ client .delete ("/1" )
105
105
client .stop ()
106
106
client .close ()
107
107
108
108
def test_invalid_sasl_auth (self ):
109
109
client = self ._get_client (
110
- sasl_options = {'mechanism' : 'DIGEST-MD5' ,
111
- 'username' : 'baduser' ,
112
- 'password' : 'badpassword' }
110
+ sasl_options = {
111
+ "mechanism" : "DIGEST-MD5" ,
112
+ "username" : "baduser" ,
113
+ "password" : "badpassword" ,
114
+ }
113
115
)
114
116
self .assertRaises (AuthFailedError , client .start )
115
117
116
118
117
119
class TestSASLGSSAPIAuthentication (KazooTestHarness ):
118
-
119
120
def setUp (self ):
120
121
try :
121
122
import puresasl # NOQA
122
123
except ImportError :
123
- raise SkipTest (' PureSASL not available.' )
124
+ raise SkipTest (" PureSASL not available." )
124
125
try :
125
126
import kerberos # NOQA
126
127
except ImportError :
127
- raise SkipTest (' Kerberos support not available.' )
128
- if not os .environ .get (' KRB5_TEST_ENV' ):
129
- raise SkipTest (' Test Kerberos environ not setup.' )
128
+ raise SkipTest (" Kerberos support not available." )
129
+ if not os .environ .get (" KRB5_TEST_ENV" ):
130
+ raise SkipTest (" Test Kerberos environ not setup." )
130
131
131
- os .environ [' ZOOKEEPER_JAAS_AUTH' ] = ' gssapi'
132
+ os .environ [" ZOOKEEPER_JAAS_AUTH" ] = " gssapi"
132
133
self .setup_zookeeper ()
133
134
134
135
if TRAVIS_ZK_VERSION :
@@ -147,40 +148,39 @@ def test_connect_gssapi_auth(self):
147
148
# Ensure we have a client ticket
148
149
subprocess .check_call (
149
150
[
150
- 'kinit' ,
151
- '-kt' , os .path .expandvars ('${KRB5_TEST_ENV}/client.keytab' ),
152
- 'client'
151
+ "kinit" ,
152
+ "-kt" ,
153
+ os .path .expandvars ("${KRB5_TEST_ENV}/client.keytab" ),
154
+ "client" ,
153
155
]
154
156
)
155
157
156
- acl = make_acl (
' sasl' ,
credential = ' [email protected] ' ,
all = True )
158
+ acl = make_acl (
" sasl" ,
credential = " [email protected] " ,
all = True )
157
159
158
- client = self ._get_client (
159
- sasl_options = {'mechanism' : 'GSSAPI' }
160
- )
160
+ client = self ._get_client (sasl_options = {"mechanism" : "GSSAPI" })
161
161
client .start ()
162
162
try :
163
- client .create ('/1' , acl = (acl ,))
163
+ client .create ("/1" , acl = (acl ,))
164
164
# give ZK a chance to copy data to other node
165
165
time .sleep (0.1 )
166
166
self .assertRaises (NoAuthError , self .client .get , "/1" )
167
167
finally :
168
- client .delete ('/1' )
168
+ client .delete ("/1" )
169
169
client .stop ()
170
170
client .close ()
171
171
172
172
def test_invalid_gssapi_auth (self ):
173
173
# Request a post-datated ticket, so that it is currently invalid.
174
174
subprocess .check_call (
175
175
[
176
- 'kinit' ,
177
- '-kt' , os .path .expandvars ('${KRB5_TEST_ENV}/client.keytab' ),
178
- '-s' , '30min' ,
179
- 'client'
176
+ "kinit" ,
177
+ "-kt" ,
178
+ os .path .expandvars ("${KRB5_TEST_ENV}/client.keytab" ),
179
+ "-s" ,
180
+ "30min" ,
181
+ "client" ,
180
182
]
181
183
)
182
184
183
- client = self ._get_client (
184
- sasl_options = {'mechanism' : 'GSSAPI' }
185
- )
185
+ client = self ._get_client (sasl_options = {"mechanism" : "GSSAPI" })
186
186
self .assertRaises (AuthFailedError , client .start )
0 commit comments