Index: tests/Zend/Oauth/OauthTest.php =================================================================== --- tests/Zend/Oauth/OauthTest.php (revision 23572) +++ tests/Zend/Oauth/OauthTest.php (working copy) @@ -70,4 +70,44 @@ $this->assertEquals('GET', $client->getRequestMethod()); $this->assertEquals('http://www.example.com', $client->getSiteUrl()); } + + /** + * @group ZF-10851 + */ + public function testOauthClientAcceptsRealmConfigurationOption() + { + $options = array( + 'realm' => 'http://www.example.com' + ); + + require_once 'Zend/Oauth/Client.php'; + $client = new Zend_Oauth_Client($options); + $this->assertEquals('http://www.example.com', $client->getRealm()); + } + + /** + * @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')); + } } Index: library/Zend/Oauth/Client.php =================================================================== --- library/Zend/Oauth/Client.php (revision 23572) +++ library/Zend/Oauth/Client.php (working copy) @@ -246,7 +246,8 @@ $oauthHeaderValue = $this->getToken()->toHeader( $this->getUri(true), $this->_config, - $this->_getSignableParametersAsQueryString() + $this->_getSignableParametersAsQueryString(), + $this->getRealm() ); $this->setHeaders('Authorization', $oauthHeaderValue); } elseif ($requestScheme == Zend_Oauth::REQUEST_SCHEME_POSTBODY) { Index: library/Zend/Oauth/Config.php =================================================================== --- library/Zend/Oauth/Config.php (revision 23572) +++ library/Zend/Oauth/Config.php (working copy) @@ -146,6 +146,13 @@ * @var Zend_Oauth_Token */ protected $_token = null; + + /** + * Define the OAuth realm + * + * @var string + */ + protected $_realm = null; /** * Constructor; create a new object with an optional array|Zend_Config @@ -214,6 +221,9 @@ case 'rsaPublicKey': $this->setRsaPublicKey($value); break; + case 'realm': + $this->setRealm($value); + break; } } if (isset($options['requestScheme'])) { @@ -655,4 +665,26 @@ { return $this->_token; } + + /** + * Set OAuth realm + * + * @param string $realm + * @return Zend_Oauth_Config + */ + public function setRealm($realm) + { + $this->_realm = $realm; + return $this; + } + + /** + * Get OAuth realm + * + * @return string + */ + public function getRealm() + { + return $this->_realm; + } } Index: library/Zend/Oauth/Config/ConfigInterface.php =================================================================== --- library/Zend/Oauth/Config/ConfigInterface.php (revision 23572) +++ library/Zend/Oauth/Config/ConfigInterface.php (working copy) @@ -72,4 +72,8 @@ public function setToken(Zend_Oauth_Token $token); public function getToken(); + + public function setRealm($realm); + + public function getRealm(); }