[test-only] add API acceptance tests to create user using the admin privilege (#4902)

* add api test

* fix typo

* php style fix
This commit is contained in:
Viktor Scharf
2022-11-04 12:39:54 +01:00
committed by GitHub
parent 655d650baf
commit 753812bf63
3 changed files with 107 additions and 2 deletions
@@ -1,4 +1,6 @@
<?php declare(strict_types=1);
<?php
declare(strict_types=1);
/**
* ownCloud
*
@@ -395,6 +397,42 @@ class GraphContext implements Context {
}
}
/**
* @When /^the user "([^"]*)" creates a new user using GraphAPI with the following settings:$/
*
* @param string $user
* @param TableNode $table
*
* @return void
* @throws Exception|GuzzleException
*/
public function theUserCreatesNewUser(string $user, TableNode $table): void {
$rows = $table->getRowsHash();
$response = GraphHelper::createUser(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$rows["userName"],
$rows["password"],
$rows["email"],
$rows["displayName"]
);
// add created user to list except for the user with an empty name
// because request /graph/v1.0/users/emptyUserName exits with 200
// and we cannot check that the user with empty name doesn't exist
if (!empty($rows["userName"])) {
$this->featureContext->addUserToCreatedUsersList(
$rows["userName"],
$rows["password"],
$rows["displayName"],
$rows["email"]
);
}
$this->featureContext->setResponse($response);
}
/**
* adds a user to a group
*
@@ -549,7 +587,7 @@ class GraphContext implements Context {
* @throws GuzzleException
* @throws Exception
*/
public function userChangesOwnPassword(string $user, string $currentPassword, $newPassword): void {
public function userChangesOwnPassword(string $user, string $currentPassword, string $newPassword): void {
$response = GraphHelper::changeOwnPassword(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),