Merge pull request #9912 from owncloud/app-endpoint

[tests-only][full-ci]Added test for public user using `/app/open` endpoint
This commit is contained in:
Sawjan Gurung
2024-08-29 17:48:42 +05:45
committed by GitHub
2 changed files with 79 additions and 0 deletions

View File

@@ -1281,6 +1281,34 @@ class FeatureContext extends BehatVariablesContext {
$this->setResponse($this->sendingToWithDirectUrl($user, $verb, $url));
}
/**
* @When the public sends HTTP method :method to URL :url with password :password
*
* @param string $method
* @param string $url
* @param string $password
*
* @return void
*/
public function thePublicSendsHttpMethodToUrlWithPassword(string $method, string $url, string $password): void {
$password = $this->getActualPassword($password);
$token = $this->shareNgGetLastCreatedLinkShareToken();
$fullUrl = $this->getBaseUrl() . $url;
$headers = [
'Public-Token' => $token
];
$this->setResponse(
HttpRequestHelper::sendRequest(
$fullUrl,
$this->getStepLineRef(),
$method,
"public",
$password,
$headers
)
);
}
/**
* @When /^user "([^"]*)" sends HTTP method "([^"]*)" to URL "([^"]*)" with headers$/
*

View File

@@ -171,3 +171,54 @@ Feature: collaboration (wopi)
| app-endpoint |
| /app/open?file_id=<<FILEID>>&app_name=FakeOffice |
| /app/open?file_id=<<FILEID>> |
Scenario Outline: public user opens file with .odt extension
Given user "Alice" has uploaded file "filesForUpload/simple.odt" to "simple.odt"
And we save it into "FILEID"
And user "Alice" has created the following resource link share:
| resource | simple.odt |
| space | Personal |
| permissionsRole | view |
| password | %public% |
When the public sends HTTP method "POST" to URL "<app-endpoint>" with password "%public%"
Then the HTTP status code should be "200"
And the JSON data of the response should match
"""
{
"type": "object",
"required": [
"app_url",
"method",
"form_parameters"
],
"properties": {
"app_url": {
"type": "string",
"pattern": "^.*\\?WOPISrc=.*wopi%2Ffiles%2F[a-fA-F0-9]{64}$"
},
"method": {
"const": "POST"
},
"form_parameters": {
"type": "object",
"required": [
"access_token",
"access_token_ttl"
],
"properties": {
"access_token": {
"type": "string"
},
"access_token_ttl": {
"type": "string"
}
}
}
}
}
"""
Examples:
| app-endpoint |
| /app/open?file_id=<<FILEID>>&app_name=FakeOffice |
| /app/open?file_id=<<FILEID>> |