@@ -99,7 +99,7 @@ def test_negotate_value_extraction_none():
99
99
100
100
101
101
def test_force_preemptive (patched_ctx ):
102
- auth = httpx_gssapi .HTTPKerberosAuth ( force_preemptive = True )
102
+ auth = httpx_gssapi .HTTPSPNEGOAuth ( opportunistic_auth = True )
103
103
104
104
request = null_request ()
105
105
@@ -111,7 +111,7 @@ def test_force_preemptive(patched_ctx):
111
111
112
112
113
113
def test_no_force_preemptive (patched_ctx ):
114
- auth = httpx_gssapi .HTTPKerberosAuth ()
114
+ auth = httpx_gssapi .HTTPSPNEGOAuth ()
115
115
116
116
request = null_request ()
117
117
@@ -124,7 +124,7 @@ def test_no_force_preemptive(patched_ctx):
124
124
def test_generate_request_header (patched_ctx ):
125
125
resp = null_response (headers = neg_token )
126
126
host = resp .url .host
127
- auth = httpx_gssapi .HTTPKerberosAuth ()
127
+ auth = httpx_gssapi .HTTPSPNEGOAuth ()
128
128
assert auth .generate_request_header (host , resp ) == b64_negotiate_response
129
129
check_init ()
130
130
fake_resp .assert_called_with (b"token" )
@@ -133,7 +133,7 @@ def test_generate_request_header(patched_ctx):
133
133
def test_generate_request_header_init_error (patched_ctx_fail ):
134
134
response = null_response (headers = neg_token )
135
135
host = response .url .host
136
- auth = httpx_gssapi .HTTPKerberosAuth ()
136
+ auth = httpx_gssapi .HTTPSPNEGOAuth ()
137
137
with pytest .raises (httpx_gssapi .exceptions .SPNEGOExchangeError ):
138
138
auth .generate_request_header (host , response )
139
139
check_init ()
@@ -142,7 +142,7 @@ def test_generate_request_header_init_error(patched_ctx_fail):
142
142
def test_generate_request_header_step_error (patched_ctx_fail ):
143
143
response = null_response (headers = neg_token )
144
144
host = response .url .host
145
- auth = httpx_gssapi .HTTPKerberosAuth ()
145
+ auth = httpx_gssapi .HTTPSPNEGOAuth ()
146
146
with pytest .raises (httpx_gssapi .exceptions .SPNEGOExchangeError ):
147
147
auth .generate_request_header (host , response )
148
148
check_init ()
@@ -155,7 +155,7 @@ def test_authenticate_user(patched_ctx):
155
155
request = null_request (),
156
156
headers = neg_token ,
157
157
)
158
- auth = httpx_gssapi .HTTPKerberosAuth ()
158
+ auth = httpx_gssapi .HTTPSPNEGOAuth ()
159
159
request = auth .authenticate_user (response )
160
160
assert 'Authorization' in request .headers
161
161
assert request .headers ['Authorization' ] == b64_negotiate_response
@@ -170,7 +170,7 @@ def test_handle_401(patched_ctx):
170
170
headers = neg_token ,
171
171
)
172
172
173
- auth = httpx_gssapi .HTTPKerberosAuth ()
173
+ auth = httpx_gssapi .HTTPSPNEGOAuth ()
174
174
request = auth .handle_401 (response )
175
175
assert 'Authorization' in request .headers
176
176
assert request .headers ['Authorization' ] == b64_negotiate_response
@@ -184,7 +184,7 @@ def test_authenticate_server(patched_ctx):
184
184
'authorization' : b64_negotiate_response ,
185
185
})
186
186
187
- auth = httpx_gssapi .HTTPKerberosAuth ()
187
+ auth = httpx_gssapi .HTTPSPNEGOAuth ()
188
188
auth .context = {"www.example.org" : gssapi .SecurityContext }
189
189
assert auth .authenticate_server (response_ok )
190
190
fake_resp .assert_called_with (b"servertoken" )
@@ -196,7 +196,7 @@ def test_handle_other(patched_ctx):
196
196
'authorization' : b64_negotiate_response ,
197
197
})
198
198
199
- auth = httpx_gssapi .HTTPKerberosAuth (mutual_authentication = REQUIRED )
199
+ auth = httpx_gssapi .HTTPSPNEGOAuth (mutual_authentication = REQUIRED )
200
200
auth .context = {"www.example.org" : gssapi .SecurityContext }
201
201
202
202
auth .handle_mutual_auth (response_ok ) # No error raised
@@ -209,7 +209,7 @@ def test_handle_response_200(patched_ctx):
209
209
'authorization' : b64_negotiate_response ,
210
210
})
211
211
212
- auth = httpx_gssapi .HTTPKerberosAuth (mutual_authentication = REQUIRED )
212
+ auth = httpx_gssapi .HTTPSPNEGOAuth (mutual_authentication = REQUIRED )
213
213
auth .context = {"www.example.org" : gssapi .SecurityContext }
214
214
215
215
flow = auth .handle_response (response_ok )
@@ -221,7 +221,7 @@ def test_handle_response_200(patched_ctx):
221
221
def test_handle_response_200_mutual_auth_required_failure (patched_ctx_fail ):
222
222
response_ok = null_response ()
223
223
224
- auth = httpx_gssapi .HTTPKerberosAuth (mutual_authentication = REQUIRED )
224
+ auth = httpx_gssapi .HTTPSPNEGOAuth (mutual_authentication = REQUIRED )
225
225
auth .context = {"www.example.org" : "CTX" }
226
226
227
227
flow = auth .handle_response (response_ok )
@@ -237,7 +237,7 @@ def test_handle_response_200_mutual_auth_required_failure_2(patched_ctx_fail):
237
237
'authorization' : b64_negotiate_response ,
238
238
})
239
239
240
- auth = httpx_gssapi .HTTPKerberosAuth (mutual_authentication = REQUIRED )
240
+ auth = httpx_gssapi .HTTPSPNEGOAuth (mutual_authentication = REQUIRED )
241
241
auth .context = {"www.example.org" : gssapi .SecurityContext }
242
242
243
243
flow = auth .handle_response (response_ok )
@@ -253,7 +253,7 @@ def test_handle_response_200_mutual_auth_optional_hard_fail(patched_ctx_fail):
253
253
'authorization' : b64_negotiate_response ,
254
254
})
255
255
256
- auth = httpx_gssapi .HTTPKerberosAuth (mutual_authentication = OPTIONAL )
256
+ auth = httpx_gssapi .HTTPSPNEGOAuth (mutual_authentication = OPTIONAL )
257
257
auth .context = {"www.example.org" : gssapi .SecurityContext }
258
258
259
259
flow = auth .handle_response (response_ok )
@@ -266,7 +266,7 @@ def test_handle_response_200_mutual_auth_optional_hard_fail(patched_ctx_fail):
266
266
def test_handle_response_200_mutual_auth_optional_soft_failure (patched_ctx ):
267
267
response_ok = null_response ()
268
268
269
- auth = httpx_gssapi .HTTPKerberosAuth (mutual_authentication = OPTIONAL )
269
+ auth = httpx_gssapi .HTTPSPNEGOAuth (mutual_authentication = OPTIONAL )
270
270
auth .context = {"www.example.org" : gssapi .SecurityContext }
271
271
272
272
flow = auth .handle_response (response_ok )
@@ -283,7 +283,7 @@ def test_handle_response_500_mutual_auth_required_failure(patched_ctx_fail):
283
283
)
284
284
response_500 ._content = b"CONTENT"
285
285
286
- auth = httpx_gssapi .HTTPKerberosAuth (mutual_authentication = REQUIRED )
286
+ auth = httpx_gssapi .HTTPSPNEGOAuth (mutual_authentication = REQUIRED )
287
287
auth .context = {"www.example.org" : "CTX" }
288
288
289
289
flow = auth .handle_response (response_500 )
@@ -305,7 +305,7 @@ def test_handle_response_500_mutual_auth_required_fail_no_san(patched_ctx_fail):
305
305
)
306
306
response_500 ._content = b'CONTENT'
307
307
308
- auth = httpx_gssapi .HTTPKerberosAuth (
308
+ auth = httpx_gssapi .HTTPSPNEGOAuth (
309
309
mutual_authentication = REQUIRED ,
310
310
sanitize_mutual_error_response = False
311
311
)
@@ -330,7 +330,7 @@ def test_handle_response_500_mutual_auth_optional_failure(patched_ctx_fail):
330
330
)
331
331
response_500 ._content = b'CONTENT'
332
332
333
- auth = httpx_gssapi .HTTPKerberosAuth (mutual_authentication = OPTIONAL )
333
+ auth = httpx_gssapi .HTTPSPNEGOAuth (mutual_authentication = OPTIONAL )
334
334
auth .context = {"www.example.org" : "CTX" }
335
335
336
336
flow = auth .handle_response (response_500 )
@@ -346,7 +346,7 @@ def test_handle_response_500_mutual_auth_optional_failure(patched_ctx_fail):
346
346
347
347
348
348
def test_handle_response_401 (patched_ctx ):
349
- auth = httpx_gssapi .HTTPKerberosAuth ()
349
+ auth = httpx_gssapi .HTTPSPNEGOAuth ()
350
350
response_401 = null_response (status = 401 , headers = neg_token )
351
351
flow = auth .handle_response (response_401 )
352
352
request = next (flow )
@@ -362,7 +362,7 @@ def test_handle_response_401(patched_ctx):
362
362
def test_handle_response_401_rejected (patched_ctx ):
363
363
# Get a 401 from server, authenticate, and get another 401 back.
364
364
# Ensure there is no infinite auth loop.
365
- auth = httpx_gssapi .HTTPKerberosAuth ()
365
+ auth = httpx_gssapi .HTTPSPNEGOAuth ()
366
366
response_401 = null_response (status = 401 , headers = neg_token )
367
367
flow = auth .handle_response (response_401 )
368
368
@@ -381,16 +381,8 @@ def test_handle_response_401_rejected(patched_ctx):
381
381
fake_resp .assert_called_with (b"token" )
382
382
383
383
384
- def test_generate_request_header_custom_service (patched_ctx ):
385
- response = null_response (headers = neg_token )
386
- auth = httpx_gssapi .HTTPKerberosAuth (service = "barfoo" )
387
- auth .generate_request_header (response .url .host , response ),
388
- check_init (
name = gssapi_name (
"[email protected] " ))
389
- fake_resp .assert_called_with (b"token" )
390
-
391
-
392
384
def test_delegation (patched_ctx ):
393
- auth = httpx_gssapi .HTTPKerberosAuth (delegate = True )
385
+ auth = httpx_gssapi .HTTPSPNEGOAuth (delegate = True )
394
386
response_401 = null_response (status = 401 , headers = neg_token )
395
387
flow = auth .handle_response (response_401 )
396
388
request = next (flow )
@@ -403,27 +395,6 @@ def test_delegation(patched_ctx):
403
395
fake_resp .assert_called_with (b"token" )
404
396
405
397
406
- def test_principal_override (patched_ctx , patched_creds ):
407
- response = null_response (headers = neg_token )
408
- auth = httpx_gssapi .HTTPKerberosAuth (principal = "user@REALM" )
409
- auth .generate_request_header (response .url .host , response )
410
- fake_creds .assert_called_with (
411
- gssapi .creds .Credentials ,
412
- usage = "initiate" ,
413
- name = gssapi_name ("user@REALM" ),
414
- )
415
- check_init (creds = b"fake creds" )
416
-
417
-
418
- def test_realm_override (patched_ctx ):
419
- response = null_response (headers = neg_token )
420
- otherhost = "otherhost.otherdomain.org"
421
- auth = httpx_gssapi .HTTPKerberosAuth (hostname_override = otherhost )
422
- auth .generate_request_header (response .url .host , response )
423
- check_init (name = gssapi_name (f"HTTP@{ otherhost } " ))
424
- fake_resp .assert_called_with (b"token" )
425
-
426
-
427
398
def test_opportunistic_auth (patched_ctx ):
428
399
auth = httpx_gssapi .HTTPSPNEGOAuth (opportunistic_auth = True )
429
400
0 commit comments