Пример #1
0
 public function testMultiDimensionalArrayWithNonDefaultQueryAggregator()
 {
     $p = new OauthPlugin($this->config);
     $request = $this->getRequest();
     $aggregator = new CommaAggregator();
     $query = $request->getQuery()->setAggregator($aggregator)->set('g', array('h', 'i', 'j'))->set('k', array('l'))->set('m', array('n', 'o'));
     $this->assertContains('a%3Db%26c%3Dd%26e%3Df%26g%3Dh%2Ci%2Cj%26k%3Dl%26m%3Dn%2Co', $p->getStringToSign($request, self::TIMESTAMP, self::NONCE));
 }
Пример #2
0
 public function testOptionalOauthParametersAreNotAutomaticallyAdded()
 {
     // The only required Oauth parameters are the consumer key and secret. That is enough credentials
     // for signing oauth requests.
     $config = array('consumer_key' => 'foo', 'consumer_secret' => 'bar');
     $plugin = new OauthPlugin($config);
     $event = new Event(array('request' => $this->getRequest(), 'timestamp' => self::TIMESTAMP));
     $timestamp = $plugin->getTimestamp($event);
     $request = $event['request'];
     $nonce = $plugin->generateNonce($request);
     $paramsToSign = $plugin->getParamsToSign($request, $timestamp, $nonce);
     $optionalParams = array('callback' => 'oauth_callback', 'token' => 'oauth_token', 'verifier' => 'oauth_verifier', 'token_secret' => 'token_secret');
     foreach ($optionalParams as $optionName => $oauthName) {
         $this->assertArrayNotHasKey($oauthName, $paramsToSign, "Optional Oauth param '{$oauthName}' was not set via config variable '{$optionName}', but it is listed in getParamsToSign().");
     }
 }
 public function testDoesNotAddFalseyValuesToAuthorization()
 {
     unset($this->config['token']);
     $p = new OauthPlugin($this->config);
     $event = new Event(array('request' => $this->getRequest(), 'timestamp' => self::TIMESTAMP));
     $p->onRequestBeforeSend($event);
     $this->assertTrue($event['request']->hasHeader('Authorization'));
     $this->assertNotContains('oauth_token=', (string) $event['request']->getHeader('Authorization'));
 }