Skip to content

Commit

Permalink
tests for files_external:list with applicable users and groups
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed Jan 28, 2020
1 parent 920de6f commit 45d24b7
Show file tree
Hide file tree
Showing 2 changed files with 168 additions and 19 deletions.
96 changes: 89 additions & 7 deletions tests/acceptance/features/bootstrap/OccContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,16 @@ public function listLocalStorageMount() {
$this->invokingTheCommand('files_external:list --output=json');
}

/**
* List created local storage mount with --short
*
* @return void
* @throws Exception
*/
public function listLocalStorageMountShort() {
$this->invokingTheCommand('files_external:list --short --output=json');
}

/**
* @When the administrator enables DAV tech_preview
*
Expand Down Expand Up @@ -1194,10 +1204,20 @@ public function theAdminHasAddedRemovedTheApplicableUserForMountUsingTheOccComma
* @return void
* @throws Exception
*/
public function userListsLocalStorageMountUsingTheOccCommand() {
public function adminListsLocalStorageMountUsingTheOccCommand() {
$this->listLocalStorageMount();
}

/**
* @When the administrator lists the local storage with --short using the occ command
*
* @return void
* @throws Exception
*/
public function adminListsLocalStorageMountShortUsingTheOccCommand() {
$this->listLocalStorageMountShort();
}

/**
* @Then the following local storage should exist
*
Expand Down Expand Up @@ -1247,18 +1267,80 @@ public function theFollowingLocalStoragesShouldNotExist(TableNode $mountPoints)
* @throws Exception
*/
public function theFollowingLocalStorageShouldBeListed(TableNode $table) {
$this->featureContext->verifyTableNodeColumns(
$table,
['MountPoint', 'ApplicableUsers', 'ApplicableGroups'],
['Storage', 'AuthenticationType', 'Configuration', 'Options', 'Auth', 'Type']);
$expectedLocalStorages = $table->getColumnsHash();
$commandOutput = \json_decode($this->featureContext->getStdOutOfOccCommand());
foreach ($expectedLocalStorages as $expectedStorageEntry) {
$isStorageEntryListed = false;
foreach ($commandOutput as $listedStorageEntry) {
if ($expectedStorageEntry["MountPoint"] === $listedStorageEntry->mount_point) {
Assert::assertEquals($expectedStorageEntry['Storage'], $listedStorageEntry->storage, "Storage column does not have the expected value");
Assert::assertEquals($expectedStorageEntry['AuthenticationType'], $listedStorageEntry->authentication_type, "AuthenticationType column does not have the expected value");
Assert::assertStringStartsWith($expectedStorageEntry['Configuration'], $listedStorageEntry->configuration, "Configuration column does not have the expected value");
Assert::assertEquals($expectedStorageEntry['Options'], $listedStorageEntry->options, "Options column does not have the expected value");
Assert::assertEquals($expectedStorageEntry['ApplicableUsers'], $listedStorageEntry->applicable_users, "ApplicableUsers column does not have the expected value");
Assert::assertEquals($expectedStorageEntry['ApplicableGroups'], $listedStorageEntry->applicable_groups, "ApplicableGroups column does not have the expected value");
if (isset($expectedStorageEntry['Storage'])) {
Assert::assertEquals(
$expectedStorageEntry['Storage'],
$listedStorageEntry->storage,
"Storage column does not have the expected value for storage "
. $expectedStorageEntry['MountPoint']
);
}
if (isset($expectedStorageEntry['AuthenticationType'])) {
Assert::assertEquals(
$expectedStorageEntry['AuthenticationType'],
$listedStorageEntry->authentication_type,
"AuthenticationType column does not have the expected value for storage "
. $expectedStorageEntry['MountPoint']
);
}
if (isset($expectedStorageEntry['Auth'])) {
Assert::assertEquals(
$expectedStorageEntry['Auth'],
$listedStorageEntry->auth,
"Auth column does not have the expected value for storage "
. $expectedStorageEntry['MountPoint']
);
}
if (isset($expectedStorageEntry['Configuration'])) {
Assert::assertStringStartsWith(
$expectedStorageEntry['Configuration'],
$listedStorageEntry->configuration,
"Configuration column does not start with the expected value for storage "
. $expectedStorageEntry['MountPoint']
);
}
if (isset($expectedStorageEntry['Options'])) {
Assert::assertEquals(
$expectedStorageEntry['Options'],
$listedStorageEntry->options,
"Options column does not have the expected value for storage "
. $expectedStorageEntry['MountPoint']
);
}
if (isset($expectedStorageEntry['ApplicableUsers'])) {
Assert::assertEquals(
$expectedStorageEntry['ApplicableUsers'],
$listedStorageEntry->applicable_users,
"ApplicableUsers column does not have the expected value for storage "
. $expectedStorageEntry['MountPoint']
);
}
if (isset($expectedStorageEntry['ApplicableGroups'])) {
Assert::assertEquals(
$expectedStorageEntry['ApplicableGroups'],
$listedStorageEntry->applicable_groups,
"ApplicableGroups column does not have the expected value for storage "
. $expectedStorageEntry['MountPoint']
);
}
if (isset($expectedStorageEntry['Type'])) {
Assert::assertEquals(
$expectedStorageEntry['Type'],
$listedStorageEntry->type,
"Type column does not have the expected value for storage "
. $expectedStorageEntry['MountPoint']
);
}
$isStorageEntryListed = true;
}
}
Expand Down
91 changes: 79 additions & 12 deletions tests/acceptance/features/cliLocalStorage/listLocalStorage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,88 @@ Feature: list created local storage from the command line

Background:
Given the administrator has created the local storage mount "local_storage2"
And the administrator has created the local storage mount "new_local_storage"
And the administrator has uploaded file with content "this is a file in local storage" to "/local_storage2/file-in-local-storage.txt"
And the administrator has uploaded file with content "new file" to "/new_local_storage/new-file"
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: List the created local storage
When the administrator lists the local storage using the occ command
Then the following local storage should exist
| localStorage |
| local_storage2 |
| new_local_storage |
Then the following local storage should be listed:
| MountPoint | Storage | AuthenticationType | Configuration | Options | ApplicableUsers | ApplicableGroups |
| /local_storage | Local | None | datadir: | | All | |
| /local_storage2 | Local | None | datadir: | | All | |
| /local_storage3 | Local | None | datadir: | | All | |

Scenario: Test the other columns of listed local storage
Scenario: List local storage with applicable users
Given these users have been created with default attributes and without skeleton files:
| username |
| user0 |
| user1 |
| user2 |
And the administrator has added user "user0" as the applicable user for local storage mount "local_storage2"
And the administrator has added user "user1" as the applicable user for local storage mount "local_storage3"
And the administrator has added user "user2" as the applicable user for local storage mount "local_storage3"
When the administrator lists the local storage using the occ command
Then the following local storage should be listed:
| MountPoint | Storage | AuthenticationType | Configuration | Options | ApplicableUsers | ApplicableGroups |
| /local_storage2 | Local | None | datadir: | | All | |
| /new_local_storage | Local | None | datadir: | | All | |
| /local_storage | Local | None | datadir: | | All | |
| MountPoint | Storage | AuthenticationType | Configuration | Options | ApplicableUsers | ApplicableGroups |
| /local_storage | Local | None | datadir: | | All | |
| /local_storage2 | Local | None | datadir: | | user0 | |
| /local_storage3 | Local | None | datadir: | | user1, user2 | |

Scenario: List local storage with applicable groups
Given group "grp1" has been created
And group "grp2" has been created
And group "grp3" has been created
And the administrator has added group "grp1" as the applicable group for local storage mount "local_storage2"
And the administrator has added group "grp2" as the applicable group for local storage mount "local_storage3"
And the administrator has added group "grp3" as the applicable group for local storage mount "local_storage3"
When the administrator lists the local storage using the occ command
Then the following local storage should be listed:
| MountPoint | Storage | AuthenticationType | Configuration | Options | ApplicableUsers | ApplicableGroups |
| /local_storage | Local | None | datadir: | | All | |
| /local_storage2 | Local | None | datadir: | | | grp1 |
| /local_storage3 | Local | None | datadir: | | | grp2, grp3 |

Scenario: List local storage with applicable users and groups
Given these users have been created with default attributes and without skeleton files:
| username |
| user0 |
| user1 |
| user2 |
And group "grp1" has been created
And group "grp2" has been created
And group "grp3" has been created
And the administrator has added user "user0" as the applicable user for local storage mount "local_storage2"
And the administrator has added user "user1" as the applicable user for local storage mount "local_storage3"
And the administrator has added user "user2" as the applicable user for local storage mount "local_storage3"
And the administrator has added group "grp1" as the applicable group for local storage mount "local_storage2"
And the administrator has added group "grp2" as the applicable group for local storage mount "local_storage3"
And the administrator has added group "grp3" as the applicable group for local storage mount "local_storage3"
When the administrator lists the local storage using the occ command
Then the following local storage should be listed:
| MountPoint | Storage | AuthenticationType | Configuration | Options | ApplicableUsers | ApplicableGroups |
| /local_storage | Local | None | datadir: | | All | |
| /local_storage2 | Local | None | datadir: | | user0 | grp1 |
| /local_storage3 | Local | None | datadir: | | user1, user2 | grp2, grp3 |

Scenario: Short list of local storage with applicable users and groups
Given these users have been created with default attributes and without skeleton files:
| username |
| user0 |
| user1 |
| user2 |
And group "grp1" has been created
And group "grp2" has been created
And group "grp3" has been created
And the administrator has added user "user0" as the applicable user for local storage mount "local_storage2"
And the administrator has added user "user1" as the applicable user for local storage mount "local_storage3"
And the administrator has added user "user2" as the applicable user for local storage mount "local_storage3"
And the administrator has added group "grp1" as the applicable group for local storage mount "local_storage2"
And the administrator has added group "grp2" as the applicable group for local storage mount "local_storage3"
And the administrator has added group "grp3" as the applicable group for local storage mount "local_storage3"
When the administrator lists the local storage with --short using the occ command
Then the following local storage should be listed:
| MountPoint | Auth | ApplicableUsers | ApplicableGroups | Type |
| /local_storage | User | All | | Admin |
| /local_storage2 | User | user0 | grp1 | Admin |
| /local_storage3 | User | user1, user2 | grp2, grp3 | Admin |

0 comments on commit 45d24b7

Please sign in to comment.