Merge pull request #5349 from owncloud/tests/propfind-public-link-port

[tests-only][full-ci] Port PROPFIND tests to the master
This commit is contained in:
Artur Neumann
2023-01-06 16:01:13 +05:45
committed by GitHub
4 changed files with 114 additions and 6 deletions
+4 -4
View File
@@ -144,6 +144,10 @@ class HttpRequestHelper {
$debugRequests = false;
}
if ($debugRequests) {
self::debugRequest($request, $user, $password);
}
// The exceptions that might happen here include:
// ConnectException - in that case there is no response. Don't catch the exception.
// RequestException - if there is something in the response then pass it back.
@@ -160,10 +164,6 @@ class HttpRequestHelper {
}
}
if ($debugRequests) {
self::debugRequest($request, $user, $password);
}
return $response;
}
@@ -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"