Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2022-07-04 20:05:01 +0300
committerJoas Schilling <coding@schilljs.com>2022-07-04 20:05:01 +0300
commit21c29e60ead0fe27e386e4e5752b4a38793fd394 (patch)
tree33b00b3a055e1926f8dd6950aaa0d6d079f417a6
parent761d5ba01e57f1b9a0788f4ae8bfa8c60c9217f7 (diff)
Add a test for remote authentication
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--tests/integration/features/bootstrap/FeatureContext.php31
-rw-r--r--tests/integration/features/federation/invite.feature17
2 files changed, 48 insertions, 0 deletions
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php
index 9392c1685..d9726be24 100644
--- a/tests/integration/features/bootstrap/FeatureContext.php
+++ b/tests/integration/features/bootstrap/FeatureContext.php
@@ -56,6 +56,8 @@ class FeatureContext implements Context, SnippetAcceptingContext {
protected static $remoteToInviteId;
/** @var string[] */
protected static $inviteIdToRemote;
+ /** @var string[] */
+ protected static $remoteAuth;
/** @var int[] */
protected static $questionToPollId;
@@ -286,6 +288,10 @@ class FeatureContext implements Context, SnippetAcceptingContext {
private function assertRooms($rooms, TableNode $formData) {
Assert::assertCount(count($formData->getHash()), $rooms, 'Room count does not match');
Assert::assertEquals($formData->getHash(), array_map(function ($room, $expectedRoom) {
+ if (isset($room['remoteAccessToken'])) {
+ self::$remoteAuth[self::translateRemoteServer($room['remoteServer']) . '#' . self::$identifierToToken[$room['name']]] = $room['remoteAccessToken'];
+ }
+
if (!isset(self::$identifierToToken[$room['name']])) {
self::$identifierToToken[$room['name']] = $room['token'];
}
@@ -566,6 +572,27 @@ class FeatureContext implements Context, SnippetAcceptingContext {
}
/**
+ * @Then /^user "([^"]*)" fetches remote room "([^"]*)" with (\d+) \((v4)\)$/
+ */
+ public function userFetchesRemoteRoom(string $user, string $identifier, string $status, string $apiVersion): void {
+ if (!isset(self::$remoteAuth['LOCAL#' . self::$identifierToToken[$identifier]])) {
+ throw new \Exception(
+ 'No remote auth available for: ' . 'LOCAL#' . self::$identifierToToken[$identifier]
+ . '. Did you pull rooms for the recipient?'
+ );
+ }
+ $accessToken = self::$remoteAuth['LOCAL#' . self::$identifierToToken[$identifier]];
+
+ $this->currentUser = 'federation#' . urlencode($user . '@' . 'http://localhost:8081') . '#' . $accessToken;
+ $this->sendRequest('GET', '/apps/spreed/api/' . $apiVersion . '/room/' . self::$identifierToToken[$identifier], null, [
+ 'X-Nextcloud-Federation' => 'true',
+ ]);
+
+ $this->assertStatusCode($this->response, $status);
+ var_dump($this->getDataFromResponse($this->response));
+ }
+
+ /**
* @Then /^user "([^"]*)" loads attendees attendee ids in room "([^"]*)" \((v4)\)$/
*
* @param string $user
@@ -2686,6 +2713,10 @@ class FeatureContext implements Context, SnippetAcceptingContext {
$options = ['cookies' => $this->getUserCookieJar($this->currentUser)];
if ($this->currentUser === 'admin') {
$options['auth'] = ['admin', 'admin'];
+ } elseif (strpos($this->currentUser, 'federation') === 0) {
+ $auth = explode('#', $this->currentUser);
+ array_shift($auth);
+ $options['auth'] = $auth;
} elseif (strpos($this->currentUser, 'guest') !== 0) {
$options['auth'] = [$this->currentUser, self::TEST_PASSWORD];
}
diff --git a/tests/integration/features/federation/invite.feature b/tests/integration/features/federation/invite.feature
index 1ea48f739..42b8acb12 100644
--- a/tests/integration/features/federation/invite.feature
+++ b/tests/integration/features/federation/invite.feature
@@ -78,3 +78,20 @@ Feature: federation/invite
| room | federated_users | participant2@http://localhost:8180 | federated_user_removed | {federated_user} declined the invitation | {"actor":{"type":"user","id":"participant2","name":"participant2@localhost:8180","server":"http:\/\/localhost:8180"},"federated_user":{"type":"user","id":"participant2","name":"participant2@localhost:8180","server":"http:\/\/localhost:8180"}} |
| room | users | participant1 | federated_user_added | You invited {user} | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"},"federated_user":{"type":"user","id":"participant2","name":"participant2@localhost:8180","server":"http:\/\/localhost:8180"}} |
| room | users | participant1 | conversation_created | You created the conversation | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname"}} |
+
+ Scenario: Auth
+ Given the following "spreed" app config is set
+ | federation_enabled | yes |
+ Given user "participant1" creates room "room" (v4)
+ | roomType | 2 |
+ | roomName | room |
+ And user "participant1" adds remote "participant2" to room "room" with 200 (v4)
+ And user "participant2" has the following invitations (v1)
+ | remote_server | remote_token |
+ | LOCAL | room |
+ And user "participant2" accepts invite to room "room" of server "LOCAL" (v1)
+ And user "participant2" has the following invitations (v1)
+ Then user "participant2" is participant of the following rooms (v4)
+ | id | type |
+ | room | 2 |
+ Then user "participant2" fetches remote room "room" with 200 (v4)