Author: bhofmann
Date: Mon Jan 10 16:46:02 2011
New Revision: 1057273
URL: http://svn.apache.org/viewvc?rev=1057273&view=rev
Log:
Added opensocial_instance_id to SigningFetcher as specified at
http://opensocial-resources.googlecode.com/svn/spec/1.1/Core-Gadget.xml#SignedFetch
Modified:
shindig/trunk/php/src/gadgets/SigningFetcher.php
shindig/trunk/php/test/gadgets/SigningFetcherTest.php
Modified: shindig/trunk/php/src/gadgets/SigningFetcher.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/src/gadgets/SigningFetcher.php?rev=1057273&r1=1057272&r2=1057273&view=diff
==============================================================================
--- shindig/trunk/php/src/gadgets/SigningFetcher.php (original)
+++ shindig/trunk/php/src/gadgets/SigningFetcher.php Mon Jan 10 16:46:02 2011
@@ -33,6 +33,7 @@ class SigningFetcher extends RemoteConte
protected static $OPENSOCIAL_VIEWERID = "opensocial_viewer_id";
protected static $OPENSOCIAL_APPID = "opensocial_app_id";
protected static $OPENSOCIAL_APPURL = "opensocial_app_url";
+ protected static $OPENSOCIAL_INSTANCEID = "opensocial_instance_id";
protected static $XOAUTH_PUBLIC_KEY_OLD = "xoauth_signature_publickey";
protected static $XOAUTH_PUBLIC_KEY_NEW = "xoauth_public_key";
protected static $ALLOWED_PARAM_NAME = '^[-_[:alnum:]]+$';
@@ -166,23 +167,27 @@ class SigningFetcher extends RemoteConte
if ($signOwner) {
$owner = $token->getOwnerId();
if ($owner != null) {
- $msgParams[SigningFetcher::$OPENSOCIAL_OWNERID] = $owner;
+ $msgParams[SigningFetcher::$OPENSOCIAL_OWNERID] = $owner;
}
}
if ($signViewer) {
$viewer = $token->getViewerId();
if ($viewer != null) {
- $msgParams[SigningFetcher::$OPENSOCIAL_VIEWERID] = $viewer;
+ $msgParams[SigningFetcher::$OPENSOCIAL_VIEWERID] = $viewer;
}
}
if ($signOwner || $signViewer) {
$app = $token->getAppId();
if ($app != null) {
- $msgParams[SigningFetcher::$OPENSOCIAL_APPID] = $app;
+ $msgParams[SigningFetcher::$OPENSOCIAL_APPID] = $app;
}
$url = $token->getAppUrl();
if ($url != null) {
- $msgParams[SigningFetcher::$OPENSOCIAL_APPURL] = $url;
+ $msgParams[SigningFetcher::$OPENSOCIAL_APPURL] = $url;
+ }
+ $moduleId = $token->getModuleId();
+ if ($moduleId != null) {
+ $msgParams[SigningFetcher::$OPENSOCIAL_INSTANCEID] = $moduleId;
}
}
}
Modified: shindig/trunk/php/test/gadgets/SigningFetcherTest.php
URL:
http://svn.apache.org/viewvc/shindig/trunk/php/test/gadgets/SigningFetcherTest.php?rev=1057273&r1=1057272&r2=1057273&view=diff
==============================================================================
--- shindig/trunk/php/test/gadgets/SigningFetcherTest.php (original)
+++ shindig/trunk/php/test/gadgets/SigningFetcherTest.php Mon Jan 10 16:46:02
2011
@@ -51,12 +51,12 @@ EOD;
* SigningFetcher test case.
*/
class SigningFetcherTest extends PHPUnit_Framework_TestCase {
-
+
/**
* @var SigningFetcher
*/
private $signingFetcher;
-
+
/**
* Prepares the environment before running a test.
*/
@@ -125,7 +125,7 @@ EOD;
// OAuth Request Body Hash 1.0 Draft 4 Example
$this->assertEquals('Lve95gjOVATpfV8EL5X4nxwjKHE=',
$query['oauth_body_hash']);
}
-
+
/**
* Tests SigningFetcher->fetchRequest
*/
@@ -137,7 +137,7 @@ EOD;
$this->signingFetcher->fetchRequest($request);
$this->verifySignedRequest($request);
}
-
+
private function verifySignedRequest(RemoteContentRequest $request) {
$url = parse_url($request->getUrl());
$query = array();
@@ -149,6 +149,12 @@ EOD;
} else {
$this->assertEquals(base64_encode(sha1($request->getPostBody(), true)),
$query['oauth_body_hash']);
}
+ $this->assertEquals('owner', $query['opensocial_owner_id']);
+ $this->assertEquals('viewer', $query['opensocial_viewer_id']);
+ $this->assertEquals('app', $query['opensocial_app_id']);
+ $this->assertEquals('appUrl', $query['opensocial_app_url']);
+ $this->assertEquals('1', $query['opensocial_instance_id']);
+ $this->assertEquals($query['xoauth_signature_publickey'],
$query['xoauth_public_key']);
$oauthRequest = OAuthRequest::from_request($request->getMethod(),
$request->getUrl(), array_merge($query, $post));
$signature_method = new MockSignatureMethod();
$signature_valid = $signature_method->check_signature($oauthRequest, null,
null, $query['oauth_signature']);