Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Commit

Permalink
Assume that StorageAuthScheme::computeCanonicalizedResource receives …
Browse files Browse the repository at this point in the history
…ordered query param values
  • Loading branch information
Diego Luces committed Nov 10, 2016
1 parent 3eac8c2 commit 51bd012
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 3 additions & 6 deletions src/Common/Internal/Authentication/StorageAuthScheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,9 @@ protected function computeCanonicalizedResource($url, $queryParams)
// 9. Group query parameters
// 10. Append a new line character (\n) after each name-value pair.
foreach ($queryParams as $key => $value) {
// Grouping query parameters
$values = explode(Resources::SEPARATOR, $value);
sort($values);
$separated = implode(Resources::SEPARATOR, $values);

$canonicalizedResource .= "\n" . $key . ':' . $separated;
// $value must already be ordered lexicographically
// See: ServiceRestProxy::groupQueryValues
$canonicalizedResource .= "\n" . $key . ':' . $value;
}

return $canonicalizedResource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

namespace MicrosoftAzure\Storage\Tests\Unit\Common\Internal\Authentication;
use MicrosoftAzure\Storage\Common\Internal\Authentication\StorageAuthScheme;
use MicrosoftAzure\Storage\Common\Internal\ServiceRestProxy;
use MicrosoftAzure\Storage\Tests\Unit\Utilities;
use MicrosoftAzure\Storage\Tests\Mock\Common\Internal\Authentication\StorageAuthSchemeMock;
use MicrosoftAzure\Storage\Tests\Framework\TestResources;
Expand Down Expand Up @@ -94,7 +95,13 @@ public function testComputeCanonicalizedResourceMockMultipleValues()
{
$queryVariables = array();
$queryVariables['COMP'] = 'list';
$queryVariables[Resources::QP_INCLUDE] = 'snapshots,metadata,uncommittedblobs';
$queryVariables[Resources::QP_INCLUDE] = ServiceRestProxy::groupQueryValues(
array(
'snapshots',
'metadata',
'uncommittedblobs'
)
);
$expectedQueryPart = "comp:list\ninclude:metadata,snapshots,uncommittedblobs";
$accountName = TestResources::ACCOUNT_NAME;
$url = TestResources::URI1;
Expand Down

0 comments on commit 51bd012

Please sign in to comment.