Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: Add integration tests for adding and removing permissions
Signed-off-by: Daniel Calviño Sánchez <[email protected]>
  • Loading branch information
danxuliu authored and backportbot[bot] committed Aug 22, 2024
commit c6f743d7ad9f08baba5147effa45e0a50cd4c24c
50 changes: 50 additions & 0 deletions tests/integration/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,21 @@ private function assertRooms($rooms, TableNode $formData, bool $shouldOrder = fa
if (isset($expectedRoom['recordingConsent'])) {
$data['recordingConsent'] = (int) $room['recordingConsent'];
}
if (isset($expectedRoom['permissions'])) {
$data['permissions'] = $this->mapPermissionsAPIOutput($room['permissions']);
}
if (isset($expectedRoom['permissions'])) {
$data['permissions'] = $this->mapPermissionsAPIOutput($room['permissions']);
}
if (isset($expectedRoom['attendeePermissions'])) {
$data['attendeePermissions'] = $this->mapPermissionsAPIOutput($room['attendeePermissions']);
}
if (isset($expectedRoom['callPermissions'])) {
$data['callPermissions'] = $this->mapPermissionsAPIOutput($room['callPermissions']);
}
if (isset($expectedRoom['defaultPermissions'])) {
$data['defaultPermissions'] = $this->mapPermissionsAPIOutput($room['defaultPermissions']);
}
if (isset($expectedRoom['participants'])) {
throw new \Exception('participants key needs to be checked via participants endpoint');
}
Expand Down Expand Up @@ -1716,6 +1731,41 @@ public function userSetsPermissionsForInRoomTo(string $user, string $participant
$this->assertStatusCode($this->response, $statusCode);
}

/**
* @When /^user "([^"]*)" (sets|removes|adds) permissions for all attendees in room "([^"]*)" to "([^"]*)" with (\d+) \((v4)\)$/
*
* @param string $user
* @param string $mode
* @param string $identifier
* @param string $permissionsString
* @param int $statusCode
* @param string $apiVersion
*/
public function userSetsRemovesAddsPermissionsForAllAttendeesInRoomTo(string $user, string $method, string $identifier, string $permissionsString, int $statusCode, string $apiVersion): void {
$permissions = $this->mapPermissionsTestInput($permissionsString);

// Convert method from step syntax to what the API expects
if ($method === 'sets') {
$method = 'set';
} elseif ($method === 'removes') {
$method = 'remove';
} else {
$method = 'add';
}

$requestParameters = [
['method', $method],
['permissions', $permissions],
];

$this->setCurrentUser($user);
$this->sendRequest(
'PUT', '/apps/spreed/api/' . $apiVersion . '/room/' . self::$identifierToToken[$identifier] . '/attendees/permissions/all',
new TableNode($requestParameters)
);
$this->assertStatusCode($this->response, $statusCode);
}

/**
* @When /^user "([^"]*)" sets (call|default) permissions for room "([^"]*)" to "([^"]*)" with (\d+) \((v4)\)$/
*
Expand Down
36 changes: 36 additions & 0 deletions tests/integration/features/conversation-5/set-permissions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,39 @@ Feature: conversation-2/set-publishing-permissions
| actorType | actorId | permissions | attendeePermissions | participantType |
| users | owner | SJLAVPM | D | 1 |
| users | invited user | CLAVPM | CLAVPM | 3 |

Scenario: adding and removing permissions to all attendees do not change default attendee permissions
Given user "invited user2" exists
And user "owner" creates room "group room" (v4)
| roomType | 2 |
| roomName | room |
And user "owner" adds user "invited user" to room "group room" with 200 (v4)
And user "owner" adds user "invited user2" to room "group room" with 200 (v4)
And user "owner" sets call permissions for room "group room" to "LPM" with 200 (v4)
And user "owner" sets permissions for "invited user2" in room "group room" to "LVP" with 200 (v4)
When user "owner" adds permissions for all attendees in room "group room" to "JA" with 200 (v4)
And user "owner" removes permissions for all attendees in room "group room" to "SLP" with 200 (v4)
Then user "owner" sees the following attendees in room "group room" with 200 (v4)
| actorType | actorId | permissions | attendeePermissions |
| users | owner | SJLAVPM | D |
| users | invited user | CJAM | D |
| users | invited user2 | CJAV | CJAV |
And user "owner" is participant of room "group room" (v4)
| callPermissions | defaultPermissions |
| CJAM | D |

Scenario: adding and removing permissions to all attendees customize room permissions if call permissions are not set
Given user "owner" creates room "group room" (v4)
| roomType | 2 |
| roomName | room |
And user "owner" adds user "invited user" to room "group room" with 200 (v4)
And user "owner" sets default permissions for room "group room" to "LPM" with 200 (v4)
When user "owner" adds permissions for all attendees in room "group room" to "JA" with 200 (v4)
And user "owner" removes permissions for all attendees in room "group room" to "SLP" with 200 (v4)
Then user "owner" sees the following attendees in room "group room" with 200 (v4)
| actorType | actorId | permissions | attendeePermissions |
| users | owner | SJLAVPM | D |
| users | invited user | CJAM | D |
And user "owner" is participant of room "group room" (v4)
| callPermissions | defaultPermissions |
| CJAM | CLPM |