Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tests-Only] Add acceptance tests to share top-level of read-only storage #37262

Merged
merged 1 commit into from
May 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/acceptance/config/behat.yml
Original file line number Diff line number Diff line change
@@ -481,6 +481,7 @@ default:
- WebUIHelpAndTipsContext:
- WebUIGeneralContext:
- WebUILoginContext:
- WebUISharingContext:
- OccContext:

webUIComments:
38 changes: 38 additions & 0 deletions tests/acceptance/features/bootstrap/OccContext.php
Original file line number Diff line number Diff line change
@@ -189,6 +189,31 @@ public function setExtStorageReadOnlyUsingTheOccCommand($mountPoint, $setting =
);
}

/**
* @param string $mountPoint
* @param boolean $setting
*
* @return void
* @throws Exception
*/
public function setExtStorageSharingUsingTheOccCommand($mountPoint, $setting = true) {
$command = "files_external:option";

$mountId = $this->featureContext->getStorageId($mountPoint);

$key = "enable_sharing";

if ($setting) {
$value = "true";
} else {
$value = "false";
}

$this->invokingTheCommand(
"$command $mountId $key $value"
);
}

/**
* @param string $mountPoint
* @param string $setting "never" (switch it off) otherwise "Once every direct access"
@@ -935,6 +960,19 @@ public function theAdminHasSetTheExtStorageToReadOnly($mountPoint) {
$this->theCommandShouldHaveBeenSuccessful();
}

/**
* @Given the administrator has set the external storage :mountPoint to sharing
*
* @param string $mountPoint
*
* @return void
* @throws Exception
*/
public function theAdminHasSetTheExtStorageToSharing($mountPoint) {
$this->setExtStorageSharingUsingTheOccCommand($mountPoint);
$this->theCommandShouldHaveBeenSuccessful();
}

/**
* @When the administrator sets the external storage :mountPoint to be never scanned automatically using the occ command
*
Original file line number Diff line number Diff line change
@@ -185,13 +185,26 @@ public function theAdministratorDeletesTheLastCreatedLocalStorageMountUsingTheWe
}

/**
* @Given the administrator has enabled read-only for the last created local storage mount using the webUI
* @When the administrator enables read-only for the last created local storage mount using the webUI
*
* @return void
*/
public function theAdministratorEnablesReadonlyForTheLastCreatedLocalStorageMountUsingTheWebui() {
$this->adminStorageSettingsPage->openMountOptions($this->getSession());
$this->adminStorageSettingsPage->enableReadonlyMountOption($this->getSession());
$this->adminStorageSettingsPage->openMountOptions($this->getSession());
}

/**
* @Given the administrator has enabled sharing for the last created local storage mount using the webUI
*
* @return void
*/
public function theAdministratorHasEnabledSharingForTheLastCreatedLocalStorageMountUsingTheWebui() {
$this->adminStorageSettingsPage->openMountOptions($this->getSession());
$this->adminStorageSettingsPage->enableSharingMountOption($this->getSession());
$this->adminStorageSettingsPage->openMountOptions($this->getSession());
}

