Added expected to failure file

This commit is contained in:
sagargurung1001@gmail.com
2022-11-29 16:39:10 +05:45
committed by Phil Davis
parent 9f0a22af7e
commit 6ff9d6196f
4 changed files with 168 additions and 118 deletions

View File

@@ -242,31 +242,31 @@ class GraphHelper {
);
}
/**
* @param string $baseUrl
* @param string $xRequestId
* @param string $adminUser
* @param string $adminPassword
* @param string $ofUser
*
* @return ResponseInterface
* @throws GuzzleException
*/
public static function getUserWithDriveInformation(
string $baseUrl,
string $xRequestId,
string $user,
string $userPassword,
string $ofUser
): ResponseInterface {
$url = self::getFullUrl($baseUrl, 'users/'. $ofUser . '?%24select=&%24expand=drive');
return HttpRequestHelper::get(
$url,
$xRequestId,
$user,
$userPassword,
);
}
/**
* @param string $baseUrl
* @param string $xRequestId
* @param string $user
* @param string $userPassword
* @param string|null $ofUser
*
* @return ResponseInterface
* @throws GuzzleException
*/
public static function getUserWithDriveInformation(
string $baseUrl,
string $xRequestId,
string $user,
string $userPassword,
?string $ofUser = null
): ResponseInterface {
$url = self::getFullUrl($baseUrl, 'users/' . $ofUser . '?%24select=&%24expand=drive');
return HttpRequestHelper::get(
$url,
$xRequestId,
$user,
$userPassword,
);
}
/**
* @param string $baseUrl

View File

@@ -78,3 +78,6 @@ The expected failures in this file are from features in the owncloud/ocis repo.
#### [Requests with invalid credentials do not return CORS headers](https://github.com/owncloud/ocis/issues/5194)
- [apiCors/cors.feature:67](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiCors/cors.feature#L67)
- [apiCors/cors.feature:68](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiCors/cors.feature#L68)
#### [A User can get information of another user with Graph API](https://github.com/owncloud/ocis/issues/5125)
- [apiGraph/getUser.feature:21](https://github.com/owncloud/ocis/blob/master/tests/acceptance/features/apiGraph/getUser.feature#L21)

View File

@@ -51,12 +51,39 @@ Feature: get users
And the last response should be an unauthorized response
Scenario: admin user tries to get drive data of another user
Scenario: admin user tries to get drive information of a user
Given these users have been created with default attributes and without skeleton files:
| username |
| Brian |
When the user "Alice" tries to get information of user "Brian" along with his drive data using Graph API
When the user "Alice" tries to get user "Brian" along with his drive information using Graph API
Then the HTTP status code should be "200"
And the user retrieve API response should contain the following information:
| displayName | id | mail | onPremisesSamAccountName |
| Brian Murphy | %uuid_v4% | brian@example.org | Brian |
# And the drive information of user "Brian" should contain:
# | key | value |
# | driveType | personal |
# | driveAlias | personal/alice |
# | id | %space_id% |
# | name | Brian Murphy |
# | quota@@@state | normal |
# | root@@@webDavUrl | %base_url%/dav/spaces/%space_id% |
Scenario: normal user tries to get hid/her own drive information
Given these users have been created with default attributes and without skeleton files:
| username |
| Brian |
When the user "Brian" tries to get his drive information using Graph API
Then the HTTP status code should be "200"
And the user retrieve API response should contain the following information:
| displayName | id | mail | onPremisesSamAccountName |
| Brian Murphy | %uuid_v4% | brian@example.org | Brian |
# And the drive information of user "Brian" should contain:
# | key | value |
# | driveType | personal |
# | driveAlias | personal/brian |
# | id | %space_id% |
# | name | Brian Murphy |
# | quota@@@state | normal |
# | root@@@webDavUrl | %base_url%/dav/spaces/%space_id% |

View File

@@ -1241,100 +1241,120 @@ class GraphContext implements Context {
}
}
/**
* @When user :user tries to get information of user :ofUser using Graph API
*/
public function userTriesToGetInformationOfUser($user, $ofUser) {
$credentials = $this->getAdminOrUserCredentials($user);
$response = GraphHelper::getUser(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$credentials['username'],
$credentials['password'],
$ofUser
);
$this->featureContext->setResponse($response);
}
/**
* @When user :user tries to get information of user :ofUser using Graph API
*
* @param string $user
* @param string $ofUser
*
* @return void
*/
public function userTriesToGetInformationOfUser($user, $ofUser): void {
$credentials = $this->getAdminOrUserCredentials($user);
$response = GraphHelper::getUser(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$credentials['username'],
$credentials['password'],
$ofUser
);
$this->featureContext->setResponse($response);
}
/**
* @When user :user tries to get all user using the Graph API
*
* @param string $user
*
* @return void
*/
public function userGetsAllUserUsingTheGraphApi(string $user) {
$credentials = $this->getAdminOrUserCredentials($user);
$response = GraphHelper::getUsers(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$credentials['username'],
$credentials['password'],
);
$this->featureContext->setResponse($response);
}
/**
* @When user :user tries to get all user using the Graph API
*
* @param string $user
*
* @return void
*/
public function userGetsAllUserUsingTheGraphApi(string $user) {
$credentials = $this->getAdminOrUserCredentials($user);
$response = GraphHelper::getUsers(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$credentials['username'],
$credentials['password'],
);
$this->featureContext->setResponse($response);
}
/**
* @Then the API response should contain all user with following information:
*
* @param TableNode $table
*
* @throws Exception
* @return void
*/
public function theApiResponseShouldContainAllUserWithFollowingInformation(TableNode $table): void {
$values = $table->getHash();
$apiResponse = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse())['value'];
foreach ($values as $expectedValue) {
$found = false;
foreach ($apiResponse as $key => $actualResponseValue) {
if ($expectedValue["displayName"] === $actualResponseValue["displayName"]) {
$found = true;
$this->checkUserInformation($expectedValue, $actualResponseValue);
unset($apiResponse[$key]);
break;
}
}
if (!$found) {
throw new Exception('User ' . $expectedValue["displayName"] . ' could not be found in the response.');
}
}
}
/**
* @Then the API response should contain all user with following information:
*
* @param TableNode $table
*
* @throws Exception
*/
public function theApiResponseShouldContainAllUserWithFollowingInformation(TableNode $table) {
$values = $table->getHash();
$apiResponse = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse())['value'];
foreach ($values as $expectedValue) {
$found = false;
foreach ($apiResponse as $key => $actualResponseValue) {
if ($expectedValue["displayName"] === $actualResponseValue["displayName"]) {
$found = true;
$this->checkUserInformation($expectedValue, $actualResponseValue);
unset($apiResponse[$key]);
break;
}
}
if (!$found) {
throw new Exception('User ' . $expectedValue["displayName"] . ' could not be found in the response.');
}
}
}
/**
* @param string $user
* @param string|null $ofUser
*
* @return ResponseInterface
* @throws JsonException
* @throws GuzzleException
*/
public function retrieveUserInformationAlongWithDriveUsingGraphApi(
string $user,
?string $ofUser = null
):ResponseInterface {
if ($ofUser === null) {
$ofUser = $user;
}
$credentials = $this->getAdminOrUserCredentials($user);
return GraphHelper::getUserWithDriveInformation(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$credentials["username"],
$credentials["password"],
$ofUser
);
}
/**
* @param string $user
* @param string $ofUser
*
* @return ResponseInterface
* @throws JsonException
* @throws GuzzleException
*/
public function retrieveUserInformationAlongWithDriveUsingGraphApi(
string $user,
string $ofUser
):ResponseInterface {
$credentials = $this->getAdminOrUserCredentials($user);
return GraphHelper::getUserWithDriveInformation(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$credentials["username"],
$credentials["password"],
$ofUser
);
}
/**
*
* @When /^the user "([^"]*)" tries to get user "([^"]*)" along with (his|her) drive information using Graph API$/
*
* @param string $user
* @param string $ofUser
*
* @return void
*/
public function userTriesToGetInformationOfUserAlongWithHisDriveData(string $user, $ofUser) {
$response = $this->retrieveUserInformationAlongWithDriveUsingGraphApi($user, $ofUser);
$this->featureContext->setResponse($response);
}
/**
*
* @When /^the user "([^"]*)" tries to get information of user "([^"]*)" along with (his|her) drive data using Graph API$/
*
* @param string $user
* @param string $ofUser
*
* @return void
*/
public function userTriesToGetInformationOfUserAlongWithHisDriveData(string $user, string $ofUser)
{
$response = $this->retrieveUserInformationAlongWithDriveUsingGraphApi($user, $ofUser);
$this->featureContext->setResponse($response);
}
/**
*
* @When /^the user "([^"]*)" tries to get (his|her) drive information using Graph API$/
*
* @param string $user
*
* @return void
*/
public function userTriesToGetOwnDriveInformation(string $user) {
$response = $this->retrieveUserInformationAlongWithDriveUsingGraphApi($user);
$this->featureContext->setResponse($response);
}
}