Add tests removed by core PR-40275

update core commit id

update expected to fail file
This commit is contained in:
Swikriti Tripathi
2022-08-11 15:58:13 +05:45
parent 18996ea42a
commit 7c9ecac6fc
4 changed files with 340 additions and 60 deletions
@@ -0,0 +1,227 @@
@api @skipOnOcV10
Feature: sharing
Background:
Given using OCS API version "1"
And these users have been created with default attributes and without skeleton files:
| username |
| Alice |
| Brian |
And using spaces DAV path
Scenario: Correct webdav share-permissions for received file with edit and reshare permissions
Given user "Alice" has uploaded file with content "foo" to "/tmp.txt"
And user "Alice" has shared file "/tmp.txt" with user "Brian"
And user "Brian" has accepted share "/tmp.txt" offered by user "Alice"
When user "Brian" gets the following properties of file "/tmp.txt" inside space "Shares Jail" using the WebDAV API
| propertyName |
| ocs:share-permissions |
Then the HTTP status code should be "207"
And the single response should contain a property "ocs:share-permissions" with value "19"
Scenario: Correct webdav share-permissions for received group shared file with edit and reshare permissions
Given group "grp1" has been created
And user "Brian" has been added to group "grp1"
And user "Alice" has uploaded file with content "foo" to "/tmp.txt"
And user "Alice" has created a share with settings
| path | /tmp.txt |
| shareType | group |
| permissions | share,update,read |
| shareWith | grp1 |
And user "Brian" has accepted share "/tmp.txt" offered by user "Alice"
When user "Brian" gets the following properties of file "/tmp.txt" inside space "Shares Jail" using the WebDAV API
| propertyName |
| ocs:share-permissions |
Then the HTTP status code should be "207"
And the single response should contain a property "ocs:share-permissions" with value "19"
Scenario: Correct webdav share-permissions for received file with edit permissions but no reshare permissions
Given user "Alice" has uploaded file with content "foo" to "/tmp.txt"
And user "Alice" has shared file "tmp.txt" with user "Brian"
And user "Brian" has accepted share "/tmp.txt" offered by user "Alice"
When user "Alice" updates the last share using the sharing API with
| permissions | update,read |
Then the HTTP status code should be "200"
And as user "Brian" file "/tmp.txt" inside space "Shares Jail" should contain a property "ocs:share-permissions" with value "3"
Scenario: Correct webdav share-permissions for received group shared file with edit permissions but no reshare permissions
Given group "grp1" has been created
And user "Brian" has been added to group "grp1"
And user "Alice" has uploaded file with content "foo" to "/tmp.txt"
And user "Alice" has created a share with settings
| path | /tmp.txt |
| shareType | group |
| permissions | update,read |
| shareWith | grp1 |
And user "Brian" has accepted share "/tmp.txt" offered by user "Alice"
When user "Brian" gets the following properties of file "/tmp.txt" inside space "Shares Jail" using the WebDAV API
| propertyName |
| ocs:share-permissions |
Then the HTTP status code should be "207"
And the single response should contain a property "ocs:share-permissions" with value "3"
Scenario: Correct webdav share-permissions for received file with reshare permissions but no edit permissions
Given user "Alice" has uploaded file with content "foo" to "/tmp.txt"
And user "Alice" has shared file "tmp.txt" with user "Brian"
And user "Brian" has accepted share "/tmp.txt" offered by user "Alice"
When user "Alice" updates the last share using the sharing API with
| permissions | share,read |
Then the HTTP status code should be "200"
And as user "Brian" file "/tmp.txt" inside space "Shares Jail" should contain a property "ocs:share-permissions" with value "17"
Scenario: Correct webdav share-permissions for received group shared file with reshare permissions but no edit permissions
Given group "grp1" has been created
And user "Brian" has been added to group "grp1"
And user "Alice" has uploaded file with content "foo" to "/tmp.txt"
And user "Alice" has created a share with settings
| path | /tmp.txt |
| shareType | group |
| permissions | share,read |
| shareWith | grp1 |
And user "Brian" has accepted share "/tmp.txt" offered by user "Alice"
When user "Brian" gets the following properties of file "/tmp.txt" inside space "Shares Jail" using the WebDAV API
| propertyName |
| ocs:share-permissions |
Then the HTTP status code should be "207"
And the single response should contain a property "ocs:share-permissions" with value "17"
Scenario: Correct webdav share-permissions for received folder with all permissions
Given user "Alice" has created folder "/tmp"
And user "Alice" has shared file "/tmp" with user "Brian"
And user "Brian" has accepted share "/tmp" offered by user "Alice"
When user "Brian" gets the following properties of folder "/tmp" inside space "Shares Jail" using the WebDAV API
| propertyName |
| ocs:share-permissions |
Then the HTTP status code should be "207"
And the single response should contain a property "ocs:share-permissions" with value "31"
Scenario: Correct webdav share-permissions for received group shared folder with all permissions
Given group "grp1" has been created
And user "Brian" has been added to group "grp1"
And user "Alice" has created folder "/tmp"
And user "Alice" has created a share with settings
| path | tmp |
| shareType | group |
| shareWith | grp1 |
And user "Brian" has accepted share "/tmp" offered by user "Alice"
When user "Brian" gets the following properties of folder "/tmp" inside space "Shares Jail" using the WebDAV API
| propertyName |
| ocs:share-permissions |
Then the HTTP status code should be "207"
And the single response should contain a property "ocs:share-permissions" with value "31"
Scenario: Correct webdav share-permissions for received folder with all permissions but edit
Given user "Alice" has created folder "/tmp"
And user "Alice" has shared file "/tmp" with user "Brian"
And user "Brian" has accepted share "/tmp" offered by user "Alice"
When user "Alice" updates the last share using the sharing API with
| permissions | share,delete,create,read |
Then the HTTP status code should be "200"
And as user "Brian" folder "/tmp" inside space "Shares Jail" should contain a property "ocs:share-permissions" with value "29"
Scenario: Correct webdav share-permissions for received group shared folder with all permissions but edit
Given group "grp1" has been created
And user "Brian" has been added to group "grp1"
And user "Alice" has created folder "/tmp"
And user "Alice" has created a share with settings
| path | tmp |
| shareType | group |
| shareWith | grp1 |
| permissions | share,delete,create,read |
And user "Brian" has accepted share "/tmp" offered by user "Alice"
When user "Brian" gets the following properties of folder "/tmp" inside space "Shares Jail" using the WebDAV API
| propertyName |
| ocs:share-permissions |
Then the HTTP status code should be "207"
And the single response should contain a property "ocs:share-permissions" with value "29"
Scenario: Correct webdav share-permissions for received folder with all permissions but create
Given user "Alice" has created folder "/tmp"
And user "Alice" has shared file "/tmp" with user "Brian"
And user "Brian" has accepted share "/tmp" offered by user "Alice"
When user "Alice" updates the last share using the sharing API with
| permissions | share,delete,update,read |
Then the HTTP status code should be "200"
And as user "Brian" folder "/tmp" inside space "Shares Jail" should contain a property "ocs:share-permissions" with value "27"
Scenario: Correct webdav share-permissions for received group shared folder with all permissions but create
Given group "grp1" has been created
And user "Brian" has been added to group "grp1"
And user "Alice" has created folder "/tmp"
And user "Alice" has created a share with settings
| path | tmp |
| shareType | group |
| shareWith | grp1 |
| permissions | share,delete,update,read |
And user "Brian" has accepted share "/tmp" offered by user "Alice"
When user "Brian" gets the following properties of folder "/tmp" inside space "Shares Jail" using the WebDAV API
| propertyName |
| ocs:share-permissions |
Then the HTTP status code should be "207"
And the single response should contain a property "ocs:share-permissions" with value "27"
Scenario: Correct webdav share-permissions for received folder with all permissions but delete
Given user "Alice" has created folder "/tmp"
And user "Alice" has shared file "/tmp" with user "Brian"
And user "Brian" has accepted share "/tmp" offered by user "Alice"
When user "Alice" updates the last share using the sharing API with
| permissions | share,create,update,read |
Then the HTTP status code should be "200"
And as user "Brian" folder "/tmp" inside space "Shares Jail" should contain a property "ocs:share-permissions" with value "23"
Scenario: Correct webdav share-permissions for received group shared folder with all permissions but delete
Given group "grp1" has been created
And user "Brian" has been added to group "grp1"
And user "Alice" has created folder "/tmp"
And user "Alice" has created a share with settings
| path | tmp |
| shareType | group |
| shareWith | grp1 |
| permissions | share,create,update,read |
And user "Brian" has accepted share "/tmp" offered by user "Alice"
When user "Brian" gets the following properties of folder "/tmp" inside space "Shares Jail" using the WebDAV API
| propertyName |
| ocs:share-permissions |
Then the HTTP status code should be "207"
And the single response should contain a property "ocs:share-permissions" with value "23"
Scenario: Correct webdav share-permissions for received folder with all permissions but share
Given user "Alice" has created folder "/tmp"
And user "Alice" has shared file "/tmp" with user "Brian"
And user "Brian" has accepted share "/tmp" offered by user "Alice"
When user "Alice" updates the last share using the sharing API with
| permissions | change |
Then the HTTP status code should be "200"
And as user "Brian" folder "/tmp" inside space "Shares Jail" should contain a property "ocs:share-permissions" with value "15"
Scenario: Correct webdav share-permissions for received group shared folder with all permissions but share
Given group "grp1" has been created
And user "Brian" has been added to group "grp1"
And user "Alice" has created folder "/tmp"
And user "Alice" has created a share with settings
| path | tmp |
| shareType | group |
| shareWith | grp1 |
| permissions | change |
And user "Brian" has accepted share "/tmp" offered by user "Alice"
When user "Brian" gets the following properties of folder "/tmp" inside space "Shares Jail" using the WebDAV API
| propertyName |
| ocs:share-permissions |
Then the HTTP status code should be "207"
And the single response should contain a property "ocs:share-permissions" with value "15"
@@ -28,6 +28,7 @@ use Behat\Gherkin\Node\TableNode;
use GuzzleHttp\Exception\GuzzleException;
use Psr\Http\Message\ResponseInterface;
use TestHelpers\HttpRequestHelper;
use TestHelpers\WebDavHelper;
use TestHelpers\SetupHelper;
use TestHelpers\GraphHelper;
use PHPUnit\Framework\Assert;
@@ -54,6 +55,11 @@ class SpacesContext implements Context {
*/
private TrashbinContext $trashbinContext;
/**
* @var WebDavPropertiesContext
*/
private WebDavPropertiesContext $webDavPropertiesContext;
/**
* @var string
*/
@@ -386,6 +392,7 @@ class SpacesContext implements Context {
$this->featureContext = $environment->getContext('FeatureContext');
$this->ocsContext = $environment->getContext('OCSContext');
$this->trashbinContext = $environment->getContext('TrashbinContext');
$this->webDavPropertiesContext = $environment->getContext('WebDavPropertiesContext');
// Run the BeforeScenario function in OCSContext to set it up correctly
$this->ocsContext->before($scope);
$this->baseUrl = \trim($this->featureContext->getBaseUrl(), "/");
@@ -1318,7 +1325,7 @@ class SpacesContext implements Context {
): array {
$spaceId = $this->getResponseSpaceId();
//if we are using that step the second time in a scenario e.g. 'But ... should not'
//then don't parse the result again, because the result in a ResponseInterface
//then don't parse the result again, because the result is in a ResponseInterface
if (empty($this->getResponseXml())) {
$this->setResponseXml(
HttpRequestHelper::parseResponseAsXml($this->featureContext->getResponse())
@@ -2979,4 +2986,91 @@ class SpacesContext implements Context {
Assert::assertEmpty($responseArray, __METHOD__ . ' Response should be empty');
}
}
/**
* @When /^user "([^"]*)" gets the following properties of (?:file|folder|entry|resource) "([^"]*)" inside space "([^"]*)" using the WebDAV API$/
*
* @param string $user
* @param string $resourceName
* @param string $spaceName
* @param TableNode|null $propertiesTable
*
* @return void
*
* @throws Exception|GuzzleException
*/
public function userGetsTheFollowingPropertiesOfFileInsideSpaceUsingTheWebdavApi(
string $user,
string $resourceName,
string $spaceName,
TableNode $propertiesTable
):void {
$space = $this->getSpaceByName($user, $spaceName);
$properties = null;
$fullUrl = $space["root"]["webDavUrl"] . '/' . ltrim($resourceName, "/");
$this->featureContext->verifyTableNodeColumns($propertiesTable, ["propertyName"]);
$this->featureContext->verifyTableNodeColumnsCount($propertiesTable, 1);
if ($propertiesTable instanceof TableNode) {
foreach ($propertiesTable->getColumnsHash() as $row) {
$properties[] = $row["propertyName"];
}
}
$body = WebDavHelper::getBodyForPropfind($properties);
$headers['Depth'] = '1';
$this->featureContext->setResponse(
$this->sendPropfindRequestToUrl(
$fullUrl,
$user,
$this->featureContext->getPasswordForUser($user),
'',
$headers,
$body
)
);
$responseXml = $this->featureContext->getResponseXml(null, __METHOD__);
$this->featureContext->setResponseXmlObject($responseXml);
}
/**
* @Then /^as user "([^"]*)" (?:file|folder|entry|resource) "([^"]*)" inside space "([^"]*)" should contain a property "([^"]*)" with value "([^"]*)"$/
*
* @param string $user
* @param string $resourceName
* @param string $spaceName
* @param string $property
* @param string $expectedValue
*
* @return void
*
* @throws Exception|GuzzleException
*/
public function asUserFileInsideSpaceShouldContainAPropertyWithValue(
string $user,
string $resourceName,
string $spaceName,
string $property,
string $expectedValue
):void {
$space = $this->getSpaceByName($user, $spaceName);
$fullUrl = $space["root"]["webDavUrl"] . '/' . ltrim($resourceName, "/");
$body = WebDavHelper::getBodyForPropfind([$property]);
$headers['Depth'] = '1';
$this->featureContext->setResponse(
$this->sendPropfindRequestToUrl(
$fullUrl,
$user,
$this->featureContext->getPasswordForUser($user),
'',
$headers,
$body
)
);
$responseXml = $this->featureContext->getResponseXml(null, __METHOD__);
$this->featureContext->setResponseXmlObject($responseXml);
$this->webDavPropertiesContext->checkSingleResponseContainsAPropertyWithValueAndAlternative(
$property,
$expectedValue,
$expectedValue
);
}
}