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

occ files:scan fix groups with comma, plus tests #31719

Merged
merged 4 commits into from
Aug 6, 2018
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
8 changes: 4 additions & 4 deletions apps/files/lib/Command/Scan.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ protected function configure() {
'Limit rescan to this path, e.g., --path="/alice/files/Music", the user_id is determined by the path and the user_id parameter and --all are ignored.'
)
->addOption(
'groups',
'group',
'g',
InputArgument::OPTIONAL,
'Scan user(s) under the group(s). This option can be used as --groups=foo,bar to scan groups foo and bar'
InputOption::VALUE_IS_ARRAY|InputOption::VALUE_REQUIRED,
'Scan user(s) under the group(s). This option can be used as --group=foo --group=bar to scan groups foo and bar'
)
->addOption(
'quiet',
Expand Down Expand Up @@ -276,7 +276,7 @@ protected function getAllUsersFromGroup($group) {

protected function execute(InputInterface $input, OutputInterface $output) {
$inputPath = $input->getOption('path');
$groups = $input->getOption('groups') ? \explode(',', $input->getOption('groups')) : [];
$groups = $input->getOption('group');
$shouldRepairStoragesIndividually = (bool) $input->getOption('repair');

if (\count($groups) >= 1) {
Expand Down
17 changes: 9 additions & 8 deletions apps/files/tests/Command/ScanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ protected function tearDown() {

public function dataInput() {
return [
[['--groups' => 'haystack'], 'Group name haystack doesn\'t exist'],
[['--groups' => 'group1'], 'Starting scan for user 1 out of 1 (user1)'],
[['--group' => ['haystack']], 'Group name haystack doesn\'t exist'],
[['--group' => ['haystack,barn']], 'Group name haystack,barn doesn\'t exist'],
[['--group' => ['group1']], 'Starting scan for user 1 out of 1 (user1)'],
[['user_id' => ['user1']], 'Starting scan for user 1 out of 1 (user1)'],
[['user_id' => ['user2']], 'Starting scan for user 1 out of 1 (user2)']
];
Expand All @@ -158,7 +159,7 @@ public function testCommandInput($input, $expectedOutput) {

public function userInputData() {
return [
[['--groups' => 'group1'], 'Starting scan for user 1 out of 200']
[['--group' => ['group1']], 'Starting scan for user 1 out of 200']
];
}

Expand All @@ -171,7 +172,7 @@ public function testGroupPaginationForUsers($input, $expectedOutput) {
//First we populate the users
$user = 'user';
$numberOfUsersInGroup = 210;
for ($i = 2; $i <= 210; $i++) {
for ($i = 2; $i <= $numberOfUsersInGroup; $i++) {
$userObj = $this->createUser($user.$i);
$this->groupManager->get('group1')->addUser($userObj);
}
Expand All @@ -180,13 +181,13 @@ public function testGroupPaginationForUsers($input, $expectedOutput) {
$output = $this->commandTester->getDisplay();
$this->assertContains($expectedOutput, $output);
//If pagination works then below assert shouldn't fail
$this->assertNotContains('Starting scan for user 1 out of 210', $output);
$this->assertNotContains("Starting scan for user 1 out of $numberOfUsersInGroup", $output);
}

public function multipleGroupTest() {
return [
[['--groups' => 'group1,group2'], ''],
[['--groups' => 'group1,group2,group3'], '']
[['--group' => ['group1,x','group2']], ''],
[['--group' => ['group1','group2,x','group3']], '']
];
}

Expand All @@ -196,7 +197,7 @@ public function multipleGroupTest() {
*/
public function testMultipleGroups($input) {
//Create 10 users in each group
$groups = \explode(',', $input['--groups']);
$groups = $input['--group'];
$user = "user";
$userObj = [];
for ($i = 1; $i <= (10 * \count($groups)); $i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ So that I can more easily manage access to resources by groups rather than indiv
| group_id | comment |
| new-group | dash |
| the.group | dot |
| left,right | comma |
| España | special European characters |
| नेपाली | Unicode group name |
| 0 | The "false" group |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ So that I can give a user access to the resources of the group
| group_id | comment |
| new-group | dash |
| the.group | dot |
| left,right | comma |
| España | special European characters |
| नेपाली | Unicode group name |
| 0 | The "false" group |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ So that I can remove unnecessary groups
| group_id | comment |
| new-group | dash |
| the.group | dot |
| left,right | comma |
| España | special European characters |
| नेपाली | Unicode group name |
| 0 | The "false" group |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ So that I can manage user access to group resources
| group_id | comment |
| new-group | dash |
| the.group | dot |
| left,right | comma |
| España | special European characters |
| नेपाली | Unicode group name |
| 0 | The "false" group |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ So that I can more easily manage access to resources by groups rather than indiv
| group_id | comment |
| new-group | dash |
| the.group | dot |
| left,right | comma |
| España | special European characters |
| नेपाली | Unicode group name |
| 0 | The "false" group |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ So that I can give a user access to the resources of the group
| group_id | comment |
| new-group | dash |
| the.group | dot |
| left,right | comma |
| España | special European characters |
| नेपाली | Unicode group name |
| 0 | The "false" group |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ So that I can remove unnecessary groups
| group_id | comment |
| new-group | dash |
| the.group | dot |
| left,right | comma |
| España | special European characters |
| नेपाली | Unicode group name |
| 0 | The "false" group |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ So that I can manage user access to group resources
| group_id | comment |
| new-group | dash |
| the.group | dot |
| left,right | comma |
| España | special European characters |
| नेपाली | Unicode group name |
| 0 | The "false" group |
Expand Down
9 changes: 9 additions & 0 deletions tests/lib/Share20/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,15 @@ public function dataIsSharingDisabledForUser() {
// New list only groups in common
$data[] = ['yes', \json_encode(['group1', 'group2']), null, ['group2'], true];

// New list partly in common, group names containing comma
$data[] = ['yes', \json_encode(['group1,a', 'group2']), null, ['group1,a', 'group3'], true];
$data[] = ['yes', \json_encode(['group1,a', 'group2,b']), null, ['group1,a', 'group3'], true];
$data[] = ['yes', \json_encode(['group1,a', 'group2']), null, ['group1,a', 'group3,c'], true];

// New list only groups in common, group names containing comma
$data[] = ['yes', \json_encode(['group1', 'group2,a']), null, ['group2,a'], true];
$data[] = ['yes', \json_encode(['group1,a', 'group2,a']), null, ['group2,a'], true];

return $data;
}

Expand Down