Exemplo n.º 1
0
 /**
  * Test HMAC-SHA1 signing
  *
  * Hash result + parameters taken from
  * http://wiki.oauth.net/w/page/12238556/TestCases
  *
  * @return void
  */
 public function testHmacSigning()
 {
     $request = new Request();
     $request->url('http://photos.example.net/photos')->body(['file' => 'vacation.jpg', 'size' => 'original']);
     $options = ['consumerKey' => 'dpf43f3p2l4k3l03', 'consumerSecret' => 'kd94hf93k423kf44', 'tokenSecret' => 'pfkkdhi9sl3r4s00', 'token' => 'nnch734d00sl2jdk', 'nonce' => 'kllo9940pd9333jh', 'timestamp' => '1191242096'];
     $auth = new Oauth();
     $auth->authentication($request, $options);
     $result = $request->header('Authorization');
     $expected = 'tR3+Ty81lMeYAr/Fid0kMTYa/WM=';
     $this->assertContains('oauth_signature="' . $expected . '"', urldecode($result));
 }
Exemplo n.º 2
0
 /**
  * Test RSA-SHA1 signing with a private key string and passphrase file
  *
  * Hash result + parameters taken from
  * http://wiki.oauth.net/w/page/12238556/TestCases
  *
  * @return void
  */
 public function testRsaSigningStringWithPassphraseFile()
 {
     $this->skipIf(PHP_EOL != "\n", 'Just the line ending "\\n" is supported. You can run the test again e.g. on a linux system.');
     $request = new Request();
     $request->url('http://photos.example.net/photos')->body(['file' => 'vacaction.jpg', 'size' => 'original']);
     $privateKey = $this->privateKeyStringEnc;
     $passphrase = fopen(TEST_APP . DS . 'config' . DS . 'key_passphrase_lf', 'r');
     $options = ['method' => 'RSA-SHA1', 'consumerKey' => 'dpf43f3p2l4k3l03', 'nonce' => '13917289812797014437', 'timestamp' => '1196666512', 'privateKey' => $privateKey, 'privateKeyPassphrase' => $passphrase];
     $auth = new Oauth();
     $auth->authentication($request, $options);
     $result = $request->header('Authorization');
     $expected = 'jvTp/wX1TYtByB1m+Pbyo0lnCOLIsyGCH7wke8AUs3BpnwZJtAuEJkvQL2/9n4s5wUmUl4aCI4BwpraNx4RtEXMe5qg5T1LVTGliMRpKasKsW//e+RinhejgCuzoH26dyF8iY2ZZ/5D1ilgeijhV/vBka5twt399mXwaYdCwFYE=';
     $this->assertContains('oauth_signature="' . $expected . '"', urldecode($result));
     $expected = 0;
     $this->assertEquals($expected, ftell($passphrase));
 }