Skip to content

Commit

Permalink
[tests-only][full-ci] refactoring user creation Given steps from pr…
Browse files Browse the repository at this point in the history
…ovisioning into GraphContext (#7019)

* refactored the user creation given statement from provisioning to graph api

added getUser steps that covers the steps for user with user light role

* added userlight step tests to check drive information and updated expected failure files

* added usercreation initiation code

* deleted seperate tests for user light role

* remove unnecesary changes

* add user not initialize step

* corrected the testcode

* moved the steps from graph to provisioning file

* fix creating single ldap user

* fix: user check method

* initialize user via graph

* addressing reviews

---------

Co-authored-by: Saw-jan <saw.jan.grg3e@gmail.com>
  • Loading branch information
S-Panta and saw-jan authored Sep 6, 2023
1 parent 64bfdf2 commit 5efc3c5
Show file tree
Hide file tree
Showing 11 changed files with 194 additions and 474 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ The expected failures in this file are from features in the owncloud/ocis repo.
- [apiGraph/getUser.feature:91](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L91)
- [apiGraph/getUser.feature:92](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L92)
- [apiGraph/getUser.feature:93](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L93)
- [apiGraph/getUser.feature:606](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L606)
- [apiGraph/getUser.feature:607](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L607)
- [apiGraph/getUser.feature:608](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L608)
- [apiGraph/getUser.feature:609](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L609)
Expand All @@ -83,14 +82,15 @@ The expected failures in this file are from features in the owncloud/ocis repo.
- [apiGraph/getUser.feature:615](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L615)
- [apiGraph/getUser.feature:616](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L616)
- [apiGraph/getUser.feature:617](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L617)
- [apiGraph/getUser.feature:618](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L618)

#### [Normal user can get expanded members information of a group](https://github.com/owncloud/ocis/issues/5604)

- [apiGraph/getGroup.feature:381](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getGroup.feature#L381)
- [apiGraph/getGroup.feature:382](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getGroup.feature#L382)
- [apiGraph/getGroup.feature:383](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getGroup.feature#L383)

#### [Changing user with an uppercase name gives 404 error](https://github.com/owncloud/ocis/issues/5763)
#### [Changing user with an uppercase name gives 404 error](https://github.com/owncloud/ocis/issues/7044)

- [apiGraph/editUser.feature:67](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/editUser.feature#L67)

Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/features/apiGraph/editUser.feature
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Feature: edit user
| empty mail | | 400 | brian@example.com |
| change to a invalid email | invalidEmail | 400 | brian@example.com |

@issue-5763
@issue-7044
Scenario Outline: admin user can edit another user's name
Given user "Carol" has been created with default attributes and without skeleton files
When the user "Alice" changes the user name of user "Carol" to "<userName>" using the Graph API
Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/features/apiGraph/getUser.feature
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ Feature: get users
"""


Scenario Outline: non-admin user gets his/her own drive information
Scenario Outline: user gets his/her own information along with drive information
Given the administrator has assigned the role "<userRole>" to user "Brian" using the Graph API
When the user "Brian" gets his drive information using Graph API
Then the HTTP status code should be "200"
Expand Down Expand Up @@ -504,6 +504,7 @@ Feature: get users
"""
Examples:
| userRole |
| Admin |
| Space Admin |
| User |
| User Light |
Expand Down Expand Up @@ -750,7 +751,6 @@ Feature: get users
And the JSON data of the response should not contain the user "Alice Hansen" in the item 'value'



Scenario: admin user gets all users of two groups
Given the administrator has assigned the role "Admin" to user "Alice" using the Graph API
And user "Carol" has been created with default attributes and without skeleton files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function theUserGetsCapabilitiesCheckResponse():void {

/**
* @return string
* @throws Exception
* @throws Exception|GuzzleException
*/
public function getAdminUsernameForCapabilitiesCheck():string {
if (\TestHelpers\OcisHelper::isTestingOnReva()) {
Expand All @@ -190,7 +190,7 @@ public function getAdminUsernameForCapabilitiesCheck():string {
$adminUsername = "PseudoAdminForRevaTest";
$createdUsers = $this->featureContext->getCreatedUsers();
if (!\array_key_exists($adminUsername, $createdUsers)) {
$this->featureContext->createUser($adminUsername);
$this->featureContext->userHasBeenCreated(["userName" => $adminUsername]);
}
} else {
$adminUsername = $this->featureContext->getAdminUsername();
Expand Down
57 changes: 0 additions & 57 deletions tests/acceptance/features/bootstrap/GraphContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -724,41 +724,6 @@ public function theAdminHasRetrievedMembersListOfGroupUsingTheGraphApi(string $g
return $this->getArrayOfUsersResponded($this->listGroupMembers($group));
}

/**
* creates a user with provided data
* actor: the administrator
*
* @param string $user
* @param string $password
* @param string $email
* @param string $displayName
*
* @return void
* @throws Exception|GuzzleException
*/
public function theAdminHasCreatedUser(
string $user,
string $password,
string $email,
string $displayName
): void {
$response = GraphHelper::createUser(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$this->featureContext->getAdminUsername(),
$this->featureContext->getAdminPassword(),
$user,
$password,
$email,
$displayName
);
if ($response->getStatusCode() !== 200) {
$this->throwHttpException($response, "Could not create user $user");
} else {
$this->featureContext->setResponse($response);
}
}

/**
* @When /^the user "([^"]*)" creates a new user using GraphAPI with the following settings:$/
*
Expand Down Expand Up @@ -795,28 +760,6 @@ public function theUserCreatesNewUser(string $user, TableNode $table): void {
$this->featureContext->setResponse($response);
}

/**
* @Given /^the user "([^"]*)" has created a new user using the Graph API with the following settings:$/
*
* @param string $user
* @param TableNode $table
*
* @return void
* @throws Exception|GuzzleException
*/
public function theUserHasCreatedANewUserUsingGraphapiWithTheFollowingSettings(string $user, TableNode $table): void {
$this->theUserCreatesNewUser(
$user,
$table
);
$rows = $table->getRowsHash();
$response = $this->featureContext->getResponse();

if ($response->getStatusCode() !== 200) {
$this->throwHttpException($response, "Could not create user '$rows[userName]'");
}
}

/**
* adds a user to a group
*
Expand Down
Loading

0 comments on commit 5efc3c5

Please sign in to comment.