add PROPFIND tests to public link share

This commit is contained in:
Saw-jan
2023-01-06 15:01:18 +05:45
parent d564851d47
commit 613d41477b
3 changed files with 110 additions and 2 deletions
@@ -1658,4 +1658,55 @@ class PublicWebDavContext implements Context {
$this->featureContext = $environment->getContext('FeatureContext');
$this->occContext = $environment->getContext('OccContext');
}
/**
* @When /^the public sends "([^"]*)" request to the last public link share using the (old|new) public WebDAV API(?: with password "([^"]*)")?$/
*
* @param string $method
* @param string $publicWebDAVAPIVersion
* @param string $password
*
* @return void
* @throws GuzzleException
*/
public function publicSendsRequestToLastPublicShare(string $method, string $publicWebDAVAPIVersion, ?string $password = ''):void {
if (OcisHelper::isTestingOnOcisOrReva() && $publicWebDAVAPIVersion === "old") {
return;
}
if ($method === "PROPFIND") {
$body = '<?xml version="1.0"?>
<d:propfind xmlns:d="DAV:" xmlns:oc="http://owncloud.org/ns">
<d:prop>
<d:resourcetype/>
<oc:public-link-item-type/>
<oc:public-link-permission/>
<oc:public-link-expiration/>
<oc:public-link-share-datetime/>
<oc:public-link-share-owner/>
</d:prop>
</d:propfind>';
}
$token = $this->featureContext->getLastPublicShareToken();
$davPath = WebDavHelper::getDavPath(
null,
null,
"public-files-$publicWebDAVAPIVersion"
);
$username = $this->getUsernameForPublicWebdavApi(
$token,
$password,
$publicWebDAVAPIVersion
);
$fullUrl = $this->featureContext->getBaseUrl() . "/$davPath$token";
$response = HttpRequestHelper::sendRequest(
$fullUrl,
$this->featureContext->getStepLineRef(),
$method,
$username,
$password,
null,
$body
);
$this->featureContext->setResponse($response);
}
}
@@ -886,7 +886,15 @@ class WebDavPropertiesContext implements Context {
$pattern = $this->featureContext->substituteInLineCodes(
$pattern,
$user,
['preg_quote' => ['/']]
['preg_quote' => ['/']],
[
[
"code" => "%public_token%",
"function" =>
[$this->featureContext, "getLastPublicShareToken"],
"parameter" => []
],
]
);
Assert::assertMatchesRegularExpression(
$pattern,
@@ -47,4 +47,53 @@ Feature: PROPFIND
Examples:
| dav_path | depth_infinity_allowed | depth | http_status |
| /remote.php/dav/spaces/%spaceid% | 1 | 0 | 207 |
| /remote.php/dav/spaces/%spaceid% | 1 | infinity | 207 |
| /remote.php/dav/spaces/%spaceid% | 1 | infinity | 207 |
Scenario: send PROPFIND request to a public link
Given user "Alice" has been created with default attributes and without skeleton files
And user "Alice" has created folder "/PARENT"
And user "Alice" has created a public link share with settings
| path | /PARENT |
| permissions | read |
When the public sends "PROPFIND" request to the last public link share using the new public WebDAV API
Then the HTTP status code should be "207"
And the value of the item "//d:href" in the response should match "/%base_path%\/remote.php\/dav\/public-files\/%public_token%\/$/"
And the value of the item "//oc:public-link-share-owner" in the response should be "Alice"
Scenario: send PROPFIND request to a public link shared with password
Given user "Alice" has been created with default attributes and without skeleton files
And user "Alice" has created folder "/PARENT"
And user "Alice" has created a public link share with settings
| path | /PARENT |
| permissions | read |
| password | 1111 |
When the public sends "PROPFIND" request to the last public link share using the new public WebDAV API with password "1111"
Then the HTTP status code should be "207"
And the value of the item "//d:href" in the response should match "/%base_path%\/remote.php\/dav\/public-files\/%public_token%\/$/"
And the value of the item "//oc:public-link-share-owner" in the response should be "Alice"
Scenario: send PROPFIND request to a public link shared with password (request without password)
Given user "Alice" has been created with default attributes and without skeleton files
And user "Alice" has created folder "/PARENT"
And user "Alice" has created a public link share with settings
| path | /PARENT |
| permissions | read |
| password | 1111 |
When the public sends "PROPFIND" request to the last public link share using the new public WebDAV API
Then the HTTP status code should be "401"
And the value of the item "/d:error/s:exception" in the response should be "Sabre\DAV\Exception\NotAuthenticated"
Scenario: send PROPFIND request to a public link shared with password (request with incorrect password)
Given user "Alice" has been created with default attributes and without skeleton files
And user "Alice" has created folder "/PARENT"
And user "Alice" has created a public link share with settings
| path | /PARENT |
| permissions | read |
| password | 1111 |
When the public sends "PROPFIND" request to the last public link share using the new public WebDAV API with password "1234"
Then the HTTP status code should be "401"
And the value of the item "/d:error/s:exception" in the response should be "Sabre\DAV\Exception\NotAuthenticated"