예제 #1
0
 /**
  * @covers PusherSignature::signRequest
  */
 public function testCanSignRequest()
 {
     $request = new HttpRequest('POST', '/apps/3/events');
     // We set variables in query to have always the same result
     $request->getQuery()->replace(array('auth_key' => $this->credentials->getKey(), 'auth_timestamp' => '1353088179', 'auth_version' => '1.0', 'body_md5' => 'ec365a775a4cd0599faeb73354201b6f'));
     $request->setResponseBody('{"name":"foo","channels":["project-3"],"data":"{\\"some\\":\\"data\\"}"}');
     $this->pusherSignature->signRequest($request, $this->credentials);
     $this->assertEquals('auth_key=278d425bdf160c739803&auth_timestamp=1353088179&auth_version=1.0&body_md5=ec365a775a4cd0599faeb73354201b6f&auth_signature=da454824c97ba181a32ccc17a72625ba02771f50b50e1e7430e47a1f3f457e6c', $request->getQuery('auth_signature'));
 }
예제 #2
0
 /**
  * Constructor
  *
  * @param Credentials $credentials
  */
 public function __construct(Credentials $credentials)
 {
     // Make sure we always have the app_id parameter as default
     parent::__construct('', array('command.params' => array('app_id' => $credentials->getAppId())));
     $this->credentials = $credentials;
     $this->setDescription(ServiceDescription::factory(sprintf(__DIR__ . '/ServiceDescription/Pusher-%s.php', self::LATEST_API_VERSION)));
     // Prefix the User-Agent by SDK version
     $this->setUserAgent('zfr-pusher-php/' . Version::VERSION, true);
     // Add a listener to sign each requests
     $this->signature = new PusherSignature();
     $this->addSubscriber(new SignatureListener($credentials, $this->signature));
 }
예제 #3
0
 /**
  * @covers PusherClient::__construct
  */
 public function testAssertApplicationIdIsAlwaysSent()
 {
     $config = $this->client->getConfig('command.params');
     $this->assertEquals($config['app_id'], $this->credentials->getAppId());
 }
예제 #4
0
 /**
  * Sign the authentication string
  *
  * @param  string $string
  * @param  Credentials $credentials
  * @return string
  */
 public function signString($string, Credentials $credentials)
 {
     return hash_hmac('sha256', $string, $credentials->getSecret());
 }