Permalink
Browse files

test & fix lowercase method name triggers destroy session

  • Loading branch information...
1 parent 2c81799 commit 3e1a5d864e945d07d156dbf73aeef56656fb924a @daaku daaku committed Jul 17, 2012
Showing with 29 additions and 2 deletions.
  1. +3 −2 src/base_facebook.php
  2. +26 −0 tests/tests.php
View
@@ -754,8 +754,9 @@ protected function _restserver($params) {
$this->throwAPIException($result);
}
- if ($params['method'] === 'auth.expireSession' ||
- $params['method'] === 'auth.revokeAuthorization') {
+ $method = strtolower($params['method']);
+ if ($method === 'auth.expiresession' ||
+ $method === 'auth.revokeauthorization') {
$this->destroySession();
}
View
@@ -1306,6 +1306,32 @@ public function testAuthExpireSessionDestroysSession() {
);
}
+ public function testLowercaseAuthRevokeAuthDestroysSession() {
+ $methods_to_stub = array(
+ '_oauthRequest',
+ 'destroySession',
+ );
+ $constructor_args = array(array(
+ 'appId' => self::APP_ID,
+ 'secret' => self::SECRET
+ ));
+ $key = 'foo';
+ $val = 42;
+ $stub = $this->getMock(
+ 'TransientFacebook', $methods_to_stub, $constructor_args);
+ $stub
+ ->expects($this->once())
+ ->method('_oauthRequest')
+ ->will($this->returnValue("{\"$key\":$val}"));
+ $stub
+ ->expects($this->once())
+ ->method('destroySession');
+ $this->assertEquals(
+ array($key => $val),
+ $stub->api(array('method' => 'auth.revokeauthorization'))
+ );
+ }
+
protected function generateMD5HashOfRandomValue() {
return md5(uniqid(mt_rand(), true));
}

0 comments on commit 3e1a5d8

Please sign in to comment.