-
Notifications
You must be signed in to change notification settings - Fork 1.3k
cleanup LDAP code according to warnings #11436
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
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #11436 +/- ##
============================================
+ Coverage 3.58% 17.50% +13.91%
- Complexity 0 15564 +15564
============================================
Files 445 5914 +5469
Lines 37571 529642 +492071
Branches 6921 64702 +57781
============================================
+ Hits 1347 92691 +91344
- Misses 36058 426503 +390445
- Partials 166 10448 +10282
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull Request Overview
This PR performs cleanup of the LDAP code according to compiler warnings. It removes unused methods, simplifies string concatenations, eliminates dead code, and modernizes various patterns without changing functionality.
- Removes deprecated/unused methods and constructors
- Simplifies string building patterns and improves logging
- Updates method visibility and parameters for better consistency
Reviewed Changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| ADLdapUserManagerImplTest.java | Updates test setup to use static mocking and fixes assertion methods |
| LinkAccountToLdapCmdTest.java | Adds missing test assertion for account name |
| LdapListUsersCmdTest.java | Fixes method name from isACloudstackUser to isACloudStackUser |
| LdapConfigurationDaoImpl.java | Removes unused find method overload |
| LdapConfigurationDao.java | Removes unused method signature and improves javadoc |
| OpenLdapUserManagerImpl.java | Major refactoring: simplifies string building, uses static methods, improves logging |
| LdapUserManager.java | Removes public modifiers from interface methods |
| LdapUser.java | Makes memberships field final |
| LdapTrustMapVO.java | Removes empty constructor and updates hashCode implementation |
| LdapManagerImpl.java | Simplifies logging and removes unused method |
| LdapManager.java | Removes unused method signature |
| LdapContextFactory.java | Uses static methods for configuration access |
| LdapConfiguration.java | Makes many methods static and removes deprecated constructor |
| LdapAuthenticator.java | Improves logging and simplifies conditional logic |
| ADLdapUserManagerImpl.java | Uses static configuration methods and improves string building |
| LinkAccountToLdapResponse.java | Adds missing getter method |
| Various command classes | Removes empty constructors, improves parameter documentation, and modernizes patterns |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...er-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/OpenLdapUserManagerImpl.java
Show resolved
Hide resolved
8deca7b to
3b806be
Compare
2c3bddd to
44724f6
Compare
8865be3 to
85a647e
Compare
Pearl1594
left a comment
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.
overall LGTM, some comments around formatting, etc..
...-authenticators/ldap/src/main/java/org/apache/cloudstack/api/command/LdapImportUsersCmd.java
Outdated
Show resolved
Hide resolved
...-authenticators/ldap/src/main/java/org/apache/cloudstack/api/command/LdapImportUsersCmd.java
Outdated
Show resolved
Hide resolved
...-authenticators/ldap/src/main/java/org/apache/cloudstack/api/command/LdapImportUsersCmd.java
Outdated
Show resolved
Hide resolved
...-authenticators/ldap/src/main/java/org/apache/cloudstack/api/command/LdapImportUsersCmd.java
Outdated
Show resolved
Hide resolved
...er-authenticators/ldap/src/main/java/org/apache/cloudstack/api/command/LdapListUsersCmd.java
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| String basedn = _ldapConfiguration.getBaseDn(domainId); | ||
| String basedn = LdapConfiguration.getBaseDn(domainId); |
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.
should we rather have
| String basedn = LdapConfiguration.getBaseDn(domainId); | |
| String basedn = ldapConfiguration.getBaseDn(domainId); |
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.
no, calling a static method
...ins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/LdapAuthenticator.java
Outdated
Show resolved
Hide resolved
plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/LdapManagerImpl.java
Outdated
Show resolved
Hide resolved
plugins/user-authenticators/ldap/src/main/java/org/apache/cloudstack/ldap/LdapManagerImpl.java
Outdated
Show resolved
Hide resolved
| String domainUuid = "<unknown>"; | ||
| if (domain == null) { | ||
| logger.error("no domain in database for id " + vo.getDomainId()); | ||
| logger.error("no domain in database for id {}", vo.getDomainId()); |
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.
| logger.error("no domain in database for id {}", vo.getDomainId()); | |
| logger.error("No domain in database for id {}", vo.getDomainId()); |
However, do we need to log this with the database ID?
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.
I think we need to no which domain is ill-configured, do we?
| logger.error("no domain in database for id {}", vo.getDomainId()); | |
| logger.error(“No Domain in the database for ID {}", vo.getDomainId()); |
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.
Now that I looked at the code implementation - should we check if the domain exists before persisting it into the trust map and fail the process if domain isn't found, rather than just logging the error?
Co-authored-by: Pearl Dsilva <pearl1594@gmail.com>
weizhouapache
left a comment
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.
code lgtm
Not tested
Pearl1594
left a comment
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.
code lgtm. Thanks @DaanHoogland
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16076 |
|
[SF] Trillian test result (tid-15017)
|
Description
This PR was part of investigation into the current LDAP workings, to find out that the issue under investigation was a user issue. I think this can be merged, but it has no functional changes.
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?