Skip to content

Commit

Permalink
SUITEDEV-5349 Add timezone for tests using Datetime and add signedHea…
Browse files Browse the repository at this point in the history
…ders lowercase test
  • Loading branch information
tt1991 committed Feb 17, 2016
1 parent 0928feb commit 951972d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/unit/AuthenticateRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function itShouldValidatePresignedUrlRequestWithSpecialCharacters()
'SERVER_NAME' => 'service.example.com',
);
$keyDB = array('service_api_key' => 'service_secret');
$this->createEscher('eu/service/ems_request', new DateTime('20150310T173248Z'))->authenticate($keyDB, $serverVars);
$this->createEscher('eu/service/ems_request', new DateTime('20150310T173248Z', new DateTimeZone('GMT')))->authenticate($keyDB, $serverVars);
}

/**
Expand Down
26 changes: 26 additions & 0 deletions test/unit/SignRequestUsingHeaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,32 @@ public function itShouldSignRequest()
$this->assertEqualMaps($expectedHeaders, $actualHeaders);
}

/**
* @test
* @group sign_request
*/
public function itShouldSignRequestWithUppercaseHeader()
{
$inputHeaders = array(
'content-type' => 'application/x-www-form-urlencoded; charset=utf-8',
'host' => 'iam.amazonaws.com',
'TEST' => 'TEST message'
);
$expectedHeaders = array(
'content-type' => 'application/x-www-form-urlencoded; charset=utf-8',
'host' => 'iam.amazonaws.com',
'x-ems-date' => '20110909T233600Z',
'x-ems-auth' => 'EMS-HMAC-SHA256 Credential=AKIDEXAMPLE/20110909/us-east-1/iam/aws4_request, SignedHeaders=content-type;host;test;x-ems-date, Signature=f6ae6c5a72056a6f9ad42a9bbfebb868243b4fe451c38b2817739f75c197d26f',
'test' => 'TEST message',
);
$headersToSign = array('content-type', 'host', 'x-ems-date', 'TEST');
$actualHeaders = $this->createEscher('us-east-1/iam/aws4_request')->signRequest(
'AKIDEXAMPLE', 'wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY',
'POST', 'http://iam.amazonaws.com/', 'Action=ListUsers&Version=2010-05-08', $inputHeaders, $headersToSign
);
$this->assertEqualMaps($expectedHeaders, $actualHeaders);
}

/**
* @test
* @group sign_request
Expand Down
2 changes: 1 addition & 1 deletion test/unit/SignRequestUsingQueryStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function itShouldRespectWhenUrlHasLocationHash()
*/
public function itShouldRespectWhenUrlHasSpecialChars()
{
$signedUrl = $this->createEscher('eu/service/ems_request', new DateTime('20150310T173248Z'))->presignUrl(
$signedUrl = $this->createEscher('eu/service/ems_request', new DateTime('20150310T173248Z', new DateTimeZone('GMT')))->presignUrl(
'service_api_key',
'service_secret',
'https://service.example.com/login?id=12345678&domain=login.example.com&redirect_to=https%3A%2F%2Fhome.dev%2Fbootstrap.php%3Fr%3Dservice%2Findex%26service%3Dservice_name%3F'
Expand Down

0 comments on commit 951972d

Please sign in to comment.