From 329d5c24a830bf9141ba232b4a88d7fe67546821 Mon Sep 17 00:00:00 2001 From: "byrne.reese" Date: Fri, 27 May 2022 23:30:24 -0700 Subject: [PATCH 1/7] fixed array key exists lookup to better avoid errors --- composer.json | 2 +- src/Platform/Platform.php | 23 +++++++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index 95fa010c..847531bd 100755 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "php": ">=7.1", "guzzlehttp/psr7": "^1.4.2", "pubnub/pubnub": "^4.0.0", - "symfony/event-dispatcher": "^2|^3|^4|^5", + "symfony/event-dispatcher": "^2|^3|^4|^5|^6", "guzzlehttp/guzzle": "^6.3.3|^7.0" }, "suggest": { diff --git a/src/Platform/Platform.php b/src/Platform/Platform.php index 3182979d..b2dd67aa 100644 --- a/src/Platform/Platform.php +++ b/src/Platform/Platform.php @@ -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' ]); @@ -208,7 +207,7 @@ public function login($options) ] + (!empty($options['codeVerifier']) ? [ 'code_verifier' => $options['codeVerifier'] ] : []) - ) : !empty($options['jwt']) ? $this->requestToken(self::TOKEN_ENDPOINT, [ + ) : (!empty($options['jwt']) ? $this->requestToken(self::TOKEN_ENDPOINT, [ 'grant_type' => 'urn:ietf:params:oauth:grant-type:jwt-bearer', 'assertion' => $options['jwt'], @@ -224,7 +223,7 @@ public function login($options) 'access_token_ttl' => self::ACCESS_TOKEN_TTL, 'refresh_token_ttl' => self::REFRESH_TOKEN_TTL - ]); + ])); $this->_auth->setData($response->jsonArray()); From a7a964e97b680fb6a20ba53bbe1c3b0f5c919471 Mon Sep 17 00:00:00 2001 From: "byrne.reese" Date: Sat, 28 May 2022 16:26:49 -0700 Subject: [PATCH 2/7] Added unit test for authUrl --- src/Platform/PlatformTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Platform/PlatformTest.php b/src/Platform/PlatformTest.php index 5a464c8f..ae93325e 100644 --- a/src/Platform/PlatformTest.php +++ b/src/Platform/PlatformTest.php @@ -70,6 +70,17 @@ public function testLogout() } + public function testAuthUrl() + { + $sdk = $this->getSDK(); + $url = $sdk->authUrl(array( + 'redirectUri' => 'foo', + 'state' => 'bar', + 'client_id' => 'baz' + )); + $this->assertEquals( $url, "https://platform.ringcentral.com/restapi/oauth/authorize?redirect_uri=foo&client_id=baz&state=bar" ); + } + public function testApiUrl() { From 493f6f9663d1c8a66579dfe5ed9d5ad108388b1e Mon Sep 17 00:00:00 2001 From: "byrne.reese" Date: Sat, 28 May 2022 16:33:07 -0700 Subject: [PATCH 3/7] fixing unit test --- src/Platform/PlatformTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Platform/PlatformTest.php b/src/Platform/PlatformTest.php index ae93325e..48080aec 100644 --- a/src/Platform/PlatformTest.php +++ b/src/Platform/PlatformTest.php @@ -73,7 +73,7 @@ public function testLogout() public function testAuthUrl() { $sdk = $this->getSDK(); - $url = $sdk->authUrl(array( + $url = $sdk->platform()->authUrl(array( 'redirectUri' => 'foo', 'state' => 'bar', 'client_id' => 'baz' From 3813299fc8a9f4b28b2e09a90efcb5ece0181eea Mon Sep 17 00:00:00 2001 From: "byrne.reese" Date: Sat, 28 May 2022 16:36:44 -0700 Subject: [PATCH 4/7] Fixed unit test --- src/Platform/PlatformTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Platform/PlatformTest.php b/src/Platform/PlatformTest.php index 48080aec..fbd40f85 100644 --- a/src/Platform/PlatformTest.php +++ b/src/Platform/PlatformTest.php @@ -78,7 +78,7 @@ public function testAuthUrl() 'state' => 'bar', 'client_id' => 'baz' )); - $this->assertEquals( $url, "https://platform.ringcentral.com/restapi/oauth/authorize?redirect_uri=foo&client_id=baz&state=bar" ); + $this->assertEquals( $url, "https://whatever/restapi/oauth/authorize?response_type=code&redirect_uri=foo&client_id=whatever&state=bar" ); } public function testApiUrl() From 701762edfdbb931e5c1941db8e5deb54ec04e39e Mon Sep 17 00:00:00 2001 From: "byrne.reese" Date: Sat, 28 May 2022 16:43:19 -0700 Subject: [PATCH 5/7] trying to increase coverage of subscription --- src/Subscription/SubscriptionTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Subscription/SubscriptionTest.php b/src/Subscription/SubscriptionTest.php index 50445d87..7670ddbb 100644 --- a/src/Subscription/SubscriptionTest.php +++ b/src/Subscription/SubscriptionTest.php @@ -288,4 +288,12 @@ public function testKeepPolling() } + public function testGetPubnub() + { + $sdk = $this->getSDK(); + $s = $this->createSubscription($sdk); + $pn = $s->pubnub(); + $this->assertNotNull($pn); + } + } \ No newline at end of file From 6cdd8acc2ff1eba4364c8f1593ba110fb360a349 Mon Sep 17 00:00:00 2001 From: "byrne.reese" Date: Sat, 28 May 2022 16:52:01 -0700 Subject: [PATCH 6/7] Fixing pubnub unit test --- src/Subscription/SubscriptionTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Subscription/SubscriptionTest.php b/src/Subscription/SubscriptionTest.php index 7670ddbb..e1ac24e7 100644 --- a/src/Subscription/SubscriptionTest.php +++ b/src/Subscription/SubscriptionTest.php @@ -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 { @@ -292,6 +294,8 @@ public function testGetPubnub() { $sdk = $this->getSDK(); $s = $this->createSubscription($sdk); + $pnconf = new PNConfiguration(); + $s->_pubnub = new PubNub($pnconf); $pn = $s->pubnub(); $this->assertNotNull($pn); } From 40a2e662fbf42b11309a6fbcf9bf1fcc1016259c Mon Sep 17 00:00:00 2001 From: "byrne.reese" Date: Sat, 28 May 2022 16:59:17 -0700 Subject: [PATCH 7/7] changing pubnub test case --- src/Subscription/SubscriptionTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Subscription/SubscriptionTest.php b/src/Subscription/SubscriptionTest.php index e1ac24e7..4ad56ca9 100644 --- a/src/Subscription/SubscriptionTest.php +++ b/src/Subscription/SubscriptionTest.php @@ -290,14 +290,14 @@ public function testKeepPolling() } - public function testGetPubnub() + public function testGetNullPubnub() { $sdk = $this->getSDK(); $s = $this->createSubscription($sdk); - $pnconf = new PNConfiguration(); - $s->_pubnub = new PubNub($pnconf); + //$pnconf = new PNConfiguration(); + //$s->_pubnub = new PubNub($pnconf); $pn = $s->pubnub(); - $this->assertNotNull($pn); + $this->assertNull($pn); } } \ No newline at end of file