-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44453 from nextcloud/bugfix/noid/fix-cloud-id-gen…
…eration-with-http fix(federation): Fix creating local cloudIds with http:// protocol
- Loading branch information
Showing
3 changed files
with
32 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -124,36 +124,40 @@ public function testInvalidCloudId($cloudId) { | |
$this->cloudIdManager->resolveCloudId($cloudId); | ||
} | ||
|
||
public function getCloudIdProvider() { | ||
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'], | ||
['[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'], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider getCloudIdProvider | ||
* | ||
* @param string $user | ||
* @param string $remote | ||
* @param null|string $remote | ||
* @param string $id | ||
*/ | ||
public function testGetCloudId($user, $remote, $id) { | ||
public function testGetCloudId(string $user, ?string $remote, string $id, ?string $searchCloudId = null, ?string $localHost = 'https://example.com'): void { | ||
if ($remote !== null) { | ||
$this->contactsManager->expects($this->any()) | ||
->method('search') | ||
->with($id, ['CLOUD']) | ||
->with($searchCloudId ?? $id, ['CLOUD']) | ||
->willReturn([ | ||
[ | ||
'CLOUD' => [$id], | ||
'CLOUD' => [$searchCloudId ?? $id], | ||
'FN' => 'Ample Ex', | ||
] | ||
]); | ||
} else { | ||
$this->urlGenerator->expects(self::once()) | ||
->method('getAbsoluteUrl') | ||
->willReturn('https://example.com'); | ||
->willReturn($localHost); | ||
} | ||
|
||
$cloudId = $this->cloudIdManager->getCloudId($user, $remote); | ||
|