Skip to content

Commit

Permalink
Merge pull request #110 from ringcentral/pkce-fixes
Browse files Browse the repository at this point in the history
Minor non-functional enhancements to reduce error/warnings
  • Loading branch information
byrnereese authored May 29, 2022
2 parents d9c5b96 + 40a2e66 commit bc5a20a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/Platform/Platform.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,17 @@ public function loggedIn()
*/
public function authUrl($options)
{

return $this->createUrl(self::AUTHORIZE_ENDPOINT . '?' . http_build_query(
[
'response_type' => 'code',
'redirect_uri' => $options['redirectUri'] ? $options['redirectUri'] : null,
'client_id' => $this->_clientId,
'state' => $options['state'] ? $options['state'] : null,
'brand_id' => $options['brandId'] ? $options['brandId'] : null,
'display' => $options['display'] ? $options['display'] : null,
'prompt' => $options['prompt'] ? $options['prompt'] : null,
'code_challenge' => $options['code_challenge'] ? $options['code_challenge'] : null,
'code_challenge_method' => $options['code_challenge_method'] ? $options['code_challenge_method'] : null
'response_type' => 'code',
'redirect_uri' => $options['redirectUri'] ? $options['redirectUri'] : null,
'client_id' => $this->_clientId,
'state' => array_key_exists('state',$options) ? $options['state'] : null,
'brand_id' => array_key_exists('brandId',$options) ? $options['brandId'] : null,
'display' => array_key_exists('display',$options) ? $options['display'] : null,
'prompt' => array_key_exists('prompt',$options) ? $options['prompt'] : null,
'code_challenge' => array_key_exists('code_challenge',$options) ? $options['code_challenge'] : null,
'code_challenge_method' => array_key_exists('code_challenge_method',$options) ? $options['code_challenge_method'] : null
]), [
'addServer' => 'true'
]);
Expand Down
11 changes: 11 additions & 0 deletions src/Platform/PlatformTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ public function testLogout()

}

public function testAuthUrl()
{
$sdk = $this->getSDK();
$url = $sdk->platform()->authUrl(array(
'redirectUri' => 'foo',
'state' => 'bar',
'client_id' => 'baz'
));
$this->assertEquals( $url, "https://whatever/restapi/oauth/authorize?response_type=code&redirect_uri=foo&client_id=whatever&state=bar" );
}

public function testApiUrl()
{

Expand Down
12 changes: 12 additions & 0 deletions src/Subscription/SubscriptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use RingCentral\SDK\Subscription\Subscription;
use RingCentral\SDK\Test\TestCase;
use PubNub\Models\Consumer\PubSub\PNMessageResult;
use PubNub\PNConfiguration;
use PubNub\PubNub;

class SubscriptionTest extends TestCase
{
Expand Down Expand Up @@ -288,4 +290,14 @@ public function testKeepPolling()

}

public function testGetNullPubnub()
{
$sdk = $this->getSDK();
$s = $this->createSubscription($sdk);
//$pnconf = new PNConfiguration();
//$s->_pubnub = new PubNub($pnconf);
$pn = $s->pubnub();
$this->assertNull($pn);
}

}

0 comments on commit bc5a20a

Please sign in to comment.