

Nextrek
@ 461
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
<?php use Facebook\FacebookRedirectLoginHelper; use Facebook\FacebookRequest; use Facebook\FacebookSession; class FacebookRedirectLoginHelperTest extends PHPUnit_Framework_TestCase { const REDIRECT_URL = 'http://invalid.zzz'; public function testLoginURL() { $helper = new FacebookRedirectLoginHelper( self::REDIRECT_URL, FacebookTestCredentials::$appId, FacebookTestCredentials::$appSecret ); $helper->disableSessionStatusCheck(); $loginUrl = $helper->getLoginUrl(); $state = $_SESSION['FBRLH_state']; $params = array( 'client_id' => FacebookTestCredentials::$appId, 'redirect_uri' => self::REDIRECT_URL, 'state' => $state, 'sdk' => 'php-sdk-' . FacebookRequest::VERSION, 'scope' => implode(',', array()) ); $expectedUrl = 'https://www.facebook.com/' . FacebookRequest::GRAPH_API_VERSION . '/dialog/oauth?'; $this->assertTrue(strpos($loginUrl, $expectedUrl) === 0, 'Unexpected base login URL returned from getLoginUrl().'); foreach ($params as $key => $value) { $this->assertContains($key . '=' . urlencode($value), $loginUrl); } } public function testReRequestUrlContainsState() { $helper = new FacebookRedirectLoginHelper( self::REDIRECT_URL, FacebookTestCredentials::$appId, FacebookTestCredentials::$appSecret ); $helper->disableSessionStatusCheck(); $reRequestUrl = $helper->getReRequestUrl(); $state = $_SESSION['FBRLH_state']; $this->assertContains('state=' . urlencode($state), $reRequestUrl); } public function testLogoutURL() { $helper = new FacebookRedirectLoginHelper( self::REDIRECT_URL, FacebookTestCredentials::$appId, FacebookTestCredentials::$appSecret ); $helper->disableSessionStatusCheck(); $logoutUrl = $helper->getLogoutUrl( FacebookTestHelper::$testSession, self::REDIRECT_URL ); $params = array( 'next' => self::REDIRECT_URL, 'access_token' => FacebookTestHelper::$testSession->getToken() ); $expectedUrl = 'https://www.facebook.com/logout.php?'; $this->assertTrue(strpos($logoutUrl, $expectedUrl) !== false); foreach ($params as $key => $value) { $this->assertTrue( strpos($logoutUrl, $key . '=' . urlencode($value)) !== false ); } } public function testLogoutURLFailsWithAppSession() { $helper = new FacebookRedirectLoginHelper( self::REDIRECT_URL, FacebookTestCredentials::$appId, FacebookTestCredentials::$appSecret ); $helper->disableSessionStatusCheck(); $session = FacebookTestHelper::getAppSession(); $this->setExpectedException( 'Facebook\\FacebookSDKException', 'Cannot generate a Logout URL with an App Session.' ); $helper->getLogoutUrl( $session, self::REDIRECT_URL ); } public function testCSPRNG() { $helper = new FacebookRedirectLoginHelper( self::REDIRECT_URL, FacebookTestCredentials::$appId, FacebookTestCredentials::$appSecret ); $this->assertEquals(1, preg_match('/^([0-9a-f]+)$/', $helper->random(32))); } } |
Commits for Nextrek/Android/SmartCharging/endPoints/nightly/fb_SDK/tests/FacebookRedirectLoginHelperTest.php
Revision | Author | Commited | Message |
---|---|---|---|
461 |
![]() |
Mon 03 Aug, 2015 10:04:56 +0000 | Aggiunto supporto login Facebook, logout utente e modifiche (solo lato repo) all’utente e al locale. |