Skip to content

Commit

Permalink
update getPersonalSpaceIdForUser to use new oc:id format
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed Feb 15, 2022
1 parent 1cbc3a0 commit b8e7eb9
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions tests/TestHelpers/WebDavHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,19 +433,16 @@ public static function getPersonalSpaceIdForUser(string $baseUrl, string $user,
__METHOD__ . " oc:id not found in webdav propfind for user $user - so the personal space id cannot be discovered"
);
}
// oc:id should be some base64 encoded string like:
// "NzQ2NGNhZjYtMTc5OS0xMDNjLTkwNDYtYzdiNzRkZWI1ZjYzOjc0NjRjYWY2LTE3OTktMTAzYy05MDQ2LWM3Yjc0ZGViNWY2Mw=="
$idBase64 = $xmlPart[0]->__toString();
// That should decode to something like:
// "7464caf6-1799-103c-9046-c7b74deb5f63:7464caf6-1799-103c-9046-c7b74deb5f63"
$decodedId = base64_decode($idBase64);
$decodedIdParts = \explode(":", $decodedId);
if (\count($decodedIdParts) !== 2) {
// oc:id should be something like:
// "7464caf6-1799-103c-9046-c7b74deb5f63!7464caf6-1799-103c-9046-c7b74deb5f63"
$ocId = $xmlPart[0]->__toString();
$ocIdParts = \explode("!", $ocId);
if (\count($ocIdParts) !== 2) {
throw new Exception(
__METHOD__ . " the decoded oc:id $decodedId for user $user does not have 2 parts separated by a colon, so the personal space id cannot be discovered"
__METHOD__ . " the oc:id $ocId for user $user does not have 2 parts separated by an exclamation mark, so the personal space id cannot be discovered"
);
}
$personalSpaceId = $decodedIdParts[0];
$personalSpaceId = $ocIdParts[0];
} else {
foreach ($json->value as $spaces) {
if ($spaces->driveType === "personal") {
Expand Down

0 comments on commit b8e7eb9

Please sign in to comment.