fix(admin-delegation): Prevent delegation to group if delegation alre…#144
Closed
printminion-co wants to merge 1 commit intomasterfrom
Closed
fix(admin-delegation): Prevent delegation to group if delegation alre…#144printminion-co wants to merge 1 commit intomasterfrom
printminion-co wants to merge 1 commit intomasterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where admin delegation could be assigned multiple times to the same group for the same setting class, creating duplicate database entries. The fix adds duplicate detection by checking for existing assignments before creation and throwing a ConflictException when duplicates are attempted.
Key Changes:
- Introduced
ConflictExceptionfor duplicate assignment detection - Modified
AuthorizedGroupService::create()to check for existing assignments before inserting - Updated the
admin-delegation:addcommand to handle conflicts gracefully with exit code 4 - Added comprehensive test coverage for the duplicate prevention logic
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/settings/lib/Service/ConflictException.php | New exception class for handling duplicate assignment conflicts |
| apps/settings/lib/Service/AuthorizedGroupService.php | Added duplicate checking logic before creating new authorized group assignments |
| apps/settings/lib/Command/AdminDelegation/Add.php | Added exception handling for conflicts with user-friendly warning message |
| apps/settings/tests/Service/AuthorizedGroupServiceTest.php | Added unit tests for duplicate prevention and updated existing tests to mock duplicate checks |
| apps/settings/tests/Command/AdminDelegation/AddTest.php | Added tests for conflict handling in the CLI command |
| apps/settings/tests/Integration/DuplicateAssignmentIntegrationTest.php | New integration test suite verifying end-to-end duplicate prevention |
| apps/settings/composer/composer/autoload_classmap.php | Updated autoloader mapping for new ConflictException class |
| apps/settings/composer/composer/autoload_static.php | Updated static autoloader for new ConflictException class |
| $this->expectException(\OCP\AppFramework\Db\DoesNotExistException::class); | ||
| try { | ||
| $this->service->find($initialId); | ||
| } catch (\OCA\Settings\Service\NotFoundException $e) { |
There was a problem hiding this comment.
The test expects DoesNotExistException but catches NotFoundException. This mismatch will cause the test to fail if DoesNotExistException is thrown. Either remove the expectException call since you're using try-catch, or catch the expected exception type.
Suggested change
| } catch (\OCA\Settings\Service\NotFoundException $e) { | |
| } catch (\OCP\AppFramework\Db\DoesNotExistException $e) { |
d03437c to
820fe24
Compare
…ady exist Signed-off-by: Misha M.-Kupriyanov <kupriyanov@strato.de>
820fe24 to
26d9304
Compare
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
Before
Multiple delegation to same group is possible
After fix
Fixes issue with delegation via occ and web.
No multiple entries in DB.
Summary
TODO
Checklist