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
path: root/tests
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2020-12-07 20:10:39 +0300
committerVincent Petry <vincent@nextcloud.com>2020-12-11 20:15:51 +0300
commit6d75ad2b62a9f99b845596544c022b45e199a3fe (patch)
tree0ca0841cbf3b849442b9b19d0f472ac11e42ab6a /tests
parent52b88a9c16b66131e8e87721bcceacd7395a99d5 (diff)
Added integration tests for joining listable rooms
Added guest app to CI for callapi tests. Added test scenarios for joining listable rooms. Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/features/bootstrap/FeatureContext.php36
-rw-r--r--tests/integration/features/callapi/joining-listable-rooms.feature97
2 files changed, 126 insertions, 7 deletions
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php
index 03c6cc171..bf1e22965 100644
--- a/tests/integration/features/bootstrap/FeatureContext.php
+++ b/tests/integration/features/bootstrap/FeatureContext.php
@@ -30,7 +30,6 @@ use GuzzleHttp\Cookie\CookieJar;
use GuzzleHttp\Exception\ClientException;
use PHPUnit\Framework\Assert;
use Psr\Http\Message\ResponseInterface;
-use OCA\Talk\Room;
/**
* Defines application features from the specific context.
@@ -316,13 +315,16 @@ 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['participantType'])) {
+ $attendee['participantType'] = (string)$this->mapParticipantTypeTestInput($attendee['participantType']);
+ }
return $attendee;
}, $formData->getHash());
usort($expected, [$this, 'sortAttendees']);
usort($result, [$this, 'sortAttendees']);
- Assert::assertEquals($result, $expected);
+ Assert::assertEquals($expected, $result);
} else {
Assert::assertNull($formData);
}
@@ -338,6 +340,23 @@ class FeatureContext implements Context, SnippetAcceptingContext {
return $a1['actorId'] <=> $a2['actorId'];
}
+ private function mapParticipantTypeTestInput($participantType) {
+ if (is_int($participantType)) {
+ return $participantType;
+ }
+
+ switch ($participantType) {
+ case 'OWNER': return 1;
+ case 'MODERATOR': return 2;
+ case 'USER': return 3;
+ case 'GUEST': return 4;
+ case 'USER_SELF_JOINED': return 5;
+ case 'GUEST_MODERATOR': return 6;
+ }
+
+ Assert::fail('Invalid test input value for participant type');
+ }
+
/**
* @param string $guest
* @param string $isOrNotParticipant
@@ -809,16 +828,18 @@ class FeatureContext implements Context, SnippetAcceptingContext {
public function userChangesListableScopeOfTheRoom($user, $identifier, $newState, $statusCode, $apiVersion = 'v3') {
$this->setCurrentUser($user);
if ($newState === 'none') {
- $newStateValue = Room::LISTABLE_NONE;
+ $newStateValue = 0; // Room::LISTABLE_NONE
} elseif ($newState === 'users') {
- $newStateValue = Room::LISTABLE_USERS;
+ $newStateValue = 1; // Room::LISTABLE_USERS
+ } elseif ($newState === 'all') {
+ $newStateValue = 2; // Room::LISTABLE_ALL
} else {
- $newStateValue = Room::LISTABLE_ALL;
+ Assert::fail('Invalid listable scope value');
}
$this->sendRequest(
'PUT', '/apps/spreed/api/' . $apiVersion . '/room/' . self::$identifierToToken[$identifier] . '/listable',
- new TableNode([['state', $newStateValue]])
+ new TableNode([['scope', $newStateValue]])
);
$this->assertStatusCode($this->response, $statusCode);
}
@@ -1511,9 +1532,10 @@ class FeatureContext implements Context, SnippetAcceptingContext {
public function addingUserToGroup($user, $group) {
$currentUser = $this->currentUser;
$this->setCurrentUser('admin');
- $this->response = $this->sendRequest('POST', "/cloud/users/$user/groups", [
+ $this->sendRequest('POST', "/cloud/users/$user/groups", [
'groupid' => $group,
]);
+ $this->assertStatusCode($this->response, 200);
$this->setCurrentUser($currentUser);
}
diff --git a/tests/integration/features/callapi/joining-listable-rooms.feature b/tests/integration/features/callapi/joining-listable-rooms.feature
new file mode 100644
index 000000000..de890b929
--- /dev/null
+++ b/tests/integration/features/callapi/joining-listable-rooms.feature
@@ -0,0 +1,97 @@
+Feature: callapi/listable-rooms
+ Background:
+ Given user "creator" exists
+ And user "regular-user" exists
+ And user "user-guest" exists
+ And user "user-guest" is member of group "guest_app"
+ # implicit: And user "guest" is a guest user with no account
+
+ # -----------------------------------------------------------------------------
+ # Non-listed rooms
+ # -----------------------------------------------------------------------------
+ Scenario: Nobody can join a non-listed group room
+ Given user "creator" creates room "room"
+ | roomType | 2 |
+ | roomName | room |
+ When user "creator" allows listing room "room" for "none" with 200
+ Then user "regular-user" joins room "room" with 404
+ And user "user-guest" joins room "room" with 404
+ And user "guest" joins room "room" with 404
+
+ Scenario: Anyone can join a non-listed public room
+ Given user "creator" creates room "room"
+ | roomType | 3 |
+ | roomName | room |
+ And user "creator" allows listing room "room" for "none" with 200
+ When user "regular-user" joins room "room" with 200
+ And user "user-guest" joins room "room" with 200
+ And user "guest" joins room "room" with 200
+ Then user "creator" sees the following attendees in room "room" with 200 (v3)
+ | actorId | participantType | actorType |
+ | creator | OWNER | users |
+ | regular-user | USER_SELF_JOINED | users |
+ | user-guest | USER_SELF_JOINED | users |
+ | "guest" | GUEST | guests |
+
+ # -----------------------------------------------------------------------------
+ # User-listed rooms
+ # -----------------------------------------------------------------------------
+ Scenario: Only regular users can join a user-listed group room
+ Given user "creator" creates room "room"
+ | roomType | 2 |
+ | roomName | room |
+ And user "creator" allows listing room "room" for "users" with 200
+ When user "regular-user" joins room "room" with 200
+ And user "user-guest" joins room "room" with 404
+ And user "guest" joins room "room" with 404
+ Then user "creator" sees the following attendees in room "room" with 200 (v3)
+ | actorId | participantType | actorType |
+ | creator | OWNER | users |
+ | regular-user | USER | users |
+
+ Scenario: Anyone can join a user-listed public room
+ Given user "creator" creates room "room"
+ | roomType | 3 |
+ | roomName | room |
+ And user "creator" allows listing room "room" for "users" with 200
+ When user "regular-user" joins room "room" with 200
+ And user "user-guest" joins room "room" with 200
+ And user "guest" joins room "room" with 200
+ Then user "creator" sees the following attendees in room "room" with 200 (v3)
+ | actorId | participantType | actorType |
+ | creator | OWNER | users |
+ | regular-user | USER | users |
+ | user-guest | USER_SELF_JOINED | users |
+ | "guest" | GUEST | guests |
+
+ # -----------------------------------------------------------------------------
+ # All-listed rooms
+ # -----------------------------------------------------------------------------
+ Scenario: Only users with accounts can join an all-listed group room
+ Given user "creator" creates room "room"
+ | roomType | 2 |
+ | roomName | room |
+ And user "creator" allows listing room "room" for "all" with 200
+ When user "regular-user" joins room "room" with 200
+ And user "user-guest" joins room "room" with 200
+ And user "guest" joins room "room" with 404
+ Then user "creator" sees the following attendees in room "room" with 200 (v3)
+ | actorId | participantType | actorType |
+ | creator | OWNER | users |
+ | regular-user | USER | users |
+ | user-guest | USER_SELF_JOINED | users |
+
+ Scenario: Anyone can join an all-listed public room
+ Given user "creator" creates room "room"
+ | roomType | 3 |
+ | roomName | room |
+ And user "creator" allows listing room "room" for "all" with 200
+ When user "regular-user" joins room "room" with 200
+ And user "user-guest" joins room "room" with 200
+ And user "guest" joins room "room" with 200
+ Then user "creator" sees the following attendees in room "room" with 200 (v3)
+ | actorId | participantType | actorType |
+ | creator | OWNER | users |
+ | regular-user | USER | users |
+ | user-guest | USER | users |
+ | "guest" | GUEST | guests |