Skip to content

Groups for occ command and UI testing#28190

Merged
PVince81 merged 5 commits into
masterfrom
occ-manage-groups
Jun 30, 2017
Merged

Groups for occ command and UI testing#28190
PVince81 merged 5 commits into
masterfrom
occ-manage-groups

Conversation

@phil-davis

Copy link
Copy Markdown
Contributor

Description

  • Add group add, delete and removeuser to occ command (group add can also add users to a group)
  • Add support for creating and removing groups withing the UI testing framework
  • Use this to change/add some sharing autocompletion tests to include sharing with groups as well as users

Related Issue

Addresses #20629 to provide occ group command
for which some initial work happened in #21627

Also part of providing base infrastructure for UI testing #27858

Motivation and Context

  • It is useful to be able to manage groups from occ as well as users
  • UI testing needs to be able to easily create groups and put users into groups during scenario setup
  • File Firewall needs this to be able to test group rules

How Has This Been Tested?

Self-testing - Travis does it

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Once this is accepted, the documentation of the occ group command needs to be done.

Signed-off-by: Phil Davis <phil@jankaritech.com>
Signed-off-by: Phil Davis <phil@jankaritech.com>
Signed-off-by: Phil Davis <phil@jankaritech.com>
@phil-davis

phil-davis commented Jun 22, 2017

Copy link
Copy Markdown
Contributor Author

@SergioBertolinSG this implements issue #20629 which you raised and is in 10.0 backlog. Having group commands in occ is very useful for the UI testing scenario steps, and will be useful for other things also (even sysadmins who want to create and manage groups from the command line)

@phil-davis

Copy link
Copy Markdown
Contributor Author

@PVince81 @DeepDiver1975 this expands functionality of occ to be able to manage groups and their members, so I called you in for review here.
The functionality is useful for acceptance testing - a simple and well-defined way to set up groups and membership ready for testing their behavior. But also would become available to real-life sysdamins who use occ. Actually a place I used to work at wanted to manage group membership for certain groups by script that could read from some outside file and make the oC groups and their membership match. This occ group functionality would have made it easy.

@phil-davis phil-davis mentioned this pull request Jun 27, 2017
@phil-davis phil-davis added this to the 10.1 milestone Jun 27, 2017
@felixboehm

Copy link
Copy Markdown
Contributor

@PVince81 please review and set proper milestone. Thanks

Comment thread core/Command/Group/RemoveUser.php Outdated
$group->removeUser($user);
$output->writeln('User "' . $user->getUID() . '" removed from group "' . $group->getGID() . '"');
} else {
$output->writeln('<error>User "' . $userName . '" could not be found in group "' . $group->getGID() . '"</error>');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this maybe affect the command's return code ? should we abort ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder what to do in these sort of cases. The sysadmin has asked to remove user1 from group1. Actually user1 is already not in group1, so the requested state is already the case and the occ command is a NOOP.
Do we tell the sysadmin "the user is already not in the group"?
Do we mark the text as an error? (because actually what the sysadmin asked is done)
Do we return an error code, or success?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure, maybe check what other system tools do. Does "groupdel" on Linux return an error code ?

@PVince81

Copy link
Copy Markdown
Contributor

As a CLI user I'd be confused as to what command to use for adding users to a group. I know that add does it too but seeing it, it's not clear that the command can do both.

I'd prefer having separate commands with clearer names:

  • group:add
  • group:delete
  • group:add-member
  • group:remove-member

Comment thread core/Command/Group/Delete.php Outdated
$group = $this->groupManager->get($groupName);
if (is_null($group)) {
$output->writeln('<error>Group does not exist</error>');
return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return error code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar thing here - should this text even be highlighted as an error?
The sysadmin asked to delete the group, the group is not even existing, so it is indeed deleted.

return;
}

$output->writeln('<error>The specified group could not be deleted. Please check the logs.</error>');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return error code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I better return an error code here - this one is the system having trouble!

Comment thread core/Command/Group/Add.php Outdated
$output->writeln('The group "' . $group->getGID() . '" already exists');
}

