Repository navigation
feat(user): group management over HTTP and in the CLI - #5
Merged
Merged
Conversation
GroupRepository could create and delete groups and maintain sub-group
relations, but nothing exposed it: UserController only had GET routes, which
is why the AddGroup/RemoveGroup/UpdateGroup enum slots in the CLI were dead
code and were removed.
Four routes now cover it (Admin-User): POST/DELETE /user/groups and
POST/DELETE /user/groups/{name}/subgroups/{sub}, with the matching UserApi
methods and the CLI commands group_add, group_remove, group_add_subgroup and
group_remove_subgroup.
Deleting a group that some other group contains was broken: deleteOf removed
the groups row but left the group_groups_relation rows behind, so the next
initGroups() dereferenced a missing group (m_groupMap.at) and the process
could not start. It now removes the relations in both directions, scrubs the
in-memory member lists and has a test that restarts the repository on the
same database.
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
performance-enum-size: the values fit into one byte, and the neighbouring components (CommandLineService, EventBusCliComponent) already use std::uint8_t.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Group management was reachable from nowhere:
UserControllerhas onlyGETroutes for groups, which is exactly why theAddGroup/RemoveGroup/UpdateGroupslots inUserManagementCliComponentwere dead code and were removed in #4.GroupRepositoryalready hadcreateOf,deleteOf,addGroupOfandremoveGroupOf— only the glue was missing.Stacked on #4 (
refactor/nolint-cleanup). Retarget tomasteronce #4 is merged.What changed
/user/groupsAdmin-UsercreateOf(Group)/user/groups/{name}Admin-UserdeleteOf(Group)/user/groups/{name}/subgroups/{sub}Admin-UseraddGroupOf(group, sub)/user/groups/{name}/subgroups/{sub}Admin-UserremoveGroupOf(group, sub)Body/response is the existing
GroupDto(group_name,virtual), so no new DTO. Codes: 401 (no token / wrong group), 403 (wrong content type), 400 (broken body, virtual group, missing name), 404 (unknown group), 409 (name exists, or the group still belongs to a user).CLI:
group_add --group -g [--virtual -v],group_remove -g,group_add_subgroup -g -s,group_remove_subgroup -g -s. The enum slots are back, this time with a command and a handler.Swagger documents all four paths.
Bug found on the way
GroupRepository::deleteOf()removed thegroupsrow but left thegroup_groups_relationrows pointing at the deleted group.initGroups()then dereferenced it (m_groupMap.at) and the process could not start again. It now deletes the relations in both directions and scrubs the in-memory member lists; the test builds a second repository on the same database, which is what a restart does.Counter-check: without the fix the new test fails with
map::at.Notes
GroupRepository::createOfrejects them by design, they are defined in code and seeded byVirtualGroupBootstrapPlugin.added/removed: falseinstead of an error.Verification
-Werror), 1311/1311 unit tests.check-format.sh master,check-swagger.sh(49 paths),check-namespace.sh: green.