Ejemplo n.º 1
0
    /**
     * @group ZF-10851
     */
    public function testOauthClientPreparationWithRealmConfigurationOption()
    {
        require_once "Zend/Oauth/Token/Access.php";
        
        $options = array(
            'requestMethod' => 'GET',
            'siteUrl'       => 'http://www.example.com',
            'realm'			=> 'someRealm'
        );
        $token = new Zend_Oauth_Token_Access();

        require_once 'Zend/Oauth/Client.php';
        $client = new Zend_Oauth_Client($options);
        $this->assertEquals(NULL,$client->getHeader('Authorization'));
        
        $client->setToken($token);
        $client->setUri('http://oauth.example.com');
        $client->prepareOauth();
        
        $this->assertNotContains('realm=""',$client->getHeader('Authorization'));
        $this->assertContains('realm="someRealm"',$client->getHeader('Authorization'));
    }
Ejemplo n.º 2
0
 /**
  * @group ZF-11663
  */
 public function testOauthClientAcceptsGetParametersThroughSetter()
 {
     require_once "Zend/Oauth/Token/Access.php";
     $token = new Zend_Oauth_Token_Access();
     $options = array('requestMethod' => 'GET', 'requestScheme' => Zend_Oauth::REQUEST_SCHEME_QUERYSTRING, 'realm' => 'someRealm');
     require_once 'Zend/Oauth/Client.php';
     $client = new Zend_Oauth_Client($options);
     $client->setToken($token);
     $client->setUri('http://www.example.com/?test=FooBar');
     $queryString = $client->getUri()->getQuery();
     // Check that query string was set properly
     $this->assertSame('test=FooBar', $queryString);
     // Change the GET parameters
     $client->setParameterGet('test', 'FooBaz');
     $client->setParameterGet('second', 'TestTest');
     // Prepare the OAuth request
     $client->prepareOauth();
     $queryString = $client->getUri()->getQuery();
     // Ensure that parameter 'test' is unchanged, as URI parameters
     // should take precedence over ones set with setParameterGet
     $this->assertContains('test=FooBar', $queryString);
     // Ensure that new parameter was added
     $this->assertContains('second=TestTest', $queryString);
 }