$users = $input->getOption('user');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move this to a separate command, much clearer from a user's perspective.

Also I guess that the current impl would not let you add users to an existing group as you'd get "Group already exists" which sounds like an error even though the code carries on.

@PVince81 PVince81 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments.

Make sure to return an error code in all execute commands when non-zero. It can help with scripting.

Also note that runOcc can check said error code in case it's useful for testing.

Signed-off-by: Phil Davis <phil@jankaritech.com>
Signed-off-by: Phil Davis <phil@jankaritech.com>
@phil-davis

Copy link
Copy Markdown
Contributor Author

I can do group:add group:addmember group:removemember and group:delete OK from the command line.
If I try to add a group that exists, or delete a group that does not exist I get an error.
If I try to add/remove members from a group that does not exist I get an error.
If I try to addmember or removemember using a user name that does not exist, I get an error.

If I addmember and some users are already in the group, I do not emit an error. IMHO that is an OK condition - a scripting person can do group:addmember for all the users that they want to be in the group and do not need to try and thin if they are already in the group.

Similarly, if I removemember and some users were already removed from the group, I do not emit an error. That lets a scripting person do removemember for any user(s) that they want to make sure are not in the group without worrying if they were already removed.

Let's see if CI is happy...

@individual-it individual-it left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@PVince81 PVince81 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@PVince81 PVince81 merged commit 3df9dc9 into master Jun 30, 2017
@PVince81 PVince81 deleted the occ-manage-groups branch June 30, 2017 08:59
@PVince81

Copy link
Copy Markdown
Contributor

@phil-davis please backport to stable10.

Ignoring the old rule "don't backport new features". cc @DeepDiver1975 @felixboehm

@phil-davis

Copy link
Copy Markdown
Contributor Author

Actually, the reason to backport this is that

  1. it provides infrastructure that allows both core and apps to implement UI tests that deal with groups
  2. apps need to be able to find this infrastructure when being tested against stable10

the fact that it also provides an enhancement/feature to the occ command, which end-users will see and can use in 10.0.3, is actually just "collateral damage" :)

@phil-davis

Copy link
Copy Markdown
Contributor Author

and this has been, and will be, a common thing for both new test infrastructure and new tests. Generally-speaking it will be "a good thing" that a more extensive set of automated tests runs in the 10.0.* series.

@PVince81

Copy link
Copy Markdown
Contributor

@phil-davis thanks, makes sense

@phil-davis

Copy link
Copy Markdown
Contributor Author

@PVince81 to backport, it needs #28188 backport to be merged first into stable10.

@mmattel

mmattel commented Jul 4, 2017

Copy link
Copy Markdown
Contributor

@PVince81 @phil-davis @settermjd
Please add a documentation PR for this occ command.
I do not see a reference nor a PR in the documentation repository...

phil-davis added a commit to owncloud-archive/documentation that referenced this pull request Jul 5, 2017
that were added by owncloud/core#28190
and backported to stable10 by owncloud/core#28276
so the occ group commands will become available from 10.0.3
@phil-davis

Copy link
Copy Markdown
Contributor Author

Doc PR owncloud-archive/documentation#3201 created.

@mmattel

mmattel commented Jul 5, 2017

Copy link
Copy Markdown
Contributor

Q: maybe I missed that:
why don't we have a parameter for listing existing groups and listing existing users in a particular group?

@phil-davis

Copy link
Copy Markdown
Contributor Author

@mmattel that is a good question that I also asked myself. But I did not want to start expanding beyond what I really needed because then people might review and say "why did you add xyz?"

IMHO it would be very handy for oC admins to be able to list users and groups from the command line.

@mmattel

mmattel commented Jul 5, 2017

Copy link
Copy Markdown
Contributor

@phil-davis mind to add this list functinality?

@lock

lock Bot commented Aug 2, 2019

Copy link
Copy Markdown

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock Bot locked as resolved and limited conversation to collaborators Aug 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants