public function request($uri, $method = Request::METHOD_GET, array $params = [], array $body = [], array $headers = [])
{
//Releases API container
\Scalr::getContainer()->release('api');
$jsonEncodedBody = !empty($body) ? json_encode($body) : '';
$date = gmdate('Y-m-d\\TH:i:s\\Z');
$c11dQueryString = '';
if (!empty($params)) {
ksort($params);
$c11dQueryString = http_build_query($params, null, '&', PHP_QUERY_RFC3986);
}
$stringToSign = $method . "\n" . $date . "\n" . self::TEST_SCRIPT_NAME . $uri . "\n" . $c11dQueryString . "\n" . (!empty($jsonEncodedBody) ? $jsonEncodedBody : '');
$sig = base64_encode(hash_hmac('sha256', $stringToSign, static::$apiKeyEntity->secretKey, 1));
$defaultHeaders = ['Content-Type' => 'application/json; charset=utf-8', 'x-scalr-key-id' => static::$apiKeyEntity->keyId, 'x-scalr-date' => $date, 'x-scalr-signature' => 'V1-HMAC-SHA256 ' . $sig];
$headers = array_merge($defaultHeaders, $headers);
$properties = ['REQUEST_METHOD' => $method, 'QUERY_STRING' => $c11dQueryString, 'REQUEST_URI' => self::TEST_HTTP_REFERER . $uri, 'raw.body' => $jsonEncodedBody, 'request.headers' => $headers, 'PATH_INFO' => $uri];
$properties = array_merge($this->getTestEnvProperties(), $properties);
$app = new ApiApplication([ApiApplication::SETTING_ENV_MOCK => $properties]);
$app->setupRoutes();
$app->call();
return new ApiTestResponse($app->response);
}