public function testV1HMAC()
 {
     foreach (array('GET', 'POST', 'PUT', 'DELETE') as $httpMethod) {
         $requestHeaderGenerator = new RequestHeaderGenerator($this->getCommunicatorConfiguration(), $httpMethod, '/v1/consumer/ANDR%C3%89E/?q=na%20me');
         $requestHeaders = $requestHeaderGenerator->generateRequestHeaders();
         $httpHeaderHelper = new HttpHeaderHelper();
         $curlHeaders = $httpHeaderHelper->generateRawHeaders($requestHeaders);
         $this->assertCount(4, $curlHeaders);
         $result = false;
         foreach ($curlHeaders as $curlHeader) {
             $result |= preg_match('/^Authorization: GCS v1HMAC:' . $this->getApiKey() . ':[a-zA-Z0-9+\\/]+={0,2}/', $curlHeader);
         }
         $this->assertEquals(true, $result);
     }
 }
 /**
  * @param resource $curlHandle
  * @param string $httpMethod
  * @param string $requestUri
  * @param string[] $requestHeaders
  * @param string $body
  * @param ProxyConfiguration|null $proxyConfiguration
  */
 protected function setCurlOptions($curlHandle, $httpMethod, $requestUri, $requestHeaders, $body, ProxyConfiguration $proxyConfiguration = null)
 {
     if (!is_array($requestHeaders)) {
         throw new UnexpectedValueException('Invalid request headers; expected array');
     }
     curl_setopt($curlHandle, CURLOPT_HEADER, true);
     curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, $httpMethod);
     curl_setopt($curlHandle, CURLOPT_URL, $requestUri);
     if (in_array($httpMethod, array('PUT', 'POST')) && $body) {
         curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $body);
     }
     if (count($requestHeaders) > 0) {
         $httpHeaderHelper = new HttpHeaderHelper();
         curl_setopt($curlHandle, CURLOPT_HTTPHEADER, $httpHeaderHelper->generateRawHeaders($requestHeaders));
     }
     if (!is_null($proxyConfiguration)) {
         $curlProxy = $proxyConfiguration->getCurlProxy();
         if (!empty($curlProxy)) {
             curl_setopt($curlHandle, CURLOPT_PROXY, $curlProxy);
         }
         $curlProxyUserPwd = $proxyConfiguration->getCurlProxyUserPwd();
         if (!empty($curlProxyUserPwd)) {
             curl_setopt($curlHandle, CURLOPT_PROXYUSERPWD, $curlProxyUserPwd);
         }
     }
 }