Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/private/Federation/CloudIdManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ public function getCloudId(string $user, ?string $remote): ICloudId {
// note that for remote id's we don't strip the protocol for the remote we use to construct the CloudId
// this way if a user has an explicit non-https cloud id this will be preserved
// we do still use the version without protocol for looking up the display name
$remote = $this->removeProtocolFromUrl($remote, true);
$remote = $this->fixRemoteURL($remote);
$host = $this->removeProtocolFromUrl($remote);

Expand All @@ -191,7 +190,9 @@ public function getCloudId(string $user, ?string $remote): ICloudId {
} else {
$displayName = $this->getDisplayNameFromContact($user . '@' . $host);
}
$id = $user . '@' . $remote;

// For the visible cloudID we only strip away https
$id = $user . '@' . $this->removeProtocolFromUrl($remote, true);

$data = [
'id' => $id,
Expand Down
12 changes: 7 additions & 5 deletions tests/lib/Federation/CloudIdManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ public function getCloudIdProvider(): array {
return [
['test', 'example.com', '[email protected]'],
['test', 'http://example.com', 'test@http://example.com', '[email protected]'],
['test', null, 'test@http://example.com', '[email protected]', 'http://example.com'],
['test', null, 'test@http://example.com', '[email protected]', 'http://example.com', 'http://example.com'],
['[email protected]', 'example.com', '[email protected]@example.com'],
['[email protected]', 'https://example.com', '[email protected]@example.com'],
['[email protected]', null, '[email protected]@example.com'],
['[email protected]', 'https://example.com/index.php/s/shareToken', '[email protected]@example.com'],
['[email protected]', null, '[email protected]@example.com', null, 'https://example.com', 'https://example.com'],
['[email protected]', 'https://example.com/index.php/s/shareToken', '[email protected]@example.com', null, 'https://example.com', 'https://example.com'],
];
}

Expand All @@ -143,7 +143,7 @@ public function getCloudIdProvider(): array {
* @param null|string $remote
* @param string $id
*/
public function testGetCloudId(string $user, ?string $remote, string $id, ?string $searchCloudId = null, ?string $localHost = 'https://example.com'): void {
public function testGetCloudId(string $user, ?string $remote, string $id, ?string $searchCloudId = null, ?string $localHost = 'https://example.com', ?string $expectedRemoteId = null): void {
if ($remote !== null) {
$this->contactsManager->expects($this->any())
->method('search')
Expand All @@ -159,9 +159,11 @@ public function testGetCloudId(string $user, ?string $remote, string $id, ?strin
->method('getAbsoluteUrl')
->willReturn($localHost);
}
$expectedRemoteId ??= $remote;

$cloudId = $this->cloudIdManager->getCloudId($user, $remote);

$this->assertEquals($id, $cloudId->getId());
$this->assertEquals($id, $cloudId->getId(), 'Cloud ID');
$this->assertEquals($expectedRemoteId, $cloudId->getRemote(), 'Remote URL');
}
}