Skip to content

Commit 0772e07

Browse files
author
Sander Verkuil
committed
Work with the proper response structure
1 parent 1a16b28 commit 0772e07

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

lib/SSO.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,7 @@ public function getProfile()
135135
true
136136
);
137137

138-
if (!array_key_exists('profile', $response)) {
139-
throw new Exception\GenericException('The profile was not found in the response.');
140-
}
141-
142-
return Resource\Profile::constructFromResponse($response['profile']);
138+
return Resource\Profile::constructFromResponse($response);
143139
}
144140

145141
/**

tests/WorkOS/SSOTest.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function testGetProfileReturnsProfileWithExpectedValues()
119119
{
120120
$path = "sso/profile";
121121

122-
$result = $this->profileAndTokenResponseFixture();
122+
$result = $this->profileResponseFixture();
123123

124124
$this->mockRequest(
125125
Client::METHOD_GET,
@@ -280,6 +280,31 @@ private function profileFixture()
280280
];
281281
}
282282

283+
private function profileResponseFixture()
284+
{
285+
return json_encode([
286+
"id" => "prof_hen",
287+
"email" => "hen@papagenos.com",
288+
"first_name" => "hen",
289+
"last_name" => "cha",
290+
"organization_id" => "org_01FG7HGMY2CZZR2FWHTEE94VF0",
291+
"connection_id" => "conn_01EMH8WAK20T42N2NBMNBCYHAG",
292+
"connection_type" => "GoogleOAuth",
293+
"idp_id" => "randomalphanum",
294+
"role" => new RoleResponse("admin"),
295+
"groups" => array("Admins", "Developers"),
296+
"custom_attributes" => array("license" => "professional"),
297+
"raw_attributes" => array(
298+
"email" => "hen@papagenos.com",
299+
"first_name" => "hen",
300+
"last_name" => "cha",
301+
"ipd_id" => "randomalphanum",
302+
"groups" => array("Admins", "Developers"),
303+
"license" => "professional"
304+
),
305+
]);
306+
}
307+
283308
private function connectionFixture()
284309
{
285310
return [

0 commit comments

Comments
 (0)