Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable29] fix(federation): ICloudId->getRemote() should contain the protocol #44626

Merged
merged 1 commit into from
Apr 2, 2024
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', 'test@example.com'],
['test', 'http://example.com', 'test@http://example.com', 'test@example.com'],
['test', null, 'test@http://example.com', 'test@example.com', 'http://example.com'],
['test', null, 'test@http://example.com', 'test@example.com', 'http://example.com', 'http://example.com'],
['test@example.com', 'example.com', 'test@example.com@example.com'],
['test@example.com', 'https://example.com', 'test@example.com@example.com'],
['test@example.com', null, 'test@example.com@example.com'],
['test@example.com', 'https://example.com/index.php/s/shareToken', 'test@example.com@example.com'],
['test@example.com', null, 'test@example.com@example.com', null, 'https://example.com', 'https://example.com'],
['test@example.com', 'https://example.com/index.php/s/shareToken', 'test@example.com@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');
}
}
Loading