Drive infor assertion

This commit is contained in:
sagargurung1001@gmail.com
2022-12-07 16:28:25 +05:45
committed by Phil Davis
parent 265db41819
commit 46575abe11
2 changed files with 56 additions and 30 deletions

View File

@@ -60,22 +60,28 @@ Feature: get users
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 response should contain the following drive information:
| driveType | personal |
| driveAlias | personal/brian |
| name | Brian Murphy |
And the user retrieve API response should contain the following drive information:
# | driveType | personal |
# | driveAlias | personal/brian |
# | id | %space_id% |
# | name | Brian Murphy |
| owner@@@user@@@id | %user_id% |
# | quota@@@state | normal |
# | root@@@id | %space_id% |
# | root@@@webDavUrl | %base_url%/dav/spaces/%space_id% |
# | webUrl | %base_url%/f/%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 response should contain the following drive information:
| driveType | personal |
| driveAlias | personal/brian |
| name | Brian Murphy |
# 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 response should contain the following drive information:
# | driveType | personal |
# | driveAlias | personal/brian |
# | name | Brian Murphy |

View File

@@ -1364,23 +1364,43 @@ class GraphContext implements Context {
}
/**
* @Then the response should contain the following drive information:
* @param array $expectedDriveInformation
* @param array $actualValueDriveInformation
*
* @throws GuzzleException
* @return void
*/
public function theResponseShouldContainTheFollowingDriveInformation(TableNode $table)
{
$rows = $table->getRowsHash();
$responseAPI = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse())['drive'];
foreach (array_keys($rows) as $keyName) {
Assert::assertEquals(
$rows[$keyName],
$responseAPI[$keyName],
__METHOD__ .
' Expected ' . $keyName . 'to have value' . $responseAPI[$keyName]
. ' but got ' . $rows[$keyName]
public function checkUserDriveInformation(array $expectedDriveInformation, array $actualValueDriveInformation):void {
foreach (array_keys($expectedDriveInformation) as $keyName) {
// break the segment with @@@ here
$separatedKey = explode("@@@",$keyName);
$actualKeyAvalue = null;
$actualKeyAvalue = $actualValueDriveInformation['owner'];
var_dump(
$actualKeyAvalue
);
foreach ($separatedKey as $key) {
// this loop sets and get the actual keyvalue from the actual API response
$actualKeyAvalue = $actualValueDriveInformation[$key];
}
var_dump(
$actualKeyAvalue
);
}
}
/**
* @Then the user retrieve API response should contain the following drive information:
*/
public function theResponseShouldContainTheFollowingDriveInformation(TableNode $table)
{
$expectedDriveInformation = $table->getRowsHash();
// array of user drive information (Personal Drive Information Only)
$actualDriveInformation = $this->featureContext->getJsonDecodedResponse($this->featureContext->getResponse())['drive'];
$this->checkUserDriveInformation($expectedDriveInformation, $actualDriveInformation);
}
}