function ALProfilesAPITest::testCanonicalizeRequest in Acquia Lift Connector 7.2
Same name and namespace in other branches
- 7 acquia_lift_profiles/tests/acquia_lift_profiles_unit.test \ALProfilesAPITest::testCanonicalizeRequest()
Tests the method that canonicalizes a request into a string for signing.
File
- acquia_lift_profiles/
tests/ acquia_lift_profiles_unit.test, line 366 - Unit tests for Acquia Lift Profiles module.
Class
- ALProfilesAPITest
- @file Unit tests for Acquia Lift Profiles module.
Code
function testCanonicalizeRequest() {
$method = 'GET';
$path = '/some/path';
$parameters = array(
'param' => 'stuff',
'another' => 'moar-stuff',
'last-param' => 'yet-moar-stuff',
);
$headers = array(
'User-Agent' => 'Drupal',
'Accept' => 'text/plain',
'Host' => 'example.com',
);
$acquia_lift_profiles_api = $this
->getALProfilesAPI();
$expected = "GET\naccept:text/plain\nhost:example.com\nuser-agent:Drupal\n/some/path?another=moar-stuff&last-param=yet-moar-stuff¶m=stuff";
$str = $acquia_lift_profiles_api
->canonicalizeRequest($method, $path, $parameters, $headers, FALSE);
$this
->assertEqual($str, $expected);
$method = 'PUT';
$parameters['new-param'] = 'ohai';
// Add a header that's not in the whitelist, it should not get added to the
// canonical request.
$headers['Content-Type'] = 'application/x-www-form-urlencoded';
$expected = "PUT\naccept:text/plain\nhost:example.com\nuser-agent:Drupal\n/some/path?another=moar-stuff&last-param=yet-moar-stuff&new-param=ohai¶m=stuff";
$str = $acquia_lift_profiles_api
->canonicalizeRequest($method, $path, $parameters, $headers, FALSE);
$this
->assertEqual($str, $expected);
}