Browse Source

Add integration tests for limiting conversation creation

Signed-off-by: Joas Schilling <coding@schilljs.com>
pull/3095/head
Joas Schilling 6 years ago
parent
commit
d93a8a49e6
No known key found for this signature in database GPG Key ID: 7076EA9751AACDDA
  1. 24
      tests/integration/features/bootstrap/FeatureContext.php
  2. 35
      tests/integration/features/conversation/limit-creation.feature

24
tests/integration/features/bootstrap/FeatureContext.php

@ -68,6 +68,9 @@ class FeatureContext implements Context, SnippetAcceptingContext {
/** @var array */
protected $createdGroups = [];
/** @var array */
protected $changedConfigs = [];
/** @var SharingContext */
private $sharingContext;
@ -900,6 +903,23 @@ class FeatureContext implements Context, SnippetAcceptingContext {
$this->assertStatusCode($this->response, $statusCode);
}
/**
* @Given /^the following app config is set$/
*
* @param TableNode $formData
*/
public function setAppConfig(TableNode $formData): void {
$currentUser = $this->currentUser;
$this->setCurrentUser('admin');
foreach ($formData->getRows() as $row) {
$this->sendRequest('POST', '/apps/provisioning_api/api/v1/config/apps/spreed/' . $row[0], [
'value' => $row[1],
]);
$this->changedConfigs[] = $row[0];
}
$this->setCurrentUser($currentUser);
}
/**
* @BeforeScenario
* @AfterScenario
@ -908,6 +928,10 @@ class FeatureContext implements Context, SnippetAcceptingContext {
$currentUser = $this->currentUser;
$this->setCurrentUser('admin');
$this->sendRequest('DELETE', '/apps/spreedcheats/');
foreach ($this->changedConfigs as $config) {
$this->sendRequest('DELETE', '/apps/provisioning_api/api/v1/config/apps/spreed/' . $config);
}
$this->setCurrentUser($currentUser);
}

35
tests/integration/features/conversation/limit-creation.feature

@ -0,0 +1,35 @@
Feature: public
Background:
Given user "participant1" exists
Given user "participant2" exists
Given user "participant3" exists
Given group "group1" exists
Scenario: User can not create group conversations
Given the following app config is set
| start_conversations | ["group1"] |
Then user "participant1" creates room "room" with 403
| roomType | 2 |
| roomName | room |
Given user "participant1" is member of group "group1"
Then user "participant1" creates room "room" with 201
| roomType | 2 |
| roomName | room |
Scenario: User can not create public conversations
Given the following app config is set
| start_conversations | ["group1"] |
Then user "participant1" creates room "room" with 403
| roomType | 3 |
| roomName | room |
Given user "participant1" is member of group "group1"
Then user "participant1" creates room "room" with 201
| roomType | 3 |
| roomName | room |
Scenario: User can still do one-to-one conversations
Given the following app config is set
| start_conversations | ["group1"] |
Then user "participant1" creates room "room" with 201
| roomType | 1 |
| invite | participant2 |
Loading…
Cancel
Save