summaryrefslogtreecommitdiffstats
path: root/build/integration/features/bootstrap/Provisioning.php
diff options
context:
space:
mode:
Diffstat (limited to 'build/integration/features/bootstrap/Provisioning.php')
-rw-r--r--build/integration/features/bootstrap/Provisioning.php92
1 files changed, 47 insertions, 45 deletions
diff --git a/build/integration/features/bootstrap/Provisioning.php b/build/integration/features/bootstrap/Provisioning.php
index 00402d73a2c..2543777faa5 100644
--- a/build/integration/features/bootstrap/Provisioning.php
+++ b/build/integration/features/bootstrap/Provisioning.php
@@ -26,6 +26,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
+
use GuzzleHttp\Client;
use GuzzleHttp\Message\ResponseInterface;
@@ -42,7 +43,7 @@ trait Provisioning {
/** @var array */
private $createdRemoteGroups = [];
-
+
/** @var array */
private $createdGroups = [];
@@ -95,7 +96,7 @@ trait Provisioning {
$options['auth'] = $this->adminUser;
}
- $options['body'] = [
+ $options['form_params'] = [
'userid' => $user,
'password' => '123456'
];
@@ -103,8 +104,8 @@ trait Provisioning {
'OCS-APIREQUEST' => 'true',
];
- $this->response = $client->send($client->createRequest("POST", $fullUrl, $options));
- if ($this->currentServer === 'LOCAL'){
+ $this->response = $client->post($fullUrl, $options);
+ if ($this->currentServer === 'LOCAL') {
$this->createdUsers[$user] = $user;
} elseif ($this->currentServer === 'REMOTE') {
$this->createdRemoteUsers[$user] = $user;
@@ -117,8 +118,8 @@ trait Provisioning {
$options2['headers'] = [
'OCS-APIREQUEST' => 'true',
];
- $url = $fullUrl.'/'.$user;
- $client->send($client->createRequest('GET', $url, $options2));
+ $url = $fullUrl . '/' . $user;
+ $client->get($url, $options2);
}
/**
@@ -136,9 +137,9 @@ trait Provisioning {
'OCS-APIREQUEST' => 'true',
];
- $response = $client->send($client->createRequest("GET", $fullUrl, $options));
+ $response = $client->get($fullUrl, $options);
foreach ($settings->getRows() as $setting) {
- $value = json_decode(json_encode($response->xml()->data->{$setting[0]}), 1);
+ $value = json_decode(json_encode(simplexml_load_string($response->getBody())->data->{$setting[0]}), 1);
if (isset($value[0])) {
PHPUnit_Framework_Assert::assertEquals($setting[1], $value[0], "", 0.0, 10, true);
} else {
@@ -179,7 +180,7 @@ trait Provisioning {
$this->currentUser = $previous_user;
}
- public function userExists($user){
+ public function userExists($user) {
$fullUrl = $this->baseUrl . "v2.php/cloud/users/$user";
$client = new Client();
$options = [];
@@ -229,9 +230,9 @@ trait Provisioning {
$respondedArray = $this->getArrayOfGroupsResponded($this->response);
if (array_key_exists($group, $respondedArray)) {
- return True;
- } else{
- return False;
+ return true;
+ } else {
+ return false;
}
}
@@ -240,11 +241,11 @@ trait Provisioning {
* @param string $user
* @param string $group
*/
- public function assureUserBelongsToGroup($user, $group){
+ public function assureUserBelongsToGroup($user, $group) {
$previous_user = $this->currentUser;
$this->currentUser = "admin";
- if (!$this->userBelongsToGroup($user, $group)){
+ if (!$this->userBelongsToGroup($user, $group)) {
$this->addingUserToGroup($user, $group);
}
@@ -287,15 +288,15 @@ trait Provisioning {
$options['auth'] = $this->adminUser;
}
- $options['body'] = [
+ $options['form_params'] = [
'groupid' => $group,
];
$options['headers'] = [
'OCS-APIREQUEST' => 'true',
];
- $this->response = $client->send($client->createRequest("POST", $fullUrl, $options));
- if ($this->currentServer === 'LOCAL'){
+ $this->response = $client->post($fullUrl, $options);
+ if ($this->currentServer === 'LOCAL') {
$this->createdGroups[$group] = $group;
} elseif ($this->currentServer === 'REMOTE') {
$this->createdRemoteGroups[$group] = $group;
@@ -316,11 +317,11 @@ trait Provisioning {
'OCS-APIREQUEST' => 'true',
];
// TODO: fix hack
- $options['body'] = [
+ $options['form_params'] = [
'foo' => 'bar'
];
- $this->response = $client->send($client->createRequest("PUT", $fullUrl, $options));
+ $this->response = $client->put($fullUrl, $options);
}
/**
@@ -338,7 +339,7 @@ trait Provisioning {
'OCS-APIREQUEST' => 'true',
];
- $this->response = $client->send($client->createRequest("DELETE", $fullUrl, $options));
+ $this->response = $client->delete($fullUrl, $options);
}
/**
@@ -356,9 +357,9 @@ trait Provisioning {
'OCS-APIREQUEST' => 'true',
];
- $this->response = $client->send($client->createRequest("DELETE", $fullUrl, $options));
+ $this->response = $client->delete($fullUrl, $options);
- if ($this->currentServer === 'LOCAL'){
+ if ($this->currentServer === 'LOCAL') {
unset($this->createdGroups[$group]);
} elseif ($this->currentServer === 'REMOTE') {
unset($this->createdRemoteGroups[$group]);
@@ -393,11 +394,11 @@ trait Provisioning {
'OCS-APIREQUEST' => 'true',
];
- $options['body'] = [
+ $options['form_params'] = [
'groupid' => $group,
];
- $this->response = $client->send($client->createRequest("POST", $fullUrl, $options));
+ $this->response =$client->post($fullUrl, $options);
}
@@ -489,13 +490,13 @@ trait Provisioning {
if ($this->currentUser === 'admin') {
$options['auth'] = $this->adminUser;
}
- $options['body'] = [
+ $options['form_params'] = [
'groupid' => $group
];
$options['headers'] = [
'OCS-APIREQUEST' => 'true',
];
- $this->response = $client->send($client->createRequest("POST", $fullUrl, $options));
+ $this->response = $client->post($fullUrl, $options);
PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode());
}
@@ -588,44 +589,48 @@ trait Provisioning {
/**
* Parses the xml answer to get the array of users returned.
+ *
* @param ResponseInterface $resp
* @return array
*/
public function getArrayOfUsersResponded($resp) {
- $listCheckedElements = $resp->xml()->data[0]->users[0]->element;
+ $listCheckedElements = simplexml_load_string($resp->getBody())->data[0]->users[0]->element;
$extractedElementsArray = json_decode(json_encode($listCheckedElements), 1);
return $extractedElementsArray;
}
/**
* Parses the xml answer to get the array of groups returned.
+ *
* @param ResponseInterface $resp
* @return array
*/
public function getArrayOfGroupsResponded($resp) {
- $listCheckedElements = $resp->xml()->data[0]->groups[0]->element;
+ $listCheckedElements = simplexml_load_string($resp->getBody())->data[0]->groups[0]->element;
$extractedElementsArray = json_decode(json_encode($listCheckedElements), 1);
return $extractedElementsArray;
}
/**
* Parses the xml answer to get the array of apps returned.
+ *
* @param ResponseInterface $resp
* @return array
*/
public function getArrayOfAppsResponded($resp) {
- $listCheckedElements = $resp->xml()->data[0]->apps[0]->element;
+ $listCheckedElements = simplexml_load_string($resp->getBody())->data[0]->apps[0]->element;
$extractedElementsArray = json_decode(json_encode($listCheckedElements), 1);
return $extractedElementsArray;
}
/**
* Parses the xml answer to get the array of subadmins returned.
+ *
* @param ResponseInterface $resp
* @return array
*/
public function getArrayOfSubadminsResponded($resp) {
- $listCheckedElements = $resp->xml()->data[0]->element;
+ $listCheckedElements = simplexml_load_string($resp->getBody())->data[0]->element;
$extractedElementsArray = json_decode(json_encode($listCheckedElements), 1);
return $extractedElementsArray;
}
@@ -689,7 +694,7 @@ trait Provisioning {
];
$this->response = $client->get($fullUrl, $options);
- PHPUnit_Framework_Assert::assertEquals("false", $this->response->xml()->data[0]->enabled);
+ PHPUnit_Framework_Assert::assertEquals("false", simplexml_load_string($this->response->getBody())->data[0]->enabled);
}
/**
@@ -708,7 +713,7 @@ trait Provisioning {
];
$this->response = $client->get($fullUrl, $options);
- PHPUnit_Framework_Assert::assertEquals("true", $this->response->xml()->data[0]->enabled);
+ PHPUnit_Framework_Assert::assertEquals("true", simplexml_load_string($this->response->getBody())->data[0]->enabled);
}
/**
@@ -716,8 +721,7 @@ trait Provisioning {
* @param string $user
* @param string $quota
*/
- public function userHasAQuotaOf($user, $quota)
- {
+ public function userHasAQuotaOf($user, $quota) {
$body = new \Behat\Gherkin\Node\TableNode([
0 => ['key', 'quota'],
1 => ['value', $quota],
@@ -731,13 +735,13 @@ trait Provisioning {
* @Given user :user has unlimited quota
* @param string $user
*/
- public function userHasUnlimitedQuota($user)
- {
+ public function userHasUnlimitedQuota($user) {
$this->userHasAQuotaOf($user, 'none');
}
/**
* Returns home path of the given user
+ *
* @param string $user
*/
public function getUserHome($user) {
@@ -746,22 +750,21 @@ trait Provisioning {
$options = [];
$options['auth'] = $this->adminUser;
$this->response = $client->get($fullUrl, $options);
- return $this->response->xml()->data[0]->home;
+ return simplexml_load_string($this->response->getBody())->data[0]->home;
}
/**
* @BeforeScenario
* @AfterScenario
*/
- public function cleanupUsers()
- {
+ public function cleanupUsers() {
$previousServer = $this->currentServer;
$this->usingServer('LOCAL');
- foreach($this->createdUsers as $user) {
+ foreach ($this->createdUsers as $user) {
$this->deleteUser($user);
}
$this->usingServer('REMOTE');
- foreach($this->createdRemoteUsers as $remoteUser) {
+ foreach ($this->createdRemoteUsers as $remoteUser) {
$this->deleteUser($remoteUser);
}
$this->usingServer($previousServer);
@@ -771,15 +774,14 @@ trait Provisioning {
* @BeforeScenario
* @AfterScenario
*/
- public function cleanupGroups()
- {
+ public function cleanupGroups() {
$previousServer = $this->currentServer;
$this->usingServer('LOCAL');
- foreach($this->createdGroups as $group) {
+ foreach ($this->createdGroups as $group) {
$this->deleteGroup($group);
}
$this->usingServer('REMOTE');
- foreach($this->createdRemoteGroups as $remoteGroup) {
+ foreach ($this->createdRemoteGroups as $remoteGroup) {
$this->deleteGroup($remoteGroup);
}
$this->usingServer($previousServer);