|
|
@ -69,6 +69,23 @@ trait Provisioning { |
|
|
Assert::assertEquals(200, $this->response->getStatusCode()); |
|
|
Assert::assertEquals(200, $this->response->getStatusCode()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Given /^user "([^"]*)" with displayname "([^"]*)" exists$/ |
|
|
|
|
|
* @param string $user |
|
|
|
|
|
*/ |
|
|
|
|
|
public function assureUserWithDisplaynameExists($user, $displayname) { |
|
|
|
|
|
try { |
|
|
|
|
|
$this->userExists($user); |
|
|
|
|
|
} catch (\GuzzleHttp\Exception\ClientException $ex) { |
|
|
|
|
|
$previous_user = $this->currentUser; |
|
|
|
|
|
$this->currentUser = "admin"; |
|
|
|
|
|
$this->creatingTheUser($user, $displayname); |
|
|
|
|
|
$this->currentUser = $previous_user; |
|
|
|
|
|
} |
|
|
|
|
|
$this->userExists($user); |
|
|
|
|
|
Assert::assertEquals(200, $this->response->getStatusCode()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @Given /^user "([^"]*)" does not exist$/
|
|
|
* @Given /^user "([^"]*)" does not exist$/
|
|
|
* @param string $user |
|
|
* @param string $user |
|
|
@ -93,7 +110,7 @@ trait Provisioning { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function creatingTheUser($user) { |
|
|
|
|
|
|
|
|
public function creatingTheUser($user, $displayname = '') { |
|
|
$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users"; |
|
|
$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users"; |
|
|
$client = new Client(); |
|
|
$client = new Client(); |
|
|
$options = []; |
|
|
$options = []; |
|
|
@ -105,6 +122,9 @@ trait Provisioning { |
|
|
'userid' => $user, |
|
|
'userid' => $user, |
|
|
'password' => '123456' |
|
|
'password' => '123456' |
|
|
]; |
|
|
]; |
|
|
|
|
|
if ($displayname !== '') { |
|
|
|
|
|
$options['form_params']['displayName'] = $displayname; |
|
|
|
|
|
} |
|
|
$options['headers'] = [ |
|
|
$options['headers'] = [ |
|
|
'OCS-APIREQUEST' => 'true', |
|
|
'OCS-APIREQUEST' => 'true', |
|
|
]; |
|
|
]; |
|
|
@ -540,6 +560,20 @@ trait Provisioning { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Then /^detailed users returned are$/ |
|
|
|
|
|
* @param \Behat\Gherkin\Node\TableNode|null $usersList |
|
|
|
|
|
*/ |
|
|
|
|
|
public function theDetailedUsersShouldBe($usersList) { |
|
|
|
|
|
if ($usersList instanceof \Behat\Gherkin\Node\TableNode) { |
|
|
|
|
|
$users = $usersList->getRows(); |
|
|
|
|
|
$usersSimplified = $this->simplifyArray($users); |
|
|
|
|
|
$respondedArray = $this->getArrayOfDetailedUsersResponded($this->response); |
|
|
|
|
|
$respondedArray = array_keys($respondedArray); |
|
|
|
|
|
Assert::assertEquals($usersSimplified, $respondedArray); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @Then /^groups returned are$/ |
|
|
* @Then /^groups returned are$/ |
|
|
* @param \Behat\Gherkin\Node\TableNode|null $groupsList |
|
|
* @param \Behat\Gherkin\Node\TableNode|null $groupsList |
|
|
@ -599,6 +633,18 @@ trait Provisioning { |
|
|
return $extractedElementsArray; |
|
|
return $extractedElementsArray; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* Parses the xml answer to get the array of detailed users returned. |
|
|
|
|
|
* |
|
|
|
|
|
* @param ResponseInterface $resp |
|
|
|
|
|
* @return array |
|
|
|
|
|
*/ |
|
|
|
|
|
public function getArrayOfDetailedUsersResponded($resp) { |
|
|
|
|
|
$listCheckedElements = simplexml_load_string($resp->getBody())->data[0]->users; |
|
|
|
|
|
$extractedElementsArray = json_decode(json_encode($listCheckedElements), 1); |
|
|
|
|
|
return $extractedElementsArray; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Parses the xml answer to get the array of groups returned. |
|
|
* Parses the xml answer to get the array of groups returned. |
|
|
* |
|
|
* |
|
|
|