test_accounts.py failure fix - fallback using the camelCase parameter name "domainId"#12689
test_accounts.py failure fix - fallback using the camelCase parameter name "domainId"#12689sureshanaparti wants to merge 2 commits intoapache:4.20from
Conversation
… name "domainId" (as earlier)
|
@blueorangutan package |
|
@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
There was a problem hiding this comment.
Pull request overview
This PR addresses authentication failures caused by clients sending the domain identifier using the camelCase request parameter name (domainId) instead of the legacy lowercase form (domainid) during login flows.
Changes:
- Added a fallback lookup for the
domainIdparameter whendomainidis not present in the request parameter map. - Applied the same fallback behavior to both the default login authenticator and the OAuth2 login authenticator.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| server/src/main/java/com/cloud/api/auth/DefaultLoginAPIAuthenticatorCmd.java | Adds fallback parameter lookup to accept domainId when authenticating via the default login API. |
| plugins/user-authenticators/oauth2/src/main/java/org/apache/cloudstack/oauth2/api/command/OauthLoginAPIAuthenticatorCmd.java | Adds the same fallback for OAuth2 login domain ID parsing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| String[] domainIdArr = (String[])params.get(ApiConstants.DOMAIN_ID); | ||
| if (domainIdArr == null) { | ||
| // Fallback to support clients using the camelCase parameter name "domainId" | ||
| domainIdArr = (String[])params.get(ApiConstants.DOMAIN__ID); | ||
| } |
There was a problem hiding this comment.
The new fallback to accept both "domainid" and "domainId" is duplicated here and in DefaultLoginAPIAuthenticatorCmd. Consider extracting a small shared helper (e.g., in a common auth/util class) to reduce the chance of future auth paths missing the same compatibility handling.
| String[] domainIdArr = (String[])params.get(ApiConstants.DOMAIN_ID); | ||
| if (domainIdArr == null) { | ||
| // Fallback to support clients using the camelCase parameter name "domainId" | ||
| domainIdArr = (String[])params.get(ApiConstants.DOMAIN__ID); | ||
| } |
There was a problem hiding this comment.
This adds behavior to accept the camelCase "domainId" parameter, but there doesn't appear to be a unit test covering this path (the existing tests use ApiConstants.DOMAIN_ID). Please add/extend a test to verify that passing ApiConstants.DOMAIN__ID is accepted and parsed correctly.
| String[] domainIdArr = (String[])params.get(ApiConstants.DOMAIN_ID); | ||
| if (domainIdArr == null) { | ||
| // Fallback to support clients using the camelCase parameter name "domainId" | ||
| domainIdArr = (String[])params.get(ApiConstants.DOMAIN__ID); | ||
| } |
There was a problem hiding this comment.
This same dual-parameter lookup logic is now required in multiple authenticators (e.g., OAuth2 and default login). Consider centralizing the lookup (e.g., a helper that returns the first non-null entry for DOMAIN_ID / DOMAIN__ID) to avoid future inconsistencies.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 4.20 #12689 +/- ##
=========================================
Coverage 16.25% 16.25%
- Complexity 13424 13427 +3
=========================================
Files 5662 5662
Lines 500149 500165 +16
Branches 60735 60740 +5
=========================================
+ Hits 81309 81326 +17
+ Misses 409755 409750 -5
- Partials 9085 9089 +4
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:
|
|
@sureshanaparti , can we root out camel case for API/Params completely? this is techdebt byting us. |
@DaanHoogland it seems camel cases (domainId, clusterId, zoneId, etc) were used in marvin tests, we can address them later in a separate pr? |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16910 |
|
@blueorangutan package |
|
@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress. |
created an issue for it: #12691 |
|
Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✖️ debian ✔️ suse15. SL-JID 16912 |
Description
This PR fixes test_accounts.py failure - fallback using the camelCase parameter name "domainId".
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?