예제 #1
0
 /**
  *
  * Provide test coverage for major methods, some simple method are knowingly skiped.
  *
  * @param string        $operation
  * @param string        $apiKeySecret
  * @param string        $expectedSignature
  * @param string|null   $expectedErrorMsg
  * @param array         $data
  *
  * @dataProvider providerTestOperationAndSignature
  */
 public function testOperationAndSignature($operation, $apiKeySecret, $expectedSignature, $expectedErrorMsg, $data)
 {
     try {
         $req = new Raven\Request($operation, $data);
         $req->setSignature($apiKeySecret);
         $this->assertEquals($expectedSignature, $req->get('signature'));
     } catch (Raven\Exceptions\SignatureException $e) {
         $this->assertEquals($expectedErrorMsg, $e->getMessage());
     }
 }
예제 #2
0
 /**
  * @param  Request      $request
  * @return Response
  * @throws Exceptions\ResponseException
  * @throws Exceptions\SignatureException
  */
 public function send(Request $request)
 {
     $request->setApiKeyId($this->accessKeyId);
     $request->setSignature($this->accessKeySecret);
     //Call Httpclient with request
     list($httpResponseHeader, $rawResponseData) = $this->makeHttpClientCall($request);
     if ($httpResponseHeader['status'] != 200) {
         throw new Exceptions\ResponseException($httpResponseHeader['reason'], $httpResponseHeader['status']);
     }
     $response = new Response($request->getOperation(), $httpResponseHeader, $rawResponseData);
     if (!$response->validateSignature($this->accessKeySecret)) {
         throw new Exceptions\SignatureException(sprintf(ExceptionMessages::INVALID_SIGNATURE, json_encode($response->getSignatureViladtionResults())));
     }
     return $response;
 }