Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Test signing of oauth2 requests.

  • Loading branch information...
commit ca21f0fe8dabb3c4dff279527b05810fa56e344e 1 parent d9ef5e5
chirags@google.com authored
Showing with 19 additions and 0 deletions.
  1. +19 −0 test/general/ApiOAuth2Test.php
View
19 test/general/ApiOAuth2Test.php
@@ -18,6 +18,8 @@
* under the License.
*/
+require_once "../src/apiClient.php";
+require_once "BaseTest.php";
require_once "io/apiREST.php";
class ApiOAuth2Test extends BaseTest {
@@ -36,6 +38,23 @@ public function setUp() {
$this->auth->accessType = "offline";
}
+ public function testSign() {
+ $req = new apiHttpRequest('http://localhost');
+ $req = $this->auth->sign($req);
+
+ $this->assertEquals('http://localhost?key=devKey', $req->getUrl());
+
+ // test accessToken
+ $this->auth->accessToken = array(
+ 'access_token' => 'ACCESS_TOKEN',
+ 'created' => time(),
+ 'expires_in' => '3600'
+ );
+ $req = $this->auth->sign($req);
+ $auth = $req->getRequestHeader('authorization');
+ $this->assertEquals('Bearer ACCESS_TOKEN', $auth);
+ }
+
public function testCreateAuthUrl() {
$authUrl = $this->auth->createAuthUrl("http://googleapis.com/scope/foo");
$expected = "https://accounts.google.com/o/oauth2/auth"
Please sign in to comment.
Something went wrong with that request. Please try again.