Skip to content

Commit

Permalink
Merge pull request #37018 from owncloud/manageOptionsForMount
Browse files Browse the repository at this point in the history
[Tests-Only] Add acceptance test to manage options for local storage mount
  • Loading branch information
phil-davis authored Feb 28, 2020
2 parents 738f9b2 + 26d76c7 commit a1f36fd
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 0 deletions.
115 changes: 115 additions & 0 deletions tests/acceptance/features/bootstrap/OccContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -1563,6 +1563,121 @@ public function theFollowingShouldBeIncludedInTheConfigurationOfLocalStorage($lo
Assert::assertTrue($isStorageEntryListed, "Expected local storage '$localStorage' not found ");
}

/**
* @When the administrator adds an option with key :key and value :value for the local storage mount :localStorage
*
* @param string $key
* @param string $value
* @param string $localStorage
*
* @return void
* @throws Exception
*/
public function adminAddsOptionForLocalStorageMountUsingTheOccCommand($key, $value, $localStorage) {
$mountId = $this->featureContext->getStorageId($localStorage);
$this->featureContext->runOcc(
[
"files_external:option",
$mountId,
$key,
$value
]
);
$this->theCommandShouldHaveBeenSuccessful();
}

/**
* @Then the following should be included in the options of local storage :localStorage:
*
* @param string $localStorage
* @param TableNode $table
*
* @return void
* @throws Exception
*/
public function theFollowingShouldBeIncludedInTheOptionsOfLocalStorage($localStorage, TableNode $table) {
$expectedOptions = $table->getColumnsHash();
foreach ($expectedOptions as $expectedOptionEntry) {
Assert::assertArrayHasKey(
'options',
$expectedOptionEntry,
__METHOD__
. " The provided expected option '"
. \implode(', ', $expectedOptionEntry)
. "' do not have key 'option'"
);
}
$commandOutput = \json_decode($this->featureContext->getStdOutOfOccCommand());
$isStorageEntryListed = false;
foreach ($commandOutput as $listedStorageEntry) {
if ($listedStorageEntry->mount_point === $localStorage) {
$isStorageEntryListed = true;
$options = $listedStorageEntry->options;
$optionsSplitted = \explode(', ', $options);
foreach ($expectedOptions as $expectedOptionArray) {
foreach ($expectedOptionArray as $expectedOptionEntry) {
Assert::assertContains(
$expectedOptionEntry,
$optionsSplitted,
__METHOD__
. " $expectedOptionEntry is not contained in '"
. \implode(', ', $optionsSplitted)
. "' , but was expected to be."
);
}
}
break;
}
}
Assert::assertTrue($isStorageEntryListed, "Expected local storage '$localStorage' not found ");
}

/**
* @Then the following should not be included in the options of local storage :localStorage:
*
* @param string $localStorage
* @param TableNode $table
*
* @return void
* @throws Exception
*/
public function theFollowingShouldNotBeIncludedInTheOptionsOfLocalStorage($localStorage, TableNode $table) {
$expectedOptions = $table->getColumnsHash();
foreach ($expectedOptions as $expectedOptionEntry) {
Assert::assertArrayHasKey(
'options',
$expectedOptionEntry,
__METHOD__
. " The provided expected option '"
. \implode(', ', $expectedOptionEntry)
. "' do not have key 'options'"
);
}
$commandOutput = \json_decode($this->featureContext->getStdOutOfOccCommand());
$isStorageEntryListed = false;
foreach ($commandOutput as $listedStorageEntry) {
if ($listedStorageEntry->mount_point === $localStorage) {
$isStorageEntryListed = true;
$options = $listedStorageEntry->options;
$optionsSplitted = \explode(', ', $options);
foreach ($expectedOptions as $expectedOptionArray) {
foreach ($expectedOptionArray as $expectedOptionEntry) {
Assert::assertNotContains(
$expectedOptionEntry,
$optionsSplitted,
__METHOD__
. " $expectedOptionEntry is contained in '"
. \implode(', ', $optionsSplitted)
. "' , but was not expected to be."
);
}
}
break;
}
}
Assert::assertTrue($isStorageEntryListed, "Expected local storage '$localStorage' not found ");
}

/**
* @When the administrator deletes local storage :folder using the occ command
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@cli @skipOnLDAP @local_storage
Feature: manage options for a mount using occ command
As an admin
I want to add options for a local storage mount
So that I can manage options for the mount

Background:
Given the administrator has created the local storage mount "local_storage2"
And the administrator has created the local storage mount "local_storage3"
And the administrator has uploaded file with content "this is a file in local storage2" to "/local_storage2/file-in-local-storage.txt"
And the administrator has uploaded file with content "this is a file in local storage3" to "/local_storage3/new-file"

Scenario: add options for a local storage mount
When the administrator adds an option with key "enable_sharing" and value "true" for the local storage mount "local_storage2"
And the administrator adds an option with key "read-only" and value "1" for the local storage mount "local_storage2"
And the administrator adds an option with key "enable_sharing" and value "false" for the local storage mount "local_storage3"
And the administrator adds an option with key "read-only" and value "1" for the local storage mount "local_storage3"
And the administrator lists the local storage using the occ command
Then the following should be included in the options of local storage "/local_storage2":
| options |
| enable_sharing: true |
| read-only: 1 |
And the following should be included in the options of local storage "/local_storage3":
| options |
| read-only: 1 |
But the following should not be included in the options of local storage "/local_storage3":
| options |
| enable_sharing: false |

0 comments on commit a1f36fd

Please sign in to comment.