add tests for setting pasword-on-share-link (#9078)
This commit is contained in:
@@ -2208,4 +2208,37 @@ class GraphHelper {
|
|||||||
$body
|
$body
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $baseUrl
|
||||||
|
* @param string $xRequestId
|
||||||
|
* @param string $user
|
||||||
|
* @param string $password
|
||||||
|
* @param string $spaceId
|
||||||
|
* @param mixed $body
|
||||||
|
* @param string $permissionsId
|
||||||
|
*
|
||||||
|
* @return ResponseInterface
|
||||||
|
* @throws GuzzleException
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static function setDriveLinkSharePassword(
|
||||||
|
string $baseUrl,
|
||||||
|
string $xRequestId,
|
||||||
|
string $user,
|
||||||
|
string $password,
|
||||||
|
string $spaceId,
|
||||||
|
$body,
|
||||||
|
string $permissionsId
|
||||||
|
): ResponseInterface {
|
||||||
|
$url = self::getBetaFullUrl($baseUrl, "drives/$spaceId/root/permissions/$permissionsId/setPassword");
|
||||||
|
return HttpRequestHelper::post(
|
||||||
|
$url,
|
||||||
|
$xRequestId,
|
||||||
|
$user,
|
||||||
|
$password,
|
||||||
|
self::getRequestHeaders(),
|
||||||
|
$body
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2237,3 +2237,66 @@ Feature: Create a share link for a resource
|
|||||||
| upload |
|
| upload |
|
||||||
| createOnly |
|
| createOnly |
|
||||||
| blocksDownload |
|
| blocksDownload |
|
||||||
|
|
||||||
|
@env-config
|
||||||
|
Scenario: set password on a existing link share of a project-space drive using root endpoint
|
||||||
|
Given the following configs have been set:
|
||||||
|
| config | value |
|
||||||
|
| OCIS_SHARING_PUBLIC_SHARE_MUST_HAVE_PASSWORD | false |
|
||||||
|
And using spaces DAV path
|
||||||
|
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
|
||||||
|
And user "Alice" has created a space "projectSpace" with the default quota using the Graph API
|
||||||
|
And user "Alice" has uploaded a file inside space "projectSpace" with content "to share" to "textfile.txt"
|
||||||
|
And user "Alice" has created the following space link share:
|
||||||
|
| space | projectSpace |
|
||||||
|
| permissionsRole | view |
|
||||||
|
When user "Alice" sets the following password for the last space link share using root endpoint of the Graph API:
|
||||||
|
| space | projectSpace |
|
||||||
|
| password | %public% |
|
||||||
|
Then the HTTP status code should be "200"
|
||||||
|
And the JSON data of the response should match
|
||||||
|
"""
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"hasPassword"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"hasPassword": {
|
||||||
|
"const": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
And the public should be able to download file "textfile.txt" from the last link share with password "%public%" and the content should be "to share"
|
||||||
|
|
||||||
|
|
||||||
|
Scenario: update password on a existing link share of a project-space drive using root endpoint
|
||||||
|
And using spaces DAV path
|
||||||
|
And the administrator has assigned the role "Space Admin" to user "Alice" using the Graph API
|
||||||
|
And user "Alice" has created a space "projectSpace" with the default quota using the Graph API
|
||||||
|
And user "Alice" has uploaded a file inside space "projectSpace" with content "to share" to "textfile.txt"
|
||||||
|
And user "Alice" has created the following space link share:
|
||||||
|
| space | projectSpace |
|
||||||
|
| permissionsRole | view |
|
||||||
|
| password | $heLlo*1234* |
|
||||||
|
When user "Alice" sets the following password for the last space link share using root endpoint of the Graph API:
|
||||||
|
| space | projectSpace |
|
||||||
|
| password | %public% |
|
||||||
|
Then the HTTP status code should be "200"
|
||||||
|
And the JSON data of the response should match
|
||||||
|
"""
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"hasPassword"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"hasPassword": {
|
||||||
|
"const": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
And the public should be able to download file "textfile.txt" from the last link share with password "%public%" and the content should be "to share"
|
||||||
|
And the public download of file "textfile.txt" from the last link share with password "$heLlo*1234*" should fail with HTTP status code "401" using shareNg
|
||||||
|
|||||||
@@ -1283,4 +1283,37 @@ class SharingNgContext implements Context {
|
|||||||
|
|
||||||
$this->featureContext->setResponse($response);
|
$this->featureContext->setResponse($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @When user :user sets the following password for the last space link share using root endpoint of the Graph API:
|
||||||
|
*
|
||||||
|
* @param string $user
|
||||||
|
* @param TableNode $body
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @throws GuzzleException
|
||||||
|
*/
|
||||||
|
public function userSetsTheFollowingPasswordForTheLastSpaceLinkShareUsingRootEndpointOfTheGraphAPI(string $user, TableNode $body): void {
|
||||||
|
$rows = $body->getRowsHash();
|
||||||
|
Assert::assertArrayNotHasKey("resource", $rows, "'resource' should not be provided in the data-table while setting password in space shared link");
|
||||||
|
|
||||||
|
Assert::assertArrayHasKey("password", $rows, "'password' is missing in the data-table");
|
||||||
|
$body = [
|
||||||
|
"password" => $this->featureContext->getActualPassword($rows['password']),
|
||||||
|
];
|
||||||
|
|
||||||
|
$space = $rows['space'];
|
||||||
|
$spaceId = ($this->spacesContext->getSpaceByName($user, $space))["id"];
|
||||||
|
|
||||||
|
$response = GraphHelper::setDriveLinkSharePassword(
|
||||||
|
$this->featureContext->getBaseUrl(),
|
||||||
|
$this->featureContext->getStepLineRef(),
|
||||||
|
$user,
|
||||||
|
$this->featureContext->getPasswordForUser($user),
|
||||||
|
$spaceId,
|
||||||
|
\json_encode($body),
|
||||||
|
$this->featureContext->shareNgGetLastCreatedLinkShareID()
|
||||||
|
);
|
||||||
|
$this->featureContext->setResponse($response);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user