diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2021-11-10 16:15:50 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-10 16:15:50 +0300 |
commit | 7f1828094fafed5f3155e6f278538a090e92aea7 (patch) | |
tree | 76c66dc1ed5d31b57fdb814b62f4d26de12b5aed /tests | |
parent | a5c5f5a5464206f0fcb198321799e58e33d17c1c (diff) | |
parent | a8fd7fc03b3659449991b9242e51c9615b69994c (diff) |
Merge pull request #6427 from nextcloud/integration-tests-for-invites
Start with integration tests for invites
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/features/bootstrap/FeatureContext.php | 14 | ||||
-rw-r--r-- | tests/integration/features/federation/invite.feature | 27 | ||||
-rw-r--r-- | tests/php/Federation/FederationTest.php | 10 |
3 files changed, 49 insertions, 2 deletions
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index 601ac55f7..37cba477b 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -426,6 +426,11 @@ class FeatureContext implements Context, SnippetAcceptingContext { if (isset($attendee['actorId']) && substr($attendee['actorId'], 0, strlen('"guest')) === '"guest') { $attendee['actorId'] = sha1(self::$userToSessionId[trim($attendee['actorId'], '"')]); } + + if (isset($attendee['actorId'], $attendee['actorType']) && $attendee['actorType'] === 'federated_users') { + $attendee['actorId'] .= '@' . rtrim($this->baseUrl, '/'); + } + if (isset($attendee['participantType'])) { $attendee['participantType'] = (string)$this->mapParticipantTypeTestInput($attendee['participantType']); } @@ -1069,7 +1074,7 @@ class FeatureContext implements Context, SnippetAcceptingContext { } /** - * @Then /^user "([^"]*)" adds (user|group|email|circle) "([^"]*)" to room "([^"]*)" with (\d+) \((v4)\)$/ + * @Then /^user "([^"]*)" adds (user|group|email|circle|remote) "([^"]*)" to room "([^"]*)" with (\d+) \((v4)\)$/ * * @param string $user * @param string $newType @@ -1080,6 +1085,11 @@ class FeatureContext implements Context, SnippetAcceptingContext { */ public function userAddAttendeeToRoom(string $user, string $newType, string $newId, string $identifier, int $statusCode, string $apiVersion): void { $this->setCurrentUser($user); + + if ($newType === 'remote') { + $newId .= '@' . $this->baseUrl; + } + $this->sendRequest( 'POST', '/apps/spreed/api/' . $apiVersion . '/room/' . self::$identifierToToken[$identifier] . '/participants', new TableNode([ @@ -2108,6 +2118,8 @@ class FeatureContext implements Context, SnippetAcceptingContext { $this->response = $client->{$verb}($fullUrl, $options); } catch (ClientException $ex) { $this->response = $ex->getResponse(); + } catch (\GuzzleHttp\Exception\ServerException $ex) { + $this->response = $ex->getResponse(); } } diff --git a/tests/integration/features/federation/invite.feature b/tests/integration/features/federation/invite.feature new file mode 100644 index 000000000..421f708cd --- /dev/null +++ b/tests/integration/features/federation/invite.feature @@ -0,0 +1,27 @@ +Feature: federation/invite + Background: + Given user "participant1" exists + Given user "participant2" exists + + Scenario: federation is disabled + Given the following app config is set + | federation_enabled | no | + Given user "participant1" creates room "room" (v4) + | roomType | 3 | + | roomName | room | + And user "participant1" adds remote "participant2" to room "room" with 501 (v4) + When user "participant1" sees the following attendees in room "room" with 200 (v4) + | actorType | actorId | participantType | + | users | participant1 | 1 | + + Scenario: federation is enabled + Given the following app config is set + | federation_enabled | yes | + Given user "participant1" creates room "room" (v4) + | roomType | 3 | + | roomName | room | + And user "participant1" adds remote "participant2" to room "room" with 200 (v4) + When user "participant1" sees the following attendees in room "room" with 200 (v4) + | actorType | actorId | participantType | + | users | participant1 | 1 | + | federated_users | participant2 | 3 | diff --git a/tests/php/Federation/FederationTest.php b/tests/php/Federation/FederationTest.php index d5376e1c1..8c107cc34 100644 --- a/tests/php/Federation/FederationTest.php +++ b/tests/php/Federation/FederationTest.php @@ -112,7 +112,7 @@ class FederationTest extends TestCase { $providerId = '3'; $roomId = 5; $token = 'abcdefghijklmno'; - $shareWith = 'test@remote.test.local'; + $shareWith = 'test@https://remote.test.local'; $name = 'abcdefgh'; $owner = 'Owner\'s name'; $ownerId = 'owner'; @@ -321,6 +321,10 @@ class FederationTest extends TestCase { ->with($remote, $notification) ->willReturn([]); + $this->addressHandler->method('urlContainProtocol') + ->with($remote) + ->willReturn(true); + $success = $this->notifications->sendShareAccepted($remote, $id, $token); $this->assertEquals(true, $success); @@ -354,6 +358,10 @@ class FederationTest extends TestCase { ->with($remote, $notification) ->willReturn([]); + $this->addressHandler->method('urlContainProtocol') + ->with($remote) + ->willReturn(true); + $success = $this->notifications->sendShareDeclined($remote, $id, $token); $this->assertEquals(true, $success); |