[test-only] Api test. get applications list. (#5529)

This commit is contained in:
Viktor Scharf authored and Phil Davis committed 2023-03-06 12:43:17 +05:45
1 parent 2078bbc22e
commit 1f2f9f3107
3 files changed
+114

No files matched your search

+25
View File
@@ -1058,4 +1058,29 @@ class GraphHelper {
\json_encode($payload)
);
}
/**
* @param string $baseUrl
* @param string $xRequestId
* @param string $user
* @param string $password
*
* @return ResponseInterface
* @throws GuzzleException
*/
public static function getApplications(
string $baseUrl,
string $xRequestId,
string $user,
string $password
): ResponseInterface {
$url = self::getFullUrl($baseUrl, 'applications');
return HttpRequestHelper::get(
$url,
$xRequestId,
$user,
$password,
self::getRequestHeaders()
);
}
}
@@ -0,0 +1,28 @@
@api @skipOnOcV10
Feature: get applications
As an user
I want to be able to get applications information with existings roles
Background:
Given user "Alice" has been created with default attributes and without skeleton files
Scenario Outline: admin user lists all the groups
Given the administrator has given "Alice" the role "<role>" using the settings api
When user "Alice" gets all applications using the Graph API
Then the HTTP status code should be "200"
And the user retrieve API response should contain the following applications information:
| key | value |
| displayName | ownCloud Infinite Scale |
| id | %uuid_v4% |
And the user retrieve API response should contain the following app roles:
| Admin |
| Space Admin |
| User |
| Guest |
Examples:
| role |
| Admin |
| Space Admin |
| User |
| Guest |
@@ -1665,4 +1665,65 @@ class GraphContext implements Context {
}
$this->addMultipleUsersToGroup($user, $userIds, $groupId, $table);
}
/**
* @When user :user gets all applications using the Graph API
*
* @param string $user
*
* @return void
* @throws GuzzleException
*/
public function userGetsAllApplicationsUsingTheGraphApi(string $user) {
$response = GraphHelper::getApplications(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
);
$this->featureContext->setResponse($response);
}
/**
* @Then the user retrieve API response should contain the following applications information:
*
* @param TableNode $table
*
* @return void
*/
public function theResponseShouldContainTheFollowingApplicationsInformation(TableNode $table): void {
Assert::assertIsArray($responseArray = ($this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse()))['value'][0]);
foreach ($table->getHash() as $row) {
$key = $row["key"];
if ($key === 'id') {
Assert::assertTrue(
GraphHelper::isUUIDv4($responseArray[$key]),
__METHOD__ . ' Expected id to have UUIDv4 pattern but found: ' . $row["value"]
);
} else {
Assert::assertEquals($responseArray[$key], $row["value"]);
}
}
}
/**
* @Then the user retrieve API response should contain the following app roles:
*
* @param TableNode $table
*
* @return void
*/
public function theResponseShouldContainTheFollowingAppRolesInformation(TableNode $table): void {
Assert::assertIsArray($responseArray = ($this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse()))['value'][0]);
foreach ($table->getRows() as $row) {
$foundRoleInResponse = false;
foreach ($responseArray['appRoles'] as $role) {
if ($role['displayName'] === $row[0]) {
$foundRoleInResponse = true;
break;
}
}
Assert::assertTrue($foundRoleInResponse, "the response does not contain the role $row[0]");
}
}
}