mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-02-19 20:19:12 -06:00
[tests-only][full-ci] Add API tests for creating groups (graph API) (#4992)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# The test runner source for API tests
|
||||
CORE_COMMITID=1eed08f1229136ac5cd7ef3ae2ccd2821a113129
|
||||
CORE_COMMITID=93344602834833fa01d90975e3c955c3b90266fe
|
||||
CORE_BRANCH=master
|
||||
|
||||
# The test runner source for UI tests
|
||||
|
||||
@@ -22,6 +22,8 @@ The expected failures in this file are from features in the owncloud/ocis repo.
|
||||
- [apiGraph/createGroupCaseSensitive.feature:20](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/createGroupCaseSensitive.feature#L20)
|
||||
- [apiGraph/createGroupCaseSensitive.feature:21](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/createGroupCaseSensitive.feature#L21)
|
||||
- [apiGraph/createGroupCaseSensitive.feature:22](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/createGroupCaseSensitive.feature#L22)
|
||||
- [apiGraph/createGroup.feature:26](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/createGroup.feature#L26)
|
||||
- [apiGraph/createUser.feature:28](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/createUser.feature#L28)
|
||||
|
||||
### [PROPFIND on accepted shares with identical names containing brackets exit with 404](https://github.com/owncloud/ocis/issues/4421)
|
||||
- [apiSpacesShares/changingFilesShare.feature:12](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiSpacesShares/changingFilesShare.feature#L12)
|
||||
|
||||
37
tests/acceptance/features/apiGraph/createGroup.feature
Normal file
37
tests/acceptance/features/apiGraph/createGroup.feature
Normal file
@@ -0,0 +1,37 @@
|
||||
@api @skipOnOcV10
|
||||
Feature: create group
|
||||
Only user with admin permissions can create new groups
|
||||
|
||||
Background:
|
||||
Given user "Alice" has been created with default attributes and without skeleton files
|
||||
And the administrator has given "Alice" the role "Admin" using the settings api
|
||||
|
||||
|
||||
Scenario Outline: admin user creates a group
|
||||
When user "Alice" creates a group "<groupname>" using the Graph API
|
||||
Then the HTTP status code should be "200"
|
||||
And group "<groupname>" should exist
|
||||
Examples:
|
||||
| groupname |
|
||||
| simplegroup |
|
||||
| España§àôœ€ |
|
||||
| नेपाली |
|
||||
| $x<=>[y*z^2+1]! |
|
||||
| 😅 😆 |
|
||||
| comma,grp1 |
|
||||
| Finance (NP) |
|
||||
| slash\Middle |
|
||||
|
||||
|
||||
Scenario: admin user tries to create a group that already exists
|
||||
Given group "mygroup" has been created
|
||||
When user "Alice" tries to create a group "mygroup" using the Graph API
|
||||
And the HTTP status code should be "400"
|
||||
And group "mygroup" should exist
|
||||
|
||||
|
||||
Scenario: normal user tries to create a group
|
||||
Given user "Brian" has been created with default attributes and without skeleton files
|
||||
When user "Brian" tries to create a group "mygroup" using the Graph API
|
||||
And the HTTP status code should be "401"
|
||||
And group "mygroup" should not exist
|
||||
@@ -25,7 +25,7 @@ Feature: create user
|
||||
| name | pass with space | example@example.org | my pass | 200 | should |
|
||||
| nameWithCharacters(*:!;_+-&) | user | new@example.org | 123 | 400 | should not |
|
||||
| withoutEmail | without email | | 123 | 400 | should not |
|
||||
| Alice | same userName | new@example.org | 123 | 500 | should |
|
||||
| Alice | same userName | new@example.org | 123 | 400 | should |
|
||||
| name with space | name with space | example@example.org | 123 | 400 | should not |
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ use Behat\Gherkin\Node\TableNode;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use TestHelpers\GraphHelper;
|
||||
use TestHelpers\WebDavHelper;
|
||||
use PHPUnit\Framework\Assert;
|
||||
|
||||
require_once 'bootstrap.php';
|
||||
@@ -467,22 +468,44 @@ class GraphContext implements Context {
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^the administrator creates a group "([^"]*)" using the Graph API$/
|
||||
*
|
||||
* @param string $group
|
||||
* @param ?string $user
|
||||
*
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function createGroup(string $group, ?string $user = null): ResponseInterface {
|
||||
if ($user) {
|
||||
$username = $user;
|
||||
$password = $this->featureContext->getPasswordForUser($user);
|
||||
} else {
|
||||
$username = $this->featureContext->getAdminUsername();
|
||||
$password = $this->featureContext->getAdminPassword();
|
||||
}
|
||||
return GraphHelper::createGroup(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$username,
|
||||
$password,
|
||||
$group,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^the administrator creates a group "([^"]*)" using the Graph API$/
|
||||
* @When user :user creates a group :group using the Graph API
|
||||
* @When user :user tries to create a group :group using the Graph API
|
||||
*
|
||||
* @param string $group
|
||||
* @param ?string $user
|
||||
*
|
||||
* @return void
|
||||
* @throws Exception
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function adminCreatesGroupUsingTheGraphApi(string $group): void {
|
||||
$response = GraphHelper::createGroup(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$this->featureContext->getAdminUsername(),
|
||||
$this->featureContext->getAdminPassword(),
|
||||
$group,
|
||||
);
|
||||
public function userCreatesGroupUsingTheGraphApi(string $group, ?string $user = null): void {
|
||||
$response = $this->createGroup($group, $user);
|
||||
$this->featureContext->setResponse($response);
|
||||
$this->featureContext->pushToLastHttpStatusCodesArray((string) $response->getStatusCode());
|
||||
|
||||
@@ -502,13 +525,7 @@ class GraphContext implements Context {
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function adminHasCreatedGroupUsingTheGraphApi(string $group): array {
|
||||
$result = GraphHelper::createGroup(
|
||||
$this->featureContext->getBaseUrl(),
|
||||
$this->featureContext->getStepLineRef(),
|
||||
$this->featureContext->getAdminUsername(),
|
||||
$this->featureContext->getAdminPassword(),
|
||||
$group,
|
||||
);
|
||||
$result = $this->createGroup($group);
|
||||
if ($result->getStatusCode() === 200) {
|
||||
return $this->featureContext->getJsonDecodedResponse($result);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user