@@ -2,7 +2,7 @@ import { AWSSignerV4 } from "./mod.ts";
22import {
33 assertEquals ,
44 assertStringIncludes ,
5- } from "https://deno.land/std@0.84 .0/testing/asserts.ts" ;
5+ } from "https://deno.land/std@0.95 .0/testing/asserts.ts" ;
66
77Deno . test ( "construct from env vars" , async ( ) => {
88 Deno . env . set ( "AWS_ACCESS_KEY_ID" , "examplekey" ) ;
@@ -14,7 +14,7 @@ Deno.test("construct from env vars", async () => {
1414 const req = await signer . sign (
1515 "dynamodb" ,
1616 new Request ( "https://test.dynamodb.us-east-1.amazonaws.com" , {
17- method : "GET " ,
17+ method : "POST " ,
1818 headers : { "x-hello" : "world" } ,
1919 body : "A dynamodb request!" ,
2020 } ) ,
@@ -25,6 +25,8 @@ Deno.test("construct from env vars", async () => {
2525 . toString ( )
2626 . padStart ( 2 , "0" )
2727 } ${ now . getDate ( ) . toString ( ) . padStart ( 2 , "0" ) } `;
28+ assertEquals ( req . method , "POST" ) ;
29+ assertEquals ( await req . text ( ) , "A dynamodb request!" ) ;
2830 assertStringIncludes ( req . headers . get ( "x-amz-date" ) ! , `${ today } T` ) ;
2931 assertEquals ( req . headers . get ( "x-amz-security-token" ) , "sessiontoken" ) ;
3032 assertEquals ( req . headers . get ( "x-hello" ) , "world" ) ;
@@ -34,7 +36,7 @@ Deno.test("construct from env vars", async () => {
3436 ) ;
3537 assertStringIncludes (
3638 req . headers . get ( "Authorization" ) ! ,
37- `AWS4-HMAC-SHA256 Credential=examplekey/${ today } /us-east-1/dynamodb/aws4_request, SignedHeaders=host;x-amz-date;x-amz-security-token;x-hello, Signature=` ,
39+ `AWS4-HMAC-SHA256 Credential=examplekey/${ today } /us-east-1/dynamodb/aws4_request, SignedHeaders=content-type; host;x-amz-date;x-amz-security-token;x-hello, Signature=` ,
3840 ) ;
3941} ) ;
4042
@@ -47,7 +49,7 @@ Deno.test("construct manually", async () => {
4749 const req = await signer . sign (
4850 "dynamodb" ,
4951 new Request ( "https://test.dynamodb.us-east-1.amazonaws.com" , {
50- method : "GET " ,
52+ method : "POST " ,
5153 headers : { "x-hello" : "world" } ,
5254 body : "A dynamodb request!" ,
5355 } ) ,
@@ -58,6 +60,8 @@ Deno.test("construct manually", async () => {
5860 . toString ( )
5961 . padStart ( 2 , "0" )
6062 } ${ now . getDate ( ) . toString ( ) . padStart ( 2 , "0" ) } `;
63+ assertEquals ( req . method , "POST" ) ;
64+ assertEquals ( await req . text ( ) , "A dynamodb request!" ) ;
6165 assertStringIncludes ( req . headers . get ( "x-amz-date" ) ! , `${ today } T` ) ;
6266 assertEquals ( req . headers . get ( "x-amz-security-token" ) , "session_token" ) ;
6367 assertEquals ( req . headers . get ( "x-hello" ) , "world" ) ;
@@ -67,7 +71,7 @@ Deno.test("construct manually", async () => {
6771 ) ;
6872 assertStringIncludes (
6973 req . headers . get ( "Authorization" ) ! ,
70- `AWS4-HMAC-SHA256 Credential=example_key/${ today } /us-east-2/dynamodb/aws4_request, SignedHeaders=host;x-amz-date;x-amz-security-token;x-hello, Signature=` ,
74+ `AWS4-HMAC-SHA256 Credential=example_key/${ today } /us-east-2/dynamodb/aws4_request, SignedHeaders=content-type; host;x-amz-date;x-amz-security-token;x-hello, Signature=` ,
7175 ) ;
7276} ) ;
7377
0 commit comments