/**
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@cli @skipOnLDAP @local_storage
Feature: create local storage and enable read-only and sharing from the command line
As an admin
I want to create read-only local storage and enable sharing from the command line
So that local folders on my server can be made visible but read-only to users of ownCloud

Background:
Given these users have been created with default attributes and without skeleton files:
| username |
| user0 |
| user1 |
And the administrator has created the local storage mount "local_storage1"
And the administrator has uploaded file with content "this is a file in local storage" to "/local_storage1/file-in-local-storage.txt"
And the administrator has added user "user0" as the applicable user for the last local storage mount
And the administrator has set the external storage "local_storage1" to read-only
And the administrator has set the external storage "local_storage1" to sharing

Scenario: applicable user is not able to share with all permissions the top-level of read-only storage
When user "user0" shares folder "local_storage1" with user "user1" using the sharing API
Then the HTTP status code should be "200"
And the OCS status code should be "404"
And the OCS status message should be "Cannot set the requested share permissions for local_storage1"

Scenario: applicable user is able to share with read permissions the top-level of read-only storage
When user "user0" shares folder "local_storage1" with user "user1" with permissions "read" using the sharing API
Then the HTTP status code should be "200"
And the OCS status code should be "100"
And as "user1" folder "local_storage1" should exist

Scenario: applicable user is able to share with read permissions the file inside the top-level of read-only storage
When user "user0" shares file "/local_storage1/file-in-local-storage.txt" with user "user1" with permissions "read" using the sharing API
Then the HTTP status code should be "200"
And the OCS status code should be "100"
And as "user1" file "file-in-local-storage.txt" should exist

Scenario: applicable user is able to share with default permissions the file inside the top-level of read-only storage
When user "user0" shares file "/local_storage1/file-in-local-storage.txt" with user "user1" using the sharing API
Then the HTTP status code should be "200"
And the OCS status code should be "100"
And as "user1" file "file-in-local-storage.txt" should exist
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@cli @skipOnLDAP @local_storage
Feature: create local storage and enable sharing from the command line
As an admin
I want to create read-write local storage and enable sharing from the command line
So that local folders on my server can be made visible and read-write to users of ownCloud

Background:
Given these users have been created with default attributes and without skeleton files:
| username |
| user0 |
| user1 |
And the administrator has created the local storage mount "local_storage1"
And the administrator has uploaded file with content "this is a file in local storage" to "/local_storage1/file-in-local-storage.txt"
And the administrator has added user "user0" as the applicable user for the last local storage mount
And the administrator has set the external storage "local_storage1" to sharing

Scenario: applicable user is able to share with all permissions the top-level of read-write storage
When user "user0" shares folder "local_storage1" with user "user1" using the sharing API
Then the HTTP status code should be "200"
And the OCS status code should be "100"
And as "user1" folder "local_storage1" should exist

Scenario: applicable user is able to share the file inside the top-level of read-write storage
When user "user0" shares file "/local_storage1/file-in-local-storage.txt" with user "user1" with permissions "read" using the sharing API
Then the HTTP status code should be "200"
And the OCS status code should be "100"
And as "user1" file "file-in-local-storage.txt" should exist
21 changes: 21 additions & 0 deletions tests/acceptance/features/lib/AdminStorageSettingsPage.php
Original file line number Diff line number Diff line change
@@ -58,6 +58,7 @@ class AdminStorageSettingsPage extends OwncloudPage {
protected $lastCreatedMountDeleteButtonXpath = "//tr[@id='addMountPoint']/preceding-sibling::tr[1]/td[@class='remove']";
protected $lastCreatedMountOptionsButtonXpath = "//tr[@id='addMountPoint']/preceding-sibling::tr[1]/td[@class='mountOptionsToggle']";
protected $setReadonlyId = "mountOptionsReadonly";
protected $setSharingId = "mountOptionsSharing";
protected $mountPointNameXpath = "//tr[@class='local'][%s]//input[@placeholder='Folder name']";

/**
@@ -324,6 +325,26 @@ public function enableReadonlyMountOption(Session $session) {
}
}

/**
* enable sharing mount option
*
* @param Session $session
*
* @return void
*/
public function enableSharingMountOption(Session $session) {
$checkCheckbox = $this->findById($this->setSharingId);
$this->assertElementNotNull(
$checkCheckbox,
__METHOD__ .
" id " . $this->setSharingId .
" could not find checkbox for sharing mount option"
);
if ((!($checkCheckbox->isChecked()))) {
$checkCheckbox->click();
}
}

/**
* toggle checkbox
*
Original file line number Diff line number Diff line change
@@ -163,3 +163,22 @@ Feature: admin storage settings
Then the last created local storage mount should be listed on the webUI
And the user re-logs in as "user1" using the webUI
And folder "local_storage1" should be listed on the webUI

@issue-36803
Scenario: applicable user is not able to share top-level of read-only storage
Given these users have been created with default attributes and without skeleton files:
| username |
| user0 |
| user1 |
And the administrator has enabled the external storage
And the administrator has browsed to the admin storage settings page
And the administrator has created the local storage mount "local_storage1" from the admin storage settings page
And the administrator has added user "user0" as the applicable user for the last local storage mount from the admin storage settings page
And the administrator has enabled read-only for the last created local storage mount using the webUI
And the administrator has enabled sharing for the last created local storage mount using the webUI
And the user has re-logged in as "user0" using the webUI
When the user shares folder "local_storage1" with user "User One" using the webUI
Then notifications should be displayed on the webUI with the text
| Cannot set the requested share permissions for local_storage1 |
# And as "user1" folder "local_storage1" should exist
And as "user1" folder "local_storage1" should not exist