1313
1414
1515class TestLegacySASLDigestAuthentication (KazooTestHarness ):
16-
1716 def setUp (self ):
1817 try :
1918 import puresasl # NOQA
2019 except ImportError :
21- raise SkipTest (' PureSASL not available.' )
20+ raise SkipTest (" PureSASL not available." )
2221
23- os .environ [' ZOOKEEPER_JAAS_AUTH' ] = ' digest'
22+ os .environ [" ZOOKEEPER_JAAS_AUTH" ] = " digest"
2423 self .setup_zookeeper ()
2524
2625 if TRAVIS_ZK_VERSION :
@@ -39,36 +38,35 @@ def test_connect_sasl_auth(self):
3938 username = "jaasuser"
4039 password = "jaas_password"
4140
42- acl = make_acl (' sasl' , credential = username , all = True )
41+ acl = make_acl (" sasl" , credential = username , all = True )
4342
4443 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 )])
4645
4746 client .start ()
4847 try :
49- client .create ('/1' , acl = (acl ,))
48+ client .create ("/1" , acl = (acl ,))
5049 # give ZK a chance to copy data to other node
5150 time .sleep (0.1 )
5251 self .assertRaises (NoAuthError , self .client .get , "/1" )
5352 finally :
54- client .delete ('/1' )
53+ client .delete ("/1" )
5554 client .stop ()
5655 client .close ()
5756
5857 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" )])
6059 self .assertRaises (AuthFailedError , client .start )
6160
6261
6362class TestSASLDigestAuthentication (KazooTestHarness ):
64-
6563 def setUp (self ):
6664 try :
6765 import puresasl # NOQA
6866 except ImportError :
69- raise SkipTest (' PureSASL not available.' )
67+ raise SkipTest (" PureSASL not available." )
7068
71- os .environ [' ZOOKEEPER_JAAS_AUTH' ] = ' digest'
69+ os .environ [" ZOOKEEPER_JAAS_AUTH" ] = " digest"
7270 self .setup_zookeeper ()
7371
7472 if TRAVIS_ZK_VERSION :
@@ -87,48 +85,51 @@ def test_connect_sasl_auth(self):
8785 username = "jaasuser"
8886 password = "jaas_password"
8987
90- acl = make_acl (' sasl' , credential = username , all = True )
88+ acl = make_acl (" sasl" , credential = username , all = True )
9189
9290 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+ }
9696 )
9797 client .start ()
9898 try :
99- client .create ('/1' , acl = (acl ,))
99+ client .create ("/1" , acl = (acl ,))
100100 # give ZK a chance to copy data to other node
101101 time .sleep (0.1 )
102102 self .assertRaises (NoAuthError , self .client .get , "/1" )
103103 finally :
104- client .delete ('/1' )
104+ client .delete ("/1" )
105105 client .stop ()
106106 client .close ()
107107
108108 def test_invalid_sasl_auth (self ):
109109 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+ }
113115 )
114116 self .assertRaises (AuthFailedError , client .start )
115117
116118
117119class TestSASLGSSAPIAuthentication (KazooTestHarness ):
118-
119120 def setUp (self ):
120121 try :
121122 import puresasl # NOQA
122123 except ImportError :
123- raise SkipTest (' PureSASL not available.' )
124+ raise SkipTest (" PureSASL not available." )
124125 try :
125126 import kerberos # NOQA
126127 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." )
130131
131- os .environ [' ZOOKEEPER_JAAS_AUTH' ] = ' gssapi'
132+ os .environ [" ZOOKEEPER_JAAS_AUTH" ] = " gssapi"
132133 self .setup_zookeeper ()
133134
134135 if TRAVIS_ZK_VERSION :
@@ -147,40 +148,39 @@ def test_connect_gssapi_auth(self):
147148 # Ensure we have a client ticket
148149 subprocess .check_call (
149150 [
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" ,
153155 ]
154156 )
155157
156- acl = make_acl (' sasl' , credential = ' client@KAZOOTEST.ORG' , all = True )
158+ acl = make_acl (" sasl" , credential = " client@KAZOOTEST.ORG" , all = True )
157159
158- client = self ._get_client (
159- sasl_options = {'mechanism' : 'GSSAPI' }
160- )
160+ client = self ._get_client (sasl_options = {"mechanism" : "GSSAPI" })
161161 client .start ()
162162 try :
163- client .create ('/1' , acl = (acl ,))
163+ client .create ("/1" , acl = (acl ,))
164164 # give ZK a chance to copy data to other node
165165 time .sleep (0.1 )
166166 self .assertRaises (NoAuthError , self .client .get , "/1" )
167167 finally :
168- client .delete ('/1' )
168+ client .delete ("/1" )
169169 client .stop ()
170170 client .close ()
171171
172172 def test_invalid_gssapi_auth (self ):
173173 # Request a post-datated ticket, so that it is currently invalid.
174174 subprocess .check_call (
175175 [
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" ,
180182 ]
181183 )
182184
183- client = self ._get_client (
184- sasl_options = {'mechanism' : 'GSSAPI' }
185- )
185+ client = self ._get_client (sasl_options = {"mechanism" : "GSSAPI" })
186186 self .assertRaises (AuthFailedError , client .start )
0 commit comments