[tests-only][full-ci]Added tests for setting password in a public share (#8079) (#8138)

* Added tests for set/update for password for public link

* Added assertion step for password update

* Rebase and refactor setPassword step

Signed-off-by: sagargurung1001@gmail.com <sagargurung1001@gmail.com>

* Review Address

* Review Address

* Fix style

---------

Signed-off-by: sagargurung1001@gmail.com <sagargurung1001@gmail.com>
This commit is contained in:
Sagar Gurung
2024-01-08 10:43:54 +05:45
committed by GitHub
parent 2b78753a12
commit 85d4598907
6 changed files with 230 additions and 15 deletions
@@ -269,18 +269,60 @@ class SharingNgContext implements Context {
throw new Error('Expiration date or role is missing to update for share link!');
}
$this->featureContext->setResponse(
GraphHelper::updateLinkShare(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$spaceId,
$itemId,
\json_encode($body),
$this->featureContext->shareNgGetLastCreatedLinkShareID()
)
$response = GraphHelper::updateLinkShare(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$spaceId,
$itemId,
\json_encode($body),
$this->featureContext->shareNgGetLastCreatedLinkShareID()
);
$this->featureContext->setResponse($response);
}
/**
* @When user :user sets/updates the following password for the last link share using the Graph API:
*
* @param string $user
* @param TableNode|null $body
*
* @return void
* @throws Exception
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function userSetsOrUpdatesFollowingPasswordForLastLinkShareUsingTheGraphApi(string $user, TableNode $body):void {
$bodyRows = $body->getRowsHash();
$space = $bodyRows['space'];
$resourceType = $bodyRows['resourceType'];
$resource = $bodyRows['resource'];
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];
if ($resourceType === 'folder') {
$itemId = $this->spacesContext->getResourceId($user, $space, $resource);
} else {
$itemId = $this->spacesContext->getFileId($user, $space, $resource);
}
if (\array_key_exists('password', $bodyRows)) {
$body = [
"password" => $this->featureContext->getActualPassword($bodyRows['password']),
];
} else {
throw new Error('Password is missing to set for share link!');
}
$response = GraphHelper::setPassword(
$this->featureContext->getBaseUrl(),
$this->featureContext->getStepLineRef(),
$user,
$this->featureContext->getPasswordForUser($user),
$spaceId,
$itemId,
\json_encode($body),
$this->featureContext->shareNgGetLastCreatedLinkShareID()
);
$this->featureContext->setResponse($response);
}
/**