OAuthProvider: add param enable in register API - #13889
Conversation
this allows to created a provider disabled.
There was a problem hiding this comment.
Pull request overview
This PR extends the OAuth2 provider registration flow to optionally create providers in a disabled state, instead of always enabling them immediately. It wires the new API parameter through the register command into persistence and adds/updates unit tests around the new behavior and response payload.
Changes:
- Add optional
enabledparameter toregisterOauthProviderand pass it through to persistence (defaulting to enabled when omitted). - Update register API response to explicitly set the
enabledflag based on runtime/provider state (consistent with list/update behavior). - Add unit tests covering registering a disabled provider and ensuring the response reflects the disabled state.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| plugins/user-authenticators/oauth2/src/main/java/org/apache/cloudstack/oauth2/OAuth2AuthManagerImpl.java | Propagates enabled from the register command into provider persistence (defaults to enabled when null). |
| plugins/user-authenticators/oauth2/src/main/java/org/apache/cloudstack/oauth2/api/command/RegisterOAuthProviderCmd.java | Adds the enabled API parameter and sets the response enabled field based on plugin/provider state. |
| plugins/user-authenticators/oauth2/src/test/java/org/apache/cloudstack/oauth2/OAuth2AuthManagerImplTest.java | Adds a unit test verifying a provider can be registered as disabled. |
| plugins/user-authenticators/oauth2/src/test/java/org/apache/cloudstack/oauth2/api/command/RegisterOAuthProviderCmdTest.java | Updates tests to account for enabled handling and adds coverage for disabled response. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #13889 +/- ##
=========================================
Coverage 19.65% 19.65%
- Complexity 19794 19798 +4
=========================================
Files 6368 6368
Lines 574889 574903 +14
Branches 70353 70356 +3
=========================================
+ Hits 112985 113003 +18
+ Misses 449634 449628 -6
- Partials 12270 12272 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
Before this change, when registering a new provider, it will always be enabled from the start.
This change allows to pass
enableto the register process to control whether the new provider should already be enabled after registering.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?