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 test to manage options for local storage mount #37018

Merged
merged 1 commit into from
Feb 28, 2020
Merged
Show file tree
Hide file tree
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
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":
jasson99 marked this conversation as resolved.
Show resolved Hide resolved
| 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":
jasson99 marked this conversation as resolved.
Show resolved Hide resolved
| options |
| enable_sharing: false |