@@ -336,12 +336,65 @@ def test_aws_signer_as_http_auth(self):
336
336
con = RequestsHttpConnection (http_auth = auth )
337
337
prepared_request = requests .Request ("GET" , "http://localhost" ).prepare ()
338
338
auth (prepared_request )
339
+ self ._assert_auth_and_signature_headers (auth , con , prepared_request )
340
+
341
+ @pytest .mark .skipif (
342
+ sys .version_info < (3 , 6 ), reason = "AWSV4SignerAuth requires python3.6+"
343
+ )
344
+ def test_aws_signer_as_http_auth_with_query_path (self ):
345
+ region = "us-west-2"
346
+
347
+ import requests
348
+
349
+ from opensearchpy .helpers .signer import AWSV4SignerAuth
350
+
351
+ auth = AWSV4SignerAuth (self .mock_session (), region )
352
+ con = RequestsHttpConnection (http_auth = auth )
353
+ prepared_request = requests .Request (
354
+ "GET" , "http://localhost?hello=world"
355
+ ).prepare ()
356
+ auth (prepared_request )
357
+ self ._assert_auth_and_signature_headers (auth , con , prepared_request )
358
+
359
+ def _assert_auth_and_signature_headers (self , auth , con , prepared_request ):
339
360
self .assertEqual (auth , con .session .auth )
340
361
self .assertIn ("Authorization" , prepared_request .headers )
341
362
self .assertIn ("X-Amz-Date" , prepared_request .headers )
342
363
self .assertIn ("X-Amz-Security-Token" , prepared_request .headers )
343
364
self .assertIn ("X-Amz-Content-SHA256" , prepared_request .headers )
344
365
366
+ @pytest .mark .skipif (
367
+ sys .version_info < (3 , 6 ), reason = "AWSV4SignerAuth requires python3.6+"
368
+ )
369
+ def test_aws_signer_as_http_auth_with_sign_port_with_port_on_base_url (self ):
370
+ region = "us-west-2"
371
+
372
+ import requests
373
+
374
+ from opensearchpy .helpers .signer import AWSV4SignerAuth
375
+
376
+ auth = AWSV4SignerAuth (self .mock_session (), region , signature_port = 443 )
377
+ con = RequestsHttpConnection (http_auth = auth )
378
+ prepared_request = requests .Request ("GET" , "http://localhost:1045" ).prepare ()
379
+ auth (prepared_request )
380
+ self ._assert_auth_and_signature_headers (auth , con , prepared_request )
381
+
382
+ @pytest .mark .skipif (
383
+ sys .version_info < (3 , 6 ), reason = "AWSV4SignerAuth requires python3.6+"
384
+ )
385
+ def test_aws_signer_as_http_auth_with_sign_port_but_without_port_on_base_url (self ):
386
+ region = "us-west-2"
387
+
388
+ import requests
389
+
390
+ from opensearchpy .helpers .signer import AWSV4SignerAuth
391
+
392
+ auth = AWSV4SignerAuth (self .mock_session (), region , signature_port = 443 )
393
+ con = RequestsHttpConnection (http_auth = auth )
394
+ prepared_request = requests .Request ("GET" , "http://localhost" ).prepare ()
395
+ auth (prepared_request )
396
+ self ._assert_auth_and_signature_headers (auth , con , prepared_request )
397
+
345
398
@pytest .mark .skipif (
346
399
sys .version_info < (3 , 6 ), reason = "AWSV4SignerAuth requires python3.6+"
347
400
)
0 commit comments