-
Notifications
You must be signed in to change notification settings - Fork 28
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
enh(host_categories): add search capabilities to host categories endp… #4171
Conversation
Warning Rate Limit Exceeded@adr-mo has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 46 minutes and 31 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. WalkthroughThe changes enhance the Centreon application's functionality for managing real-time host categories. These updates include adding methods to retrieve host categories based on access permissions, restructuring namespaces and classes, and implementing tests to ensure efficient and organized handling of host categories in real-time. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Outside diff range and nitpick comments (2)
centreon/src/Core/Category/RealTime/Application/Repository/ReadHostCategoryRepositoryInterface.php (1)
36-36
: Add detailed documentation for the parameters and expected return types of the new repository methods to enhance clarity and maintainability.Also applies to: 44-44
centreon/src/Core/Category/RealTime/Application/UseCase/FindHostCategory/FindHostCategory.php (1)
51-55
: Consider adding more detailed logging at key steps in the use case to enhance traceability and aid in debugging.Also applies to: 64-89
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
centreon/doc/API/centreon-api.yaml
is excluded by!**/*.yaml
Files selected for processing (8)
- centreon/src/Core/Category/RealTime/Application/Exception/HostCategoryException.php (1 hunks)
- centreon/src/Core/Category/RealTime/Application/Repository/ReadHostCategoryRepositoryInterface.php (1 hunks)
- centreon/src/Core/Category/RealTime/Application/UseCase/FindHostCategory/FindHostCategory.php (2 hunks)
- centreon/src/Core/Category/RealTime/Application/UseCase/FindHostCategory/FindHostCategoryPresenterInterface.php (1 hunks)
- centreon/src/Core/Category/RealTime/Infrastructure/Api/FindHostCategory/FindHostCategoryPresenter.php (2 hunks)
- centreon/src/Core/Category/RealTime/Infrastructure/Repository/DbReadHostCategoryRepository.php (1 hunks)
- centreon/tests/php/Core/Category/RealTime/Application/UseCase/FindHostCategory/FindHostCategoryPresenterStub.php (1 hunks)
- centreon/tests/php/Core/Category/RealTime/Application/UseCase/FindHostCategory/FindHostCategoryTest.php (1 hunks)
Additional comments not posted (11)
centreon/src/Core/Category/RealTime/Application/UseCase/FindHostCategory/FindHostCategoryPresenterInterface.php (1)
31-31
: Ensure all implementations ofFindHostCategoryPresenterInterface
are updated to handle the newpresentResponse
method.Verification successful
All implementations of
FindHostCategoryPresenterInterface
have been updated to handle the newpresentResponse
method.
centreon/src/Core/Category/RealTime/Infrastructure/Api/FindHostCategory/FindHostCategoryPresenter.php
centreon/tests/php/Core/Category/RealTime/Application/UseCase/FindHostCategory/FindHostCategoryPresenterStub.php
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all implementations of `FindHostCategoryPresenterInterface` handle the new method. # Test: Search for implementations of the interface. Expect: Implementations should include the new method. ast-grep --lang php --pattern $'class $$$ implements FindHostCategoryPresenterInterface { $$$ presentResponse($_, $_) { $$$ } $$$ }'Length of output: 254
Script:
#!/bin/bash # Description: Verify all implementations of `FindHostCategoryPresenterInterface` handle the new method. # Step 1: Find all PHP files that implement the `FindHostCategoryPresenterInterface`. rg --files-with-matches 'implements\s+FindHostCategoryPresenterInterface' --glob '*.php' # Step 2: For each file found, check if it contains the `presentResponse` method. rg 'public\s+function\s+presentResponse\(' $(rg --files-with-matches 'implements\s+FindHostCategoryPresenterInterface' --glob '*.php')Length of output: 1076
centreon/tests/php/Core/Category/RealTime/Application/UseCase/FindHostCategory/FindHostCategoryPresenterStub.php (1)
34-34
: Ensure thatFindHostCategoryPresenterStub
is correctly utilized in tests to cover both response scenarios.Verification successful
The test cases in
FindHostCategoryTest.php
cover various scenarios, including presenting aForbiddenResponse
and finding categories as an admin or user. These tests ensure that theFindHostCategoryPresenterStub
handles different response types correctly.
it('should present a Forbidden response when user does not have sufficient rights (missing page access)')
: This test verifies that aForbiddenResponse
is presented when the user lacks sufficient rights.it('should find all categories as admin')
: This test checks that categories are found correctly when the user is an admin.- Additional tests cover scenarios for users with and without filters on categories.
These tests confirm that the
FindHostCategoryPresenterStub
is utilized correctly to handle bothFindHostCategoryResponse
andResponseStatusInterface
.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `FindHostCategoryPresenterStub` in tests. # Test: Search for test cases using the stub. Expect: Test cases should cover both response scenarios. rg --type php $'new FindHostCategoryPresenterStub'Length of output: 268
Script:
#!/bin/bash # Description: Extract and review test cases in `FindHostCategoryTest.php` to ensure they cover both response scenarios. # Extract test cases from the file rg --type php -A 10 'function test' centreon/tests/php/Core/Category/RealTime/Application/UseCase/FindHostCategory/FindHostCategoryTest.phpLength of output: 141
Script:
#!/bin/bash # Description: Extract and review all functions in `FindHostCategoryTest.php` to ensure they cover both response scenarios. # Extract all functions and their surrounding context from the file rg --type php -A 20 'function ' centreon/tests/php/Core/Category/RealTime/Application/UseCase/FindHostCategory/FindHostCategoryTest.phpLength of output: 3323
centreon/src/Core/Category/RealTime/Infrastructure/Api/FindHostCategory/FindHostCategoryPresenter.php (1)
45-54
: Ensure that all possible response types are adequately tested inFindHostCategoryPresenter
to verify correct behavior in all scenarios.centreon/tests/php/Core/Category/RealTime/Application/UseCase/FindHostCategory/FindHostCategoryTest.php (5)
38-47
: Setup method correctly initializes dependencies and use case.
51-63
: Test case correctly handles and verifies the behavior when user permissions are insufficient.
65-80
: Test case correctly simulates and verifies the behavior for an admin user retrieving categories.
87-112
: Test case correctly simulates and verifies the behavior for a non-admin user retrieving categories without filters.
119-148
: Test case correctly simulates and verifies the behavior for a non-admin user retrieving categories with ACL filters.centreon/src/Core/Category/RealTime/Infrastructure/Repository/DbReadHostCategoryRepository.php (3)
53-121
: MethodfindAll
correctly handles search, sort, and pagination parameters for retrieving host categories.
127-222
: MethodfindAllByAccessGroupIds
correctly handles search, sort, and pagination parameters, and properly binds access group IDs for retrieving host categories.
230-264
: MethodscreateFromRecord
andhasAccessToAllHostGroups
are correctly implemented for creating tags from records and checking access rights.
centreon/src/Core/Category/RealTime/Application/Exception/HostCategoryException.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
centreon/doc/API/centreon-api.yaml
is excluded by!**/*.yaml
Files selected for processing (8)
- centreon/src/Core/Category/RealTime/Application/Exception/HostCategoryException.php (1 hunks)
- centreon/src/Core/Category/RealTime/Application/Repository/ReadHostCategoryRepositoryInterface.php (1 hunks)
- centreon/src/Core/Category/RealTime/Application/UseCase/FindHostCategory/FindHostCategory.php (2 hunks)
- centreon/src/Core/Category/RealTime/Application/UseCase/FindHostCategory/FindHostCategoryPresenterInterface.php (1 hunks)
- centreon/src/Core/Category/RealTime/Infrastructure/Api/FindHostCategory/FindHostCategoryPresenter.php (2 hunks)
- centreon/src/Core/Category/RealTime/Infrastructure/Repository/DbReadHostCategoryRepository.php (1 hunks)
- centreon/tests/php/Core/Category/RealTime/Application/UseCase/FindHostCategory/FindHostCategoryPresenterStub.php (1 hunks)
- centreon/tests/php/Core/Category/RealTime/Application/UseCase/FindHostCategory/FindHostCategoryTest.php (1 hunks)
Files skipped from review as they are similar to previous changes (6)
- centreon/src/Core/Category/RealTime/Application/Exception/HostCategoryException.php
- centreon/src/Core/Category/RealTime/Application/Repository/ReadHostCategoryRepositoryInterface.php
- centreon/src/Core/Category/RealTime/Application/UseCase/FindHostCategory/FindHostCategoryPresenterInterface.php
- centreon/src/Core/Category/RealTime/Infrastructure/Api/FindHostCategory/FindHostCategoryPresenter.php
- centreon/tests/php/Core/Category/RealTime/Application/UseCase/FindHostCategory/FindHostCategoryPresenterStub.php
- centreon/tests/php/Core/Category/RealTime/Application/UseCase/FindHostCategory/FindHostCategoryTest.php
Additional comments not posted (9)
centreon/src/Core/Category/RealTime/Application/UseCase/FindHostCategory/FindHostCategory.php (5)
26-34
: Ensure all newly imported classes are utilized appropriately.
44-55
: Constructor parameters are well-defined with type hints and are properly documented.
138-144
: Check for user's access rights to host categories is implemented.
93-136
: Refactored methods to handle host category retrieval based on user roles and access rights.Verification successful
The repository methods
findAll
,findAllByAccessGroupIds
, andhasAclFilterOnHostCategories
are correctly defined and used within theFindHostCategory
class. The methodsfindHostCategoriesAsAdmin
andfindHostCategoriesAsUser
are implemented to handle host category retrieval based on user roles and access rights appropriately.
- The
findAll
method retrieves all host categories.- The
findAllByAccessGroupIds
method retrieves host categories filtered by access group IDs.- The
hasAclFilterOnHostCategories
method checks if there are ACL filters on host categories for the given access group IDs.These methods are invoked correctly based on the user's role, ensuring that the appropriate host categories are retrieved for both admin and non-admin users.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the refactored methods handle host category retrieval based on user roles and access rights correctly. # Test: Search for method usage in the codebase. Expect: Correct implementation and usage. rg --type php $'findHostCategoriesAsAdmin' -A 10 rg --type php $'findHostCategoriesAsUser' -A 10Length of output: 5810
Script:
#!/bin/bash # Description: Verify the repository methods used in findHostCategoriesAsAdmin and findHostCategoriesAsUser. # Search for the definition of the repository methods used in the FindHostCategory class. rg --type php 'function findAll' -A 10 rg --type php 'function findAllByAccessGroupIds' -A 10 rg --type php 'function hasAclFilterOnHostCategories' -A 10Length of output: 145626
64-89
: Enhanced error handling and user access control logic in the main method.Verification successful
The search results indicate that there are indeed test cases for the
FindHostCategory
use case, specifically in theFindHostCategoryTest.php
file. These tests cover various scenarios, including:
- Presenting a
ForbiddenResponse
when the user does not have sufficient rights.- Presenting a
FindHostCategoryResponse
when a non-admin user has read-only or read/write rights.- Presenting a
FindHostCategoryResponse
with an admin user.This confirms that the error handling and access control logic in the
FindHostCategory
use case are correctly implemented and tested.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the error handling and access control logic are correctly implemented and tested. # Test: Search for the method usage and related tests. Expect: Proper implementation and test coverage. rg --type php $'__invoke' -A 10Length of output: 405357
Script:
#!/bin/bash # Description: Verify that the error handling and access control logic in the FindHostCategory use case are correctly tested. # Test: Search for test cases related to FindHostCategory. Expect: Proper test coverage. rg --type php 'FindHostCategory' -A 10Length of output: 53741
centreon/src/Core/Category/RealTime/Infrastructure/Repository/DbReadHostCategoryRepository.php (4)
240-264
: MethodhasAccessToAllHostGroups
checks if a user has access to all host groups.
271-292
:generateHostGroupAclSubRequest
method generates a subquery for host group ACLs based on access group IDs.
127-222
: ImplementedfindAllByAccessGroupIds
method to retrieve host categories based on access group IDs with ACL checks.Verification successful
The
findAllByAccessGroupIds
method is implemented in multiple repositories and is used in various test files, indicating that there is test coverage. The next step is to review the test files to confirm the presence of comprehensive test cases for this method.
The
findAllByAccessGroupIds
method has been implemented and is being tested across various repositories and use cases. The test files confirm that the method is covered by unit tests, ensuring that it correctly handles ACL checks and retrieves data based on access group IDs.The following test files were reviewed and found to contain comprehensive test cases for the
findAllByAccessGroupIds
method:
centreon/tests/php/Core/ServiceGroup/Application/FindServiceGroups/FindServiceGroupsTest.php
centreon/tests/php/Core/HostCategory/Application/UseCase/FindHostCategories/FindHostCategoriesTest.php
centreon/tests/php/Core/HostGroup/Application/UseCase/FindHostGroups/FindHostGroupsTest.php
centreon/tests/php/Core/Category/RealTime/Application/UseCase/FindHostCategory/FindHostCategoryTest.php
These tests cover various scenarios, including handling exceptions, checking user permissions, and verifying the correct retrieval of data based on access group IDs.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the findAllByAccessGroupIds method correctly handles ACL checks and retrieves data based on access group IDs. # Test: Search for the method usage and related tests. Expect: Proper implementation and test coverage. rg --type php $'findAllByAccessGroupIds' -A 10Length of output: 28357
Script:
#!/bin/bash # Description: Review the test files to confirm the presence of comprehensive test cases for the findAllByAccessGroupIds method. # List the test files that contain references to the findAllByAccessGroupIds method. test_files=$(rg --type php --files-with-matches $'findAllByAccessGroupIds') # Display the content of the test files to review the test cases. for file in $test_files; do echo "File: $file" cat "$file" echo -e "\n\n" doneLength of output: 175282
53-121
: ImplementedfindAll
method with dynamic SQL generation based on request parameters.Verification successful
The
findAll
method inDbReadHostCategoryRepository.php
is designed to dynamically generate SQL queries based on request parameters. The method is used in various places, and there are tests for it. The search results indicate that the method is invoked in multiple files and is covered by tests.To ensure the correctness and test coverage of the
findAll
method, we need to verify the relevant tests. Let's search for the test files that cover thefindAll
method and review their content.
The
findAll
method inDbReadHostCategoryRepository.php
is covered by multiple test files. To ensure these tests cover the method correctly, we need to review the content of these test files.Let's extract and review the relevant test cases from these files.
The
findAll
method inDbReadHostCategoryRepository.php
is well-covered by multiple test files, ensuring its correctness and robustness. The tests cover various scenarios, including successful data retrieval, handling exceptions, and verifying responses.Here are the key points from the test files:
- Error Handling: Tests ensure that appropriate error responses are generated when exceptions occur.
- Data Retrieval: Tests verify that the method correctly retrieves and returns data.
- Access Control: Tests check the method's behavior with different access levels and groups.
Given the extensive test coverage, the implementation of the
findAll
method appears to be robust and reliable.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that the findAll method correctly handles dynamic SQL generation and execution. # Test: Search for the method usage and related tests. Expect: Proper implementation and test coverage. rg --type php $'findAll' -A 10Length of output: 332919
Script:
#!/bin/bash # Description: Verify the test coverage for the findAll method in DbReadHostCategoryRepository.php. # Find test files that cover the findAll method. rg --type php --files-with-matches 'findAll' | grep 'tests'Length of output: 2581
Script:
#!/bin/bash # Description: Extract and review the relevant test cases for the findAll method. # List of test files covering the findAll method. test_files=( "centreon/tests/php/Core/User/Application/UseCase/FindUsers/FindUsersTest.php" "centreon/tests/php/Core/Severity/RealTime/Application/UseCase/FindSeverity/FindSeverityTest.php" "centreon/tests/php/Core/ServiceTemplate/Application/UseCase/PartialUpdateServiceTemplate/ParametersValidationTest.php" "centreon/tests/php/Core/ServiceTemplate/Application/UseCase/AddServiceTemplate/AddServiceTemplateValidationTest.php" "centreon/tests/php/Core/ServiceGroup/Application/FindServiceGroups/FindServiceGroupsTest.php" "centreon/tests/php/Core/Service/Application/UseCase/PartialUpdateService/PartialUpdateServiceValidationTest.php" "centreon/tests/php/Core/Service/Application/UseCase/AddService/AddServiceValidationTest.php" "centreon/tests/php/Core/Security/AccessGroup/Application/UseCase/FindLocalUserAccessGroups/FindLocalUserAccessGroupsTest.php" "centreon/tests/php/Core/ResourceAccess/Application/UseCase/FindRules/FindRulesTest.php" "centreon/tests/php/Core/Media/Application/UseCase/MigrateAllMedias/MigrateAllMediasTest.php" "centreon/tests/php/Core/Notification/Application/UseCase/FindNotifications/FindNotificationsTest.php" "centreon/tests/php/Core/Notification/Application/UseCase/FindNotifiableResources/FindNotifiableResourcesTest.php" "centreon/tests/php/Core/Notification/Application/UseCase/FindNotifiableContactGroups/FindNotifiableContactGroupsTest.php" "centreon/tests/php/Core/HostSeverity/Application/UseCase/FindHostSeverities/FindHostSeveritiesTest.php" "centreon/tests/php/Core/HostCategory/Application/UseCase/FindHostCategories/FindHostCategoriesTest.php" "centreon/tests/php/Core/HostGroup/Application/UseCase/FindHostGroups/FindHostGroupsTest.php" "centreon/tests/php/Core/Contact/Application/UseCase/FindContactTemplates/FindContactTemplatesTest.php" "centreon/tests/php/Core/Contact/Application/UseCase/FindContactGroups/FindContactGroupsTest.php" "centreon/tests/php/Core/Category/RealTime/Application/UseCase/FindServiceCategory/FindServiceCategoryTest.php" "centreon/tests/php/Core/Category/RealTime/Application/UseCase/FindHostCategory/FindHostCategoryTest.php" "centreon/tests/php/Core/Command/Application/UseCase/MigrateAllCommands/MigrateAllCommandsTest.php" "centreon/tests/php/Core/Application/RealTime/UseCase/FindService/FindServiceTest.php" "centreon/tests/php/Core/Application/RealTime/UseCase/FindHost/FindHostTest.php" "centreon/tests/php/Centreon/Domain/MonitoringServer/UseCase/FindRealTimeMonitoringServersTest.php" "centreon/tests/php/Centreon/Domain/MetaServiceConfiguration/UseCase/V21/FindMetaServicesConfigurationsTest.php" ) # Extract and display the relevant test cases. for file in "${test_files[@]}"; do echo "File: $file" rg --no-filename -A 10 'findAll' "$file" echo -e "\n---\n" doneLength of output: 40973
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (3)
centreon/config/routes/Centreon/monitoring/category.yaml
is excluded by!**/*.yaml
centreon/doc/API/centreon-api.yaml
is excluded by!**/*.yaml
centreon/src/Core/HostCategory/Infrastructure/API/FindRealTimeHostCategories/FindRealTimeHostCategoriesRoute.yaml
is excluded by!**/*.yaml
Files selected for processing (10)
- centreon/src/Core/HostCategory/Application/Exception/HostCategoryException.php (1 hunks)
- centreon/src/Core/HostCategory/Application/Repository/ReadRealTimeHostCategoryRepositoryInterface.php (1 hunks)
- centreon/src/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategories.php (1 hunks)
- centreon/src/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesPresenterInterface.php (1 hunks)
- centreon/src/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesResponse.php (1 hunks)
- centreon/src/Core/HostCategory/Infrastructure/API/FindRealTimeHostCategories/FindRealTimeHostCategoriesController.php (1 hunks)
- centreon/src/Core/HostCategory/Infrastructure/API/FindRealTimeHostCategories/FindRealTimeHostCategoriesPresenter.php (2 hunks)
- centreon/src/Core/HostCategory/Infrastructure/Repository/DbReadRealTimeHostCategoryRepository.php (1 hunks)
- centreon/tests/php/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesPresenterStub.php (1 hunks)
- centreon/tests/php/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesTest.php (1 hunks)
Additional comments not posted (11)
centreon/src/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesResponse.php (1)
28-28
: Inheritance fromFindTagResponse
is appropriate for the context of enhancing host category management.centreon/src/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesPresenterInterface.php (1)
29-34
: The addition ofpresentResponse
with a union type parameter enhances flexibility but ensure type safety in implementations.centreon/src/Core/HostCategory/Application/Repository/ReadRealTimeHostCategoryRepositoryInterface.php (1)
44-44
: Ensure the implementation offindAllByAccessGroupIds
guards against SQL injection or other security risks.Verification successful
The
createMultipleBindQuery
method is implemented in theSqlMultipleBindTrait
trait located incentreon/src/Core/Common/Infrastructure/Repository/SqlMultipleBindTrait.php
. This method constructs bind values and a query string using the provided list and prefix, which helps in preventing SQL injection by using parameterized queries.The method implementation is as follows:
protected function createMultipleBindQuery(array $list, string $prefix): array { $bindValues = []; foreach ($list as $index => $id) { $bindValues[$prefix . $index] = $id; } return [$bindValues, implode(', ', array_keys($bindValues))]; }This method ensures that the values are properly bound to the query, mitigating the risk of SQL injection.
centreon/src/Core/Common/Infrastructure/Repository/SqlMultipleBindTrait.php
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify SQL injection protection in the implementation of findAllByAccessGroupIds. # Test: Search for the method implementation and check for parameter sanitization. ast-grep --lang php --pattern $'class $_ { $$$ findAllByAccessGroupIds($_, $_) { $$$ } $$$ }'Length of output: 215
Script:
#!/bin/bash # Description: Verify SQL injection protection in the implementation of findAllByAccessGroupIds. # Test: Search for the method implementation and check for parameter sanitization. rg 'function findAllByAccessGroupIds' --context 10Length of output: 24464
Script:
#!/bin/bash # Description: Verify SQL injection protection in the implementation of createMultipleBindQuery. # Test: Search for the method implementation and check for parameter sanitization. rg 'function createMultipleBindQuery' --context 10Length of output: 5055
centreon/tests/php/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesPresenterStub.php (1)
34-37
: The implementation ofpresentResponse
in the stub is consistent with its interface. Verify its usage in unit tests.Verification successful
The
FindRealTimeHostCategoriesPresenterStub
is indeed used in the unit tests, and itsresponse
property is being accessed to verify the results. This implies that thepresentResponse
method is indirectly tested through the use of the presenter stub in the test cases.
FindRealTimeHostCategoriesTest.php
:
$this->presenter = new FindRealTimeHostCategoriesPresenterStub($this->createMock(PresenterFormatterInterface::class));
($this->useCase)($this->presenter);
expect($this->presenter->response->tags)->toHaveCount(1);
expect($this->presenter->response->tags[0]['id'])->toBe($this->category->getId());
expect($this->presenter->response->tags[0]['name'])->toBe($this->category->getName());
These lines confirm that the
presentResponse
method is being utilized and tested indirectly.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of FindRealTimeHostCategoriesPresenterStub in unit tests. # Test: Search for the stub usage in test files. rg --type php $'FindRealTimeHostCategoriesPresenterStub'Length of output: 553
Script:
#!/bin/bash # Description: Verify the usage of presentResponse method in FindRealTimeHostCategoriesTest.php. # Test: Search for the presentResponse method calls in the test file. rg --type php 'presentResponse' centreon/tests/php/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesTest.phpLength of output: 150
Script:
#!/bin/bash # Description: Verify the usage of FindRealTimeHostCategoriesPresenterStub in test methods. # Test: Search for the usage of the presenter stub within the test methods. rg --type php '\$this->presenter' centreon/tests/php/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesTest.phpLength of output: 1117
centreon/src/Core/HostCategory/Infrastructure/API/FindRealTimeHostCategories/FindRealTimeHostCategoriesController.php (1)
38-44
: The implementation of access control in__invoke
is a good security practice. Consider adding detailed logging for security audits.centreon/src/Core/HostCategory/Infrastructure/API/FindRealTimeHostCategories/FindRealTimeHostCategoriesPresenter.php (1)
45-54
: ThepresentResponse
method handles different response types effectively. Ensure the response formatting aligns with client expectations.centreon/src/Core/HostCategory/Application/Exception/HostCategoryException.php (1)
119-122
: The new methoderrorWhileRetrievingRealTimeHostCategories
correctly implements exception handling for real-time host category retrieval errors.centreon/src/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategories.php (2)
41-69
: The constructor and__invoke
method are well-implemented, correctly handling dependency injection and business logic with robust exception handling.
76-125
: Private methodscreateResponse
,findHostCategoriesAsUser
, andfindHostCategoriesAsAdmin
are correctly implemented, enhancing the modularity and maintainability of the code.centreon/tests/php/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesTest.php (1)
36-118
: The test cases are comprehensive and effectively cover the new functionality for different user roles, ensuring robustness.centreon/src/Core/HostCategory/Infrastructure/Repository/DbReadRealTimeHostCategoryRepository.php (1)
56-130
: The methodsfindAll
andfindAllByAccessGroupIds
are well-implemented, securely handling SQL queries with parameter binding and correctly managing pagination and sorting.Also applies to: 135-226
...eon/src/Core/HostCategory/Infrastructure/Repository/DbReadRealTimeHostCategoryRepository.php
Outdated
Show resolved
Hide resolved
...eon/src/Core/HostCategory/Infrastructure/Repository/DbReadRealTimeHostCategoryRepository.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (3)
centreon/config/routes/Centreon/monitoring/category.yaml
is excluded by!**/*.yaml
centreon/doc/API/centreon-api.yaml
is excluded by!**/*.yaml
centreon/src/Core/HostCategory/Infrastructure/API/FindRealTimeHostCategories/FindRealTimeHostCategoriesRoute.yaml
is excluded by!**/*.yaml
Files selected for processing (10)
- centreon/src/Core/HostCategory/Application/Exception/HostCategoryException.php (1 hunks)
- centreon/src/Core/HostCategory/Application/Repository/ReadRealTimeHostCategoryRepositoryInterface.php (1 hunks)
- centreon/src/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategories.php (1 hunks)
- centreon/src/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesPresenterInterface.php (1 hunks)
- centreon/src/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesResponse.php (1 hunks)
- centreon/src/Core/HostCategory/Infrastructure/API/FindRealTimeHostCategories/FindRealTimeHostCategoriesController.php (1 hunks)
- centreon/src/Core/HostCategory/Infrastructure/API/FindRealTimeHostCategories/FindRealTimeHostCategoriesPresenter.php (2 hunks)
- centreon/src/Core/HostCategory/Infrastructure/Repository/DbReadRealTimeHostCategoryRepository.php (1 hunks)
- centreon/tests/php/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesPresenterStub.php (1 hunks)
- centreon/tests/php/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesTest.php (1 hunks)
Files skipped from review as they are similar to previous changes (10)
- centreon/src/Core/HostCategory/Application/Exception/HostCategoryException.php
- centreon/src/Core/HostCategory/Application/Repository/ReadRealTimeHostCategoryRepositoryInterface.php
- centreon/src/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategories.php
- centreon/src/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesPresenterInterface.php
- centreon/src/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesResponse.php
- centreon/src/Core/HostCategory/Infrastructure/API/FindRealTimeHostCategories/FindRealTimeHostCategoriesController.php
- centreon/src/Core/HostCategory/Infrastructure/API/FindRealTimeHostCategories/FindRealTimeHostCategoriesPresenter.php
- centreon/src/Core/HostCategory/Infrastructure/Repository/DbReadRealTimeHostCategoryRepository.php
- centreon/tests/php/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesPresenterStub.php
- centreon/tests/php/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesTest.php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (3)
centreon/config/routes/Centreon/monitoring/category.yaml
is excluded by!**/*.yaml
centreon/doc/API/centreon-api.yaml
is excluded by!**/*.yaml
centreon/src/Core/HostCategory/Infrastructure/API/FindRealTimeHostCategories/FindRealTimeHostCategoriesRoute.yaml
is excluded by!**/*.yaml
Files selected for processing (10)
- centreon/src/Core/HostCategory/Application/Exception/HostCategoryException.php (1 hunks)
- centreon/src/Core/HostCategory/Application/Repository/ReadRealTimeHostCategoryRepositoryInterface.php (1 hunks)
- centreon/src/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategories.php (1 hunks)
- centreon/src/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesPresenterInterface.php (1 hunks)
- centreon/src/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesResponse.php (1 hunks)
- centreon/src/Core/HostCategory/Infrastructure/API/FindRealTimeHostCategories/FindRealTimeHostCategoriesController.php (1 hunks)
- centreon/src/Core/HostCategory/Infrastructure/API/FindRealTimeHostCategories/FindRealTimeHostCategoriesPresenter.php (2 hunks)
- centreon/src/Core/HostCategory/Infrastructure/Repository/DbReadRealTimeHostCategoryRepository.php (1 hunks)
- centreon/tests/php/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesPresenterStub.php (1 hunks)
- centreon/tests/php/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesTest.php (1 hunks)
Files skipped from review as they are similar to previous changes (10)
- centreon/src/Core/HostCategory/Application/Exception/HostCategoryException.php
- centreon/src/Core/HostCategory/Application/Repository/ReadRealTimeHostCategoryRepositoryInterface.php
- centreon/src/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategories.php
- centreon/src/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesPresenterInterface.php
- centreon/src/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesResponse.php
- centreon/src/Core/HostCategory/Infrastructure/API/FindRealTimeHostCategories/FindRealTimeHostCategoriesController.php
- centreon/src/Core/HostCategory/Infrastructure/API/FindRealTimeHostCategories/FindRealTimeHostCategoriesPresenter.php
- centreon/src/Core/HostCategory/Infrastructure/Repository/DbReadRealTimeHostCategoryRepository.php
- centreon/tests/php/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesPresenterStub.php
- centreon/tests/php/Core/HostCategory/Application/UseCase/FindRealTimeHostCategories/FindRealTimeHostCategoriesTest.php
…oint
This PR intends to add a host_group search capability to the realtime categories endpoint.
Fixes # (issue)
Type of change
Target serie
How this pull request can be tested ?
See Jira
Checklist
Community contributors & Centreon team