|  |  | @ -4,6 +4,8 @@ | 
			
		
	
		
			
				
					|  |  |  |  * SPDX-FileCopyrightText: 2016 ownCloud, Inc. | 
			
		
	
		
			
				
					|  |  |  |  * SPDX-License-Identifier: AGPL-3.0-or-later | 
			
		
	
		
			
				
					|  |  |  |  */ | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | use Behat\Gherkin\Node\TableNode; | 
			
		
	
		
			
				
					|  |  |  | use GuzzleHttp\Client; | 
			
		
	
		
			
				
					|  |  |  | use GuzzleHttp\Message\ResponseInterface; | 
			
		
	
		
			
				
					|  |  |  | use PHPUnit\Framework\Assert; | 
			
		
	
	
		
			
				
					|  |  | @ -124,7 +126,7 @@ trait Provisioning { | 
			
		
	
		
			
				
					|  |  |  | 	 * @Then /^user "([^"]*)" has$/
 | 
			
		
	
		
			
				
					|  |  |  | 	 * | 
			
		
	
		
			
				
					|  |  |  | 	 * @param string $user | 
			
		
	
		
			
				
					|  |  |  | 	 * @param \Behat\Gherkin\Node\TableNode|null $settings | 
			
		
	
		
			
				
					|  |  |  | 	 * @param TableNode|null $settings | 
			
		
	
		
			
				
					|  |  |  | 	 */ | 
			
		
	
		
			
				
					|  |  |  | 	public function userHasSetting($user, $settings) { | 
			
		
	
		
			
				
					|  |  |  | 		$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user"; | 
			
		
	
	
		
			
				
					|  |  | @ -145,12 +147,43 @@ trait Provisioning { | 
			
		
	
		
			
				
					|  |  |  | 			if (isset($value['element']) && in_array($setting[0], ['additional_mail', 'additional_mailScope'], true)) { | 
			
		
	
		
			
				
					|  |  |  | 				$expectedValues = explode(';', $setting[1]); | 
			
		
	
		
			
				
					|  |  |  | 				foreach ($expectedValues as $expected) { | 
			
		
	
		
			
				
					|  |  |  | 					Assert::assertTrue(in_array($expected, $value['element'], true)); | 
			
		
	
		
			
				
					|  |  |  | 					Assert::assertTrue(in_array($expected, $value['element'], true), 'Data wrong for field: ' . $setting[0]); | 
			
		
	
		
			
				
					|  |  |  | 				} | 
			
		
	
		
			
				
					|  |  |  | 			} elseif (isset($value[0])) { | 
			
		
	
		
			
				
					|  |  |  | 				Assert::assertEqualsCanonicalizing($setting[1], $value[0]); | 
			
		
	
		
			
				
					|  |  |  | 				Assert::assertEqualsCanonicalizing($setting[1], $value[0], 'Data wrong for field: ' . $setting[0]); | 
			
		
	
		
			
				
					|  |  |  | 			} else { | 
			
		
	
		
			
				
					|  |  |  | 				Assert::assertEquals('', $setting[1]); | 
			
		
	
		
			
				
					|  |  |  | 				Assert::assertEquals('', $setting[1], 'Data wrong for field: ' . $setting[0]); | 
			
		
	
		
			
				
					|  |  |  | 			} | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	/** | 
			
		
	
		
			
				
					|  |  |  | 	 * @Then /^user "([^"]*)" has the following profile data$/
 | 
			
		
	
		
			
				
					|  |  |  | 	 */ | 
			
		
	
		
			
				
					|  |  |  | 	public function userHasProfileData(string $user, ?TableNode $settings): void { | 
			
		
	
		
			
				
					|  |  |  | 		$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/profile/$user"; | 
			
		
	
		
			
				
					|  |  |  | 		$client = new Client(); | 
			
		
	
		
			
				
					|  |  |  | 		$options = []; | 
			
		
	
		
			
				
					|  |  |  | 		if ($this->currentUser === 'admin') { | 
			
		
	
		
			
				
					|  |  |  | 			$options['auth'] = $this->adminUser; | 
			
		
	
		
			
				
					|  |  |  | 		} else { | 
			
		
	
		
			
				
					|  |  |  | 			$options['auth'] = [$this->currentUser, $this->regularUser]; | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 		$options['headers'] = [ | 
			
		
	
		
			
				
					|  |  |  | 			'OCS-APIREQUEST' => 'true', | 
			
		
	
		
			
				
					|  |  |  | 			'Accept' => 'application/json', | 
			
		
	
		
			
				
					|  |  |  | 		]; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 		$response = $client->get($fullUrl, $options); | 
			
		
	
		
			
				
					|  |  |  | 		$body = $response->getBody()->getContents(); | 
			
		
	
		
			
				
					|  |  |  | 		$data = json_decode($body, true); | 
			
		
	
		
			
				
					|  |  |  | 		$data = $data['ocs']['data']; | 
			
		
	
		
			
				
					|  |  |  | 		foreach ($settings->getRows() as $setting) { | 
			
		
	
		
			
				
					|  |  |  | 			Assert::assertArrayHasKey($setting[0], $data, 'Profile data field missing: ' . $setting[0]); | 
			
		
	
		
			
				
					|  |  |  | 			if ($setting[1] === 'NULL') { | 
			
		
	
		
			
				
					|  |  |  | 				Assert::assertNull($data[$setting[0]], 'Profile data wrong for field: ' . $setting[0]); | 
			
		
	
		
			
				
					|  |  |  | 			} else { | 
			
		
	
		
			
				
					|  |  |  | 				Assert::assertEquals($setting[1], $data[$setting[0]], 'Profile data wrong for field: ' . $setting[0]); | 
			
		
	
		
			
				
					|  |  |  | 			} | 
			
		
	
		
			
				
					|  |  |  | 		} | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
	
		
			
				
					|  |  | @ -159,7 +192,7 @@ trait Provisioning { | 
			
		
	
		
			
				
					|  |  |  | 	 * @Then /^group "([^"]*)" has$/
 | 
			
		
	
		
			
				
					|  |  |  | 	 * | 
			
		
	
		
			
				
					|  |  |  | 	 * @param string $user | 
			
		
	
		
			
				
					|  |  |  | 	 * @param \Behat\Gherkin\Node\TableNode|null $settings | 
			
		
	
		
			
				
					|  |  |  | 	 * @param TableNode|null $settings | 
			
		
	
		
			
				
					|  |  |  | 	 */ | 
			
		
	
		
			
				
					|  |  |  | 	public function groupHasSetting($group, $settings) { | 
			
		
	
		
			
				
					|  |  |  | 		$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/groups/details?search=$group"; | 
			
		
	
	
		
			
				
					|  |  | @ -191,7 +224,7 @@ trait Provisioning { | 
			
		
	
		
			
				
					|  |  |  | 	 * @Then /^user "([^"]*)" has editable fields$/
 | 
			
		
	
		
			
				
					|  |  |  | 	 * | 
			
		
	
		
			
				
					|  |  |  | 	 * @param string $user | 
			
		
	
		
			
				
					|  |  |  | 	 * @param \Behat\Gherkin\Node\TableNode|null $fields | 
			
		
	
		
			
				
					|  |  |  | 	 * @param TableNode|null $fields | 
			
		
	
		
			
				
					|  |  |  | 	 */ | 
			
		
	
		
			
				
					|  |  |  | 	public function userHasEditableFields($user, $fields) { | 
			
		
	
		
			
				
					|  |  |  | 		$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/user/fields"; | 
			
		
	
	
		
			
				
					|  |  | @ -221,9 +254,9 @@ trait Provisioning { | 
			
		
	
		
			
				
					|  |  |  | 	 * @Then /^search users by phone for region "([^"]*)" with$/
 | 
			
		
	
		
			
				
					|  |  |  | 	 * | 
			
		
	
		
			
				
					|  |  |  | 	 * @param string $user | 
			
		
	
		
			
				
					|  |  |  | 	 * @param \Behat\Gherkin\Node\TableNode|null $settings | 
			
		
	
		
			
				
					|  |  |  | 	 * @param TableNode|null $settings | 
			
		
	
		
			
				
					|  |  |  | 	 */ | 
			
		
	
		
			
				
					|  |  |  | 	public function searchUserByPhone($region, \Behat\Gherkin\Node\TableNode $searchTable) { | 
			
		
	
		
			
				
					|  |  |  | 	public function searchUserByPhone($region, TableNode $searchTable) { | 
			
		
	
		
			
				
					|  |  |  | 		$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/search/by-phone"; | 
			
		
	
		
			
				
					|  |  |  | 		$client = new Client(); | 
			
		
	
		
			
				
					|  |  |  | 		$options = []; | 
			
		
	
	
		
			
				
					|  |  | @ -624,10 +657,10 @@ trait Provisioning { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	/** | 
			
		
	
		
			
				
					|  |  |  | 	 * @Then /^users returned are$/ | 
			
		
	
		
			
				
					|  |  |  | 	 * @param \Behat\Gherkin\Node\TableNode|null $usersList | 
			
		
	
		
			
				
					|  |  |  | 	 * @param TableNode|null $usersList | 
			
		
	
		
			
				
					|  |  |  | 	 */ | 
			
		
	
		
			
				
					|  |  |  | 	public function theUsersShouldBe($usersList) { | 
			
		
	
		
			
				
					|  |  |  | 		if ($usersList instanceof \Behat\Gherkin\Node\TableNode) { | 
			
		
	
		
			
				
					|  |  |  | 		if ($usersList instanceof TableNode) { | 
			
		
	
		
			
				
					|  |  |  | 			$users = $usersList->getRows(); | 
			
		
	
		
			
				
					|  |  |  | 			$usersSimplified = $this->simplifyArray($users); | 
			
		
	
		
			
				
					|  |  |  | 			$respondedArray = $this->getArrayOfUsersResponded($this->response); | 
			
		
	
	
		
			
				
					|  |  | @ -637,10 +670,10 @@ trait Provisioning { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	/** | 
			
		
	
		
			
				
					|  |  |  | 	 * @Then /^phone matches returned are$/ | 
			
		
	
		
			
				
					|  |  |  | 	 * @param \Behat\Gherkin\Node\TableNode|null $usersList | 
			
		
	
		
			
				
					|  |  |  | 	 * @param TableNode|null $usersList | 
			
		
	
		
			
				
					|  |  |  | 	 */ | 
			
		
	
		
			
				
					|  |  |  | 	public function thePhoneUsersShouldBe($usersList) { | 
			
		
	
		
			
				
					|  |  |  | 		if ($usersList instanceof \Behat\Gherkin\Node\TableNode) { | 
			
		
	
		
			
				
					|  |  |  | 		if ($usersList instanceof TableNode) { | 
			
		
	
		
			
				
					|  |  |  | 			$users = $usersList->getRowsHash(); | 
			
		
	
		
			
				
					|  |  |  | 			$listCheckedElements = simplexml_load_string($this->response->getBody())->data; | 
			
		
	
		
			
				
					|  |  |  | 			$respondedArray = json_decode(json_encode($listCheckedElements), true); | 
			
		
	
	
		
			
				
					|  |  | @ -650,10 +683,10 @@ trait Provisioning { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	/** | 
			
		
	
		
			
				
					|  |  |  | 	 * @Then /^detailed users returned are$/ | 
			
		
	
		
			
				
					|  |  |  | 	 * @param \Behat\Gherkin\Node\TableNode|null $usersList | 
			
		
	
		
			
				
					|  |  |  | 	 * @param TableNode|null $usersList | 
			
		
	
		
			
				
					|  |  |  | 	 */ | 
			
		
	
		
			
				
					|  |  |  | 	public function theDetailedUsersShouldBe($usersList) { | 
			
		
	
		
			
				
					|  |  |  | 		if ($usersList instanceof \Behat\Gherkin\Node\TableNode) { | 
			
		
	
		
			
				
					|  |  |  | 		if ($usersList instanceof TableNode) { | 
			
		
	
		
			
				
					|  |  |  | 			$users = $usersList->getRows(); | 
			
		
	
		
			
				
					|  |  |  | 			$usersSimplified = $this->simplifyArray($users); | 
			
		
	
		
			
				
					|  |  |  | 			$respondedArray = $this->getArrayOfDetailedUsersResponded($this->response); | 
			
		
	
	
		
			
				
					|  |  | @ -664,10 +697,10 @@ trait Provisioning { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	/** | 
			
		
	
		
			
				
					|  |  |  | 	 * @Then /^groups returned are$/ | 
			
		
	
		
			
				
					|  |  |  | 	 * @param \Behat\Gherkin\Node\TableNode|null $groupsList | 
			
		
	
		
			
				
					|  |  |  | 	 * @param TableNode|null $groupsList | 
			
		
	
		
			
				
					|  |  |  | 	 */ | 
			
		
	
		
			
				
					|  |  |  | 	public function theGroupsShouldBe($groupsList) { | 
			
		
	
		
			
				
					|  |  |  | 		if ($groupsList instanceof \Behat\Gherkin\Node\TableNode) { | 
			
		
	
		
			
				
					|  |  |  | 		if ($groupsList instanceof TableNode) { | 
			
		
	
		
			
				
					|  |  |  | 			$groups = $groupsList->getRows(); | 
			
		
	
		
			
				
					|  |  |  | 			$groupsSimplified = $this->simplifyArray($groups); | 
			
		
	
		
			
				
					|  |  |  | 			$respondedArray = $this->getArrayOfGroupsResponded($this->response); | 
			
		
	
	
		
			
				
					|  |  | @ -677,10 +710,10 @@ trait Provisioning { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	/** | 
			
		
	
		
			
				
					|  |  |  | 	 * @Then /^subadmin groups returned are$/ | 
			
		
	
		
			
				
					|  |  |  | 	 * @param \Behat\Gherkin\Node\TableNode|null $groupsList | 
			
		
	
		
			
				
					|  |  |  | 	 * @param TableNode|null $groupsList | 
			
		
	
		
			
				
					|  |  |  | 	 */ | 
			
		
	
		
			
				
					|  |  |  | 	public function theSubadminGroupsShouldBe($groupsList) { | 
			
		
	
		
			
				
					|  |  |  | 		if ($groupsList instanceof \Behat\Gherkin\Node\TableNode) { | 
			
		
	
		
			
				
					|  |  |  | 		if ($groupsList instanceof TableNode) { | 
			
		
	
		
			
				
					|  |  |  | 			$groups = $groupsList->getRows(); | 
			
		
	
		
			
				
					|  |  |  | 			$groupsSimplified = $this->simplifyArray($groups); | 
			
		
	
		
			
				
					|  |  |  | 			$respondedArray = $this->getArrayOfSubadminsResponded($this->response); | 
			
		
	
	
		
			
				
					|  |  | @ -690,10 +723,10 @@ trait Provisioning { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	/** | 
			
		
	
		
			
				
					|  |  |  | 	 * @Then /^apps returned are$/ | 
			
		
	
		
			
				
					|  |  |  | 	 * @param \Behat\Gherkin\Node\TableNode|null $appList | 
			
		
	
		
			
				
					|  |  |  | 	 * @param TableNode|null $appList | 
			
		
	
		
			
				
					|  |  |  | 	 */ | 
			
		
	
		
			
				
					|  |  |  | 	public function theAppsShouldBe($appList) { | 
			
		
	
		
			
				
					|  |  |  | 		if ($appList instanceof \Behat\Gherkin\Node\TableNode) { | 
			
		
	
		
			
				
					|  |  |  | 		if ($appList instanceof TableNode) { | 
			
		
	
		
			
				
					|  |  |  | 			$apps = $appList->getRows(); | 
			
		
	
		
			
				
					|  |  |  | 			$appsSimplified = $this->simplifyArray($apps); | 
			
		
	
		
			
				
					|  |  |  | 			$respondedArray = $this->getArrayOfAppsResponded($this->response); | 
			
		
	
	
		
			
				
					|  |  | @ -703,7 +736,7 @@ trait Provisioning { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 	/** | 
			
		
	
		
			
				
					|  |  |  | 	 * @Then /^subadmin users returned are$/ | 
			
		
	
		
			
				
					|  |  |  | 	 * @param \Behat\Gherkin\Node\TableNode|null $groupsList | 
			
		
	
		
			
				
					|  |  |  | 	 * @param TableNode|null $groupsList | 
			
		
	
		
			
				
					|  |  |  | 	 */ | 
			
		
	
		
			
				
					|  |  |  | 	public function theSubadminUsersShouldBe($groupsList) { | 
			
		
	
		
			
				
					|  |  |  | 		$this->theSubadminGroupsShouldBe($groupsList); | 
			
		
	
	
		
			
				
					|  |  | @ -882,7 +915,7 @@ trait Provisioning { | 
			
		
	
		
			
				
					|  |  |  | 	 * @param string $quota | 
			
		
	
		
			
				
					|  |  |  | 	 */ | 
			
		
	
		
			
				
					|  |  |  | 	public function userHasAQuotaOf($user, $quota) { | 
			
		
	
		
			
				
					|  |  |  | 		$body = new \Behat\Gherkin\Node\TableNode([ | 
			
		
	
		
			
				
					|  |  |  | 		$body = new TableNode([ | 
			
		
	
		
			
				
					|  |  |  | 			0 => ['key', 'quota'], | 
			
		
	
		
			
				
					|  |  |  | 			1 => ['value', $quota], | 
			
		
	
		
			
				
					|  |  |  | 		]); | 
			
		
	
	
		
			
				
					|  |  | @ -950,7 +983,7 @@ trait Provisioning { | 
			
		
	
		
			
				
					|  |  |  | 	/** | 
			
		
	
		
			
				
					|  |  |  | 	 * @Then /^user "([^"]*)" has not$/
 | 
			
		
	
		
			
				
					|  |  |  | 	 */ | 
			
		
	
		
			
				
					|  |  |  | 	public function userHasNotSetting($user, \Behat\Gherkin\Node\TableNode $settings) { | 
			
		
	
		
			
				
					|  |  |  | 	public function userHasNotSetting($user, TableNode $settings) { | 
			
		
	
		
			
				
					|  |  |  | 		$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/cloud/users/$user"; | 
			
		
	
		
			
				
					|  |  |  | 		$client = new Client(); | 
			
		
	
		
			
				
					|  |  |  | 		$options = []; | 
			
		
	
	
		
			
				
					|  |  | 
 |