Skip to content

OAuthProvider: add param enabled in register API - #13889

Open
resmo wants to merge 4 commits into
apache:mainfrom
resmo:feature/register-disabled-oauth
Open

OAuthProvider: add param enabled in register API#13889
resmo wants to merge 4 commits into
apache:mainfrom
resmo:feature/register-disabled-oauth

Conversation

@resmo

@resmo resmo commented Aug 16, 2026

Copy link
Copy Markdown
Member

Description

Before this change, when registering a new provider, it will always be enabled from the start.

This change allows to pass enabled to the register process to control whether the new provider should already be enabled after registering.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

this allows to created a provider disabled.
Copilot AI lite review requested due to automatic review settings August 16, 2026 09:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 enabled parameter to registerOauthProvider and pass it through to persistence (defaulting to enabled when omitted).
  • Update register API response to explicitly set the enabled flag 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

codecov Bot commented Aug 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.89474% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.90%. Comparing base (1cd2491) to head (ffc0ebc).
⚠️ Report is 143 commits behind head on main.

Files with missing lines Patch % Lines
...k/oauth2/api/command/RegisterOAuthProviderCmd.java 53.33% 6 Missing and 1 partial ⚠️
...pache/cloudstack/oauth2/OAuth2AuthManagerImpl.java 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #13889      +/-   ##
============================================
+ Coverage     19.65%   19.90%   +0.24%     
- Complexity    19794    20148     +354     
============================================
  Files          6368     6371       +3     
  Lines        574889   576845    +1956     
  Branches      70353    70630     +277     
============================================
+ Hits         112985   114795    +1810     
+ Misses       449634   449504     -130     
- Partials      12270    12546     +276     
Flag Coverage Δ
uitests 3.71% <ø> (+0.29%) ⬆️
unittests 21.17% <57.89%> (+0.24%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@resmo resmo added this to the 4.24.0 milestone Aug 16, 2026
@resmo resmo changed the title OAuthProvider: add param enable in register API OAuthProvider: add param enabled in register API Aug 16, 2026

@DaanHoogland DaanHoogland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clgtm, are yu doing this for automation purposes, @resmo ?

@resmo

resmo commented Aug 17, 2026

Copy link
Copy Markdown
Member Author

clgtm, are yu doing this for automation purposes, @resmo ?

yes, it is an improvment I noticed during the development of ansible module oauth_provider.

@DaanHoogland

Copy link
Copy Markdown
Contributor

@resmo , is this still draft on purpose?

@DaanHoogland DaanHoogland moved this from Backlog to conflict/waiting for author in CloudStack Testing Aug 31, 2026
@resmo
resmo marked this pull request as ready for review September 9, 2026 13:52
Copilot AI review requested due to automatic review settings September 9, 2026 13:52
@resmo

resmo commented Sep 9, 2026

Copy link
Copy Markdown
Member Author

@DaanHoogland ready for merge

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

oauthProviderVO.setAuthorizeUrl(authorizeUrl);
oauthProviderVO.setTokenUrl(tokenUrl);
oauthProviderVO.setEnabled(true);
oauthProviderVO.setEnabled(enabled == null || enabled);
@vishesh92

Copy link
Copy Markdown
Member

@resmo some minor code changes. otherwise the PR looks good.

Copilot AI review requested due to automatic review settings September 11, 2026 05:23
@resmo

resmo commented Sep 11, 2026

Copy link
Copy Markdown
Member Author

@vishesh92 ignore my previous comment, you're right. we can default early and we should. I change the code accordently.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Fix the nullable enabled handling and address the remaining API-version and default-path test findings.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 3
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 11, 2026 05:37
@resmo
resmo force-pushed the feature/register-disabled-oauth branch from 0ebad77 to db9e8b3 Compare September 11, 2026 05:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

One or more issues must be addressed before approval.

Review details

Suppressed comments (3)

plugins/user-authenticators/oauth2/src/main/java/org/apache/cloudstack/oauth2/OAuth2AuthManagerImpl.java:286

  • enabled is a nullable Boolean, but OauthProviderVO#setEnabled accepts primitive boolean, so this call auto-unboxes null and throws a NullPointerException whenever the command returns null (the existing Mockito-based registration tests do this, and it represents an omitted value). Normalize null to the documented default of true before persisting, while preserving an explicit false.
        oauthProviderVO.setEnabled(enabled);

plugins/user-authenticators/oauth2/src/main/java/org/apache/cloudstack/oauth2/api/command/RegisterOAuthProviderCmd.java:134

  • The new null-default branch is not covered by the added tests: the command tests pass a mocked manager, while the manager tests mock RegisterOAuthProviderCmd and never verify that omitting enabled persists true. Add a regression test for an unset parameter so the backward-compatible default cannot silently change.
        if (enabled == null) {
            enabled = true; // default to enabled if not specified
        }
        return enabled;

plugins/user-authenticators/oauth2/src/main/java/org/apache/cloudstack/oauth2/api/command/RegisterOAuthProviderCmd.java:82

  • The new API metadata uses since = "24.0.0", but this repository is on 4.23.0.0-SNAPSHOT and the adjacent OAuth API parameters use the 4.23.0 format (see lines 69 and 73). This records an invalid CloudStack release for the parameter in generated API documentation; use the intended 4.x release value instead.
    @Parameter(name = ApiConstants.ENABLED, type = CommandType.BOOLEAN, description = "OAuth provider will be enabled or disabled based on this value, defaults to true if not specified", since = "24.0.0")
  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@vishesh92 vishesh92 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clgtm. didn't test.

Copilot AI review requested due to automatic review settings September 12, 2026 08:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A critical null-list registration failure and an incorrect API introduction version remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

plugins/user-authenticators/oauth2/src/main/java/org/apache/cloudstack/oauth2/api/command/RegisterOAuthProviderCmd.java:82

  • The since value is using 24.0.0, while this repository is on the 4.23.0 release line and the surrounding OAuth API metadata uses 4.23.0. API discovery publishes this annotation value verbatim, so the new parameter will be documented as introduced in the wrong/nonexistent release; please use the actual 4.x target version.
    @Parameter(name = ApiConstants.ENABLED, type = CommandType.BOOLEAN, description = "OAuth provider will be enabled or disabled based on this value, defaults to true if not specified", since = "24.0.0")
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment on lines +171 to +174
for (UserOAuth2Authenticator authenticator : userOAuth2AuthenticatorPlugins) {
String name = authenticator.getName();
authenticatorPluginNames.add(name);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Ready

Development

Successfully merging this pull request may close these issues.

4 participants