public function testAssertFriendUidWillThrowExceptionForTimestampOutOfRange()
 {
     $time = time() - 181;
     list($uid, $friendUid, $secret, $expected) = $this->getFriendSignature($time);
     static::setExpectedException('Graze\\Gigya\\Exceptions\\InvalidTimestampException', sprintf("The supplied timestamp: %d is more than 180 seconds different to now: %d", $time, time()));
     $this->validator->assertFriendUid($uid, $friendUid, $time, $secret, $expected);
 }
 /**
  * @param GuzzleResponseInterface $response
  * @return bool
  */
 public function validate(GuzzleResponseInterface $response)
 {
     $data = json_decode($response->getBody(), true);
     if (!is_array($data)) {
         return false;
     }
     foreach ($this->requiredFields as $field) {
         if (!array_key_exists($field, $data)) {
             return false;
         }
     }
     if (array_key_exists('UID', $data) && array_key_exists('UIDSignature', $data) && array_key_exists('signatureTimestamp', $data)) {
         return $this->signatureValidator->validateUid($data['UID'], $data['signatureTimestamp'], $this->secret, $data['UIDSignature']);
     }
     return true;
 }
 public function testUidSignatureWithInvalidSignatureWillThrowException()
 {
     $uid = 'diofu90ifgdf';
     $timestamp = time();
     $signatureValidator = new SignatureValidator();
     $signature = $signatureValidator->calculateSignature($timestamp . '_' . $uid, 'secret');
     $body = sprintf('{
         "UID": "%s",
         "UIDSignature": "invalidSignature",
         "signatureTimestamp": "%d",
         "statusCode": 200,
         "errorCode": 0,
         "statusReason": "OK",
         "callId": "123456",
         "time": "2015-03-22T11:42:25.943Z"
     }', $uid, $timestamp);
     $response = m::mock('GuzzleHttp\\Message\\ResponseInterface');
     $response->shouldReceive('getBody')->andReturn($body);
     static::assertFalse($this->validator->validate($response));
     static::setExpectedException('Graze\\Gigya\\Exceptions\\InvalidUidSignatureException', sprintf("The supplied signature for uid: diofu90ifgdf does not match.\n Expected '%s'\n Supplied 'invalidSignature'", $signature));
     $this->validator->assert($response);
 }