@@ -494,35 +494,20 @@ defmodule Req.StepsTest do
494
494
end
495
495
496
496
describe "put_aws_sigv4" do
497
- # TODO: flaky
498
- @ tag :skip
499
497
test "body: binary" do
500
498
plug = fn conn ->
501
499
assert { :ok , "hello" , conn } = Plug.Conn . read_body ( conn )
502
-
503
- assert Plug.Conn . get_req_header ( conn , "x-amz-content-sha256" ) == [
504
- "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
505
- ]
506
-
507
- assert Plug.Conn . get_req_header ( conn , "authorization" ) == [
508
- """
509
- AWS4-HMAC-SHA256 \
510
- Credential=foo/20240101/us-east-1/s3/aws4_request,\
511
- SignedHeaders=accept-encoding;host;user-agent;x-amz-content-sha256;x-amz-date,\
512
- Signature=a7a27655988cf90a6d834c6544e8a5e1ef00308a64692f0e656167165d42ec4d\
513
- """
514
- ]
515
-
500
+ assert [ "AWS4-HMAC-SHA256" <> _ ] = Plug.Conn . get_req_header ( conn , "authorization" )
501
+ assert [ << _ :: binary - size ( 64 ) >> ] = Plug.Conn . get_req_header ( conn , "x-amz-content-sha256" )
516
502
Plug.Conn . send_resp ( conn , 200 , "ok" )
517
503
end
518
504
519
505
req =
520
506
Req . new (
521
- url: "http ://localhost " ,
507
+ url: "https ://s3.amazonaws.com " ,
522
508
aws_sigv4: [
523
509
access_key_id: "foo" ,
524
- secret_access_key: "bar" ,
525
- datetime: ~U[ 2024-01-01 00:00:00Z]
510
+ secret_access_key: "bar"
526
511
] ,
527
512
body: "hello" ,
528
513
plug: plug
@@ -531,33 +516,22 @@ defmodule Req.StepsTest do
531
516
assert Req . put! ( req ) . body == "ok"
532
517
end
533
518
534
- # TODO: flaky
535
- @ tag :skip
536
519
test "body: enumerable" do
537
520
plug = fn conn ->
538
521
assert { :ok , "hello" , conn } = Plug.Conn . read_body ( conn )
539
-
540
- assert Plug.Conn . get_req_header ( conn , "x-amz-content-sha256" ) == [ "UNSIGNED-PAYLOAD" ]
541
-
542
- assert Plug.Conn . get_req_header ( conn , "authorization" ) == [
543
- """
544
- AWS4-HMAC-SHA256 \
545
- Credential=foo/20240101/us-east-1/s3/aws4_request,\
546
- SignedHeaders=accept-encoding;content-length;host;user-agent;x-amz-content-sha256;x-amz-date,\
547
- Signature=6d8d9e360bf82d48064ee93cc628133da813bfc9b587fe52f8792c2335b29312\
548
- """
549
- ]
550
-
522
+ assert [ "AWS4-HMAC-SHA256" <> _ ] = Plug.Conn . get_req_header ( conn , "authorization" )
523
+ assert [ "UNSIGNED-PAYLOAD" ] = Plug.Conn . get_req_header ( conn , "x-amz-content-sha256" )
551
524
Plug.Conn . send_resp ( conn , 200 , "ok" )
552
525
end
553
526
554
527
req =
555
528
Req . new (
556
- url: "http://localhost " ,
529
+ url: "http://example.com " ,
557
530
aws_sigv4: [
558
531
access_key_id: "foo" ,
559
532
secret_access_key: "bar" ,
560
- datetime: ~U[ 2024-01-01 00:00:00Z]
533
+ # test setting explicit :service
534
+ service: :s3
561
535
] ,
562
536
headers: [ content_length: 5 ] ,
563
537
body: Stream . take ( [ "hello" ] , 1 ) ,
0 commit comments