-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9936 from owncloud/add-tests-for-checking-file-in…
…fo-on-wopi [tests-only][full-ci]Add tests for checking file info on fake office
- Loading branch information
Showing
4 changed files
with
233 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* ownCloud | ||
* | ||
* @author Amrita Shrestha <[email protected]> | ||
* @copyright Copyright (c) 2024 Amrita Shrestha <[email protected]> | ||
* | ||
* This code is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License, | ||
* as published by the Free Software Foundation; | ||
* either version 3 of the License, or any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/> | ||
* | ||
*/ | ||
|
||
use Behat\Behat\Context\Context; | ||
use Behat\Behat\Hook\Scope\BeforeScenarioScope; | ||
use GuzzleHttp\Exception\GuzzleException; | ||
use TestHelpers\HttpRequestHelper; | ||
|
||
/** | ||
* steps needed to re-configure oCIS server | ||
*/ | ||
class CollaborationContext implements Context { | ||
private FeatureContext $featureContext; | ||
private SpacesContext $spacesContext; | ||
|
||
/** | ||
* This will run before EVERY scenario. | ||
* It will set the properties for this object. | ||
* | ||
* @BeforeScenario | ||
* | ||
* @param BeforeScenarioScope $scope | ||
* | ||
* @return void | ||
*/ | ||
public function before(BeforeScenarioScope $scope): void { | ||
// Get the environment | ||
$environment = $scope->getEnvironment(); | ||
// Get all the contexts you need in this context from here | ||
$this->featureContext = $environment->getContext('FeatureContext'); | ||
$this->spacesContext = $environment->getContext('SpacesContext'); | ||
} | ||
|
||
/** | ||
* @When user :user checks the information of file :file of space :space using office :app | ||
* | ||
* @param string $user | ||
* @param string $file | ||
* @param string $space | ||
* @param string $app | ||
* | ||
* @return void | ||
* | ||
* @throws GuzzleException | ||
* @throws JsonException | ||
*/ | ||
public function userChecksTheInformationOfFileOfSpaceUsingOffice(string $user, string $file, string $space, string $app): void { | ||
$fileId = $this->spacesContext->getFileId($user, $space, $file); | ||
$response = \json_decode( | ||
HttpRequestHelper::post( | ||
$this->featureContext->getBaseUrl() . "/app/open?app_name=$app&file_id=$fileId", | ||
$this->featureContext->getStepLineRef(), | ||
$this->featureContext->getActualUsername($user), | ||
$this->featureContext->getPasswordForUser($user), | ||
['Content-Type' => 'application/json'] | ||
)->getBody()->getContents() | ||
); | ||
|
||
$accessToken = $response->form_parameters->access_token; | ||
|
||
// Extract the WOPISrc from the app_url | ||
$parsedUrl = parse_url($response->app_url); | ||
parse_str($parsedUrl['query'], $queryParams); | ||
$wopiSrc = $queryParams['WOPISrc']; | ||
|
||
$this->featureContext->setResponse( | ||
HttpRequestHelper::get( | ||
$wopiSrc . "?access_token=$accessToken", | ||
$this->featureContext->getStepLineRef() | ||
) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
tests/acceptance/features/apiCollaboration/checkFileInfo.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
Feature: check file info with different wopi apps | ||
As a user | ||
I want to request file information on wopi server | ||
So that I can get all the information of a file | ||
|
||
Background: | ||
Given user "Alice" has been created with default attributes and without skeleton files | ||
|
||
|
||
Scenario: check file info with fake office | ||
Given user "Alice" has uploaded file with content "hello world" to "/textfile0.txt" | ||
When user "Alice" checks the information of file "textfile0.txt" of space "Personal" using office "FakeOffice" | ||
Then the HTTP status code should be "200" | ||
And the JSON data of the response should match | ||
""" | ||
{ | ||
"type": "object", | ||
"required": [ | ||
"BaseFileName", | ||
"OwnerId", | ||
"Size", | ||
"UserId", | ||
"Version", | ||
"SupportsCobalt", | ||
"SupportsContainers", | ||
"SupportsDeleteFile", | ||
"SupportsEcosystem", | ||
"SupportsExtendedLockLength", | ||
"SupportsFolders", | ||
"SupportsGetLock", | ||
"SupportsLocks", | ||
"SupportsRename", | ||
"SupportsUpdate", | ||
"SupportsUserInfo", | ||
"UserFriendlyName", | ||
"ReadOnly", | ||
"RestrictedWebViewOnly", | ||
"UserCanAttend", | ||
"UserCanNotWriteRelative", | ||
"UserCanPresent", | ||
"UserCanRename", | ||
"UserCanWrite", | ||
"AllowAdditionalMicrosoftServices", | ||
"AllowExternalMarketplace", | ||
"DisablePrint", | ||
"DisableTranslation", | ||
"BreadcrumbDocName" | ||
], | ||
"properties": { | ||
"BaseFileName": { | ||
"const": "textfile0.txt" | ||
}, | ||
"OwnerId": { | ||
"type": "string" | ||
}, | ||
"Size": { | ||
"const": 11 | ||
}, | ||
"UserId": { | ||
"type": "string" | ||
}, | ||
"Version": { | ||
"type": "string" | ||
}, | ||
"SupportsCobalt": { | ||
"const": false | ||
}, | ||
"SupportsContainers": { | ||
"const": false | ||
}, | ||
"SupportsDeleteFile": { | ||
"const": true | ||
}, | ||
"SupportsEcosystem": { | ||
"const": false | ||
}, | ||
"SupportsExtendedLockLength": { | ||
"const": true | ||
}, | ||
"SupportsFolders": { | ||
"const": false | ||
}, | ||
"SupportsGetLock": { | ||
"const": true | ||
}, | ||
"SupportsLocks": { | ||
"const": true | ||
}, | ||
"SupportsRename": { | ||
"const": true | ||
}, | ||
"SupportsUpdate": { | ||
"const": true | ||
}, | ||
"SupportsUserInfo": { | ||
"const": false | ||
}, | ||
"UserFriendlyName": { | ||
"const": "Alice Hansen" | ||
}, | ||
"ReadOnly": { | ||
"const": false | ||
}, | ||
"RestrictedWebViewOnly": { | ||
"const": false | ||
}, | ||
"UserCanAttend": { | ||
"const": false | ||
}, | ||
"UserCanNotWriteRelative": { | ||
"const": false | ||
}, | ||
"UserCanPresent": { | ||
"const": false | ||
}, | ||
"UserCanRename": { | ||
"const": true | ||
}, | ||
"UserCanWrite": { | ||
"const": true | ||
}, | ||
"AllowAdditionalMicrosoftServices": { | ||
"const": false | ||
}, | ||
"AllowExternalMarketplace": { | ||
"const": false | ||
}, | ||
"DisablePrint": { | ||
"const": false | ||
}, | ||
"DisableTranslation": { | ||
"const": false | ||
}, | ||
"BreadcrumbDocName": { | ||
"const": "textfile0.txt" | ||
} | ||
} | ||
} | ||
""" |