aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2024-06-26 10:40:31 +0200
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2024-06-27 13:00:43 +0000
commit17434538d44bf348e7f8eff79e0fc200ee5c0098 (patch)
tree7148d2ecb614dd06af1ed609d62d439d2fce2827 /tests
parent01c0e743c7feb39b799189282f21ba44142e3c8e (diff)
downloadnextcloud-server-17434538d44bf348e7f8eff79e0fc200ee5c0098.tar.gz
nextcloud-server-17434538d44bf348e7f8eff79e0fc200ee5c0098.zip
fix(federation): Fix missing protocol on CloudID remote
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Collaboration/Collaborators/RemotePluginTest.php5
-rw-r--r--tests/lib/Federation/CloudIdManagerTest.php24
2 files changed, 13 insertions, 16 deletions
diff --git a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php
index 4fed1f179e7..bc5e8982f2a 100644
--- a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php
@@ -412,6 +412,11 @@ class RemotePluginTest extends TestCase {
foreach ($protocols as $protocol) {
$baseUrl = $user . '@' . $protocol . $remote;
+ if ($protocol === 'https://') {
+ // https:// protocol is not expected in the final result
+ $protocol = '';
+ }
+
$testCases[] = [$baseUrl, $user, $protocol . $remote];
$testCases[] = [$baseUrl . '/', $user, $protocol . $remote];
$testCases[] = [$baseUrl . '/index.php', $user, $protocol . $remote];
diff --git a/tests/lib/Federation/CloudIdManagerTest.php b/tests/lib/Federation/CloudIdManagerTest.php
index a144dbb7800..1b9b5bfb971 100644
--- a/tests/lib/Federation/CloudIdManagerTest.php
+++ b/tests/lib/Federation/CloudIdManagerTest.php
@@ -63,7 +63,7 @@ class CloudIdManagerTest extends TestCase {
);
}
- public function cloudIdProvider() {
+ public function cloudIdProvider(): array {
return [
['test@example.com', 'test', 'example.com', 'test@example.com'],
['test@example.com/cloud', 'test', 'example.com/cloud', 'test@example.com/cloud'],
@@ -75,12 +75,8 @@ class CloudIdManagerTest extends TestCase {
/**
* @dataProvider cloudIdProvider
- *
- * @param string $cloudId
- * @param string $user
- * @param string $remote
*/
- public function testResolveCloudId($cloudId, $user, $remote, $cleanId) {
+ public function testResolveCloudId(string $cloudId, string $user, string $noProtocolRemote, string $cleanId): void {
$displayName = 'Ample Ex';
$this->contactsManager->expects($this->any())
@@ -96,12 +92,12 @@ class CloudIdManagerTest extends TestCase {
$cloudId = $this->cloudIdManager->resolveCloudId($cloudId);
$this->assertEquals($user, $cloudId->getUser());
- $this->assertEquals($remote, $cloudId->getRemote());
+ $this->assertEquals('https://' . $noProtocolRemote, $cloudId->getRemote());
$this->assertEquals($cleanId, $cloudId->getId());
- $this->assertEquals($displayName . '@' . $remote, $cloudId->getDisplayId());
+ $this->assertEquals($displayName . '@' . $noProtocolRemote, $cloudId->getDisplayId());
}
- public function invalidCloudIdProvider() {
+ public function invalidCloudIdProvider(): array {
return [
['example.com'],
['test:foo@example.com'],
@@ -115,7 +111,7 @@ class CloudIdManagerTest extends TestCase {
* @param string $cloudId
*
*/
- public function testInvalidCloudId($cloudId) {
+ public function testInvalidCloudId(string $cloudId): void {
$this->expectException(\InvalidArgumentException::class);
$this->contactsManager->expects($this->never())
@@ -126,10 +122,10 @@ class CloudIdManagerTest extends TestCase {
public function getCloudIdProvider(): array {
return [
- ['test', 'example.com', 'test@example.com'],
+ ['test', 'example.com', 'test@example.com', null, 'https://example.com', 'https://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', 'http://example.com'],
- ['test@example.com', 'example.com', 'test@example.com@example.com'],
+ ['test@example.com', 'example.com', 'test@example.com@example.com', null, 'https://example.com', 'https://example.com'],
['test@example.com', 'https://example.com', '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'],
@@ -138,10 +134,6 @@ class CloudIdManagerTest extends TestCase {
/**
* @dataProvider getCloudIdProvider
- *
- * @param string $user
- * @param null|string $remote
- * @param string $id
*/
public function testGetCloudId(string $user, ?string $remote, string $id, ?string $searchCloudId = null, ?string $localHost = 'https://example.com', ?string $expectedRemoteId = null): void {
if ($remote !== null) {