From 4d4a8c8d8e73163f013d7a3392679ca1f5f24ebb Mon Sep 17 00:00:00 2001 From: Kendall Swarthout Date: Tue, 15 Oct 2024 16:52:16 -0700 Subject: [PATCH] Update `getProfile` --- lib/SSO.php | 6 ++++-- tests/WorkOS/SSOTest.php | 29 ----------------------------- 2 files changed, 4 insertions(+), 31 deletions(-) diff --git a/lib/SSO.php b/lib/SSO.php index 3c5c6e8a..e3153a7f 100644 --- a/lib/SSO.php +++ b/lib/SSO.php @@ -146,9 +146,11 @@ public function getProfile($accessToken) null ); - $response = new Resource\Response($result, $responseHeaders, $responseCode); + $decodedResponse = json_decode($result, true); - return $response->json(); + $profile = Resource\Profile::constructFromResponse($decodedResponse); + + return $profile->json(); } /** diff --git a/tests/WorkOS/SSOTest.php b/tests/WorkOS/SSOTest.php index bb0dcbd3..9f710648 100644 --- a/tests/WorkOS/SSOTest.php +++ b/tests/WorkOS/SSOTest.php @@ -113,35 +113,6 @@ public function testGetProfileAndTokenReturnsProfileWithExpectedValues() $this->assertEquals($profileFixture, $profileAndToken->profile->toArray()); } - public function testGetProfileReturnsProfileWithExpectedValues() - { - $code = 'code'; - $path = "sso/token"; - $params = [ - "client_id" => WorkOS::getClientId(), - "client_secret" => WorkOS::getApikey(), - "code" => $code, - "grant_type" => "authorization_code" - ]; - - $result = $this->profileAndTokenResponseFixture(); - - $this->mockRequest( - Client::METHOD_POST, - $path, - null, - $params, - false, - $result - ); - - $profileAndToken = $this->sso->getProfileAndToken('code'); - $profile = $this->sso->getProfile($profileAndToken->accessToken); - $profileFixture = $this->profileFixture(); - - $this->assertSame("01DMEK0J53CVMC32CK5SE0KZ8Q", $profileAndToken->accessToken); - $this->assertEquals($profileFixture, $profile->toArray()); - } public function testGetConnection() {