add PROPFIND tests to public link share
This commit is contained in:
3 files changed
+109
-1
No files matched your search
@@ -1658,4 +1658,55 @@ class PublicWebDavContext implements Context {
|
|||||||
$this->featureContext = $environment->getContext('FeatureContext');
|
$this->featureContext = $environment->getContext('FeatureContext');
|
||||||
$this->occContext = $environment->getContext('OccContext');
|
$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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -865,7 +865,15 @@ class WebDavPropertiesContext implements Context {
|
|||||||
$pattern = $this->featureContext->substituteInLineCodes(
|
$pattern = $this->featureContext->substituteInLineCodes(
|
||||||
$pattern,
|
$pattern,
|
||||||
$user,
|
$user,
|
||||||
['preg_quote' => ['/']]
|
['preg_quote' => ['/']],
|
||||||
|
[
|
||||||
|
[
|
||||||
|
"code" => "%public_token%",
|
||||||
|
"function" =>
|
||||||
|
[$this->featureContext, "getLastPublicShareToken"],
|
||||||
|
"parameter" => []
|
||||||
|
],
|
||||||
|
]
|
||||||
);
|
);
|
||||||
Assert::assertMatchesRegularExpression(
|
Assert::assertMatchesRegularExpression(
|
||||||
$pattern,
|
$pattern,
|
||||||
|
|||||||
@@ -48,3 +48,52 @@ Feature: PROPFIND
|
|||||||
| dav_path | depth_infinity_allowed | depth | http_status |
|
| dav_path | depth_infinity_allowed | depth | http_status |
|
||||||
| /remote.php/dav/spaces/%spaceid% | 1 | 0 | 207 |
|
| /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"
|
||||||
Reference in new issue
Block a user