Skip to content

[Fix-17813][ApiServer] Correct the password processing logic during data source modification - #18387

Open
njnu-seafish wants to merge 10 commits into
apache:devfrom
njnu-seafish:Fix-17813-2
Open

[Fix-17813][ApiServer] Correct the password processing logic during data source modification#18387
njnu-seafish wants to merge 10 commits into
apache:devfrom
njnu-seafish:Fix-17813-2

Conversation

@njnu-seafish

Copy link
Copy Markdown
Contributor

Was this PR generated or assisted by AI?

YES. Optimize and refine the code using AI after writing it.

Purpose of the pull request

close #17813

Brief change log

Add backend configuration to control datasource connection checks on create and update

Verify this pull request

This pull request is code cleanup without any test coverage.

(or)

This pull request is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(or)

Pull Request Notice

Pull Request Notice

If your pull request contains incompatible change, you should also add it to docs/docs/en/guide/upgrade/incompatible.md

ui-url: http://localhost:5173
audit-enable: false
# Whether to test datasource connectivity before creating or updating a datasource.
datasource-connection-enable: false

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.

You should add api-test or e2e-test to verify it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You should add api-test or e2e-test to verify it.

OK, add some test case.

Test Coverage Summary for api.datasource-connection-enable Configuration

This configuration controls whether the system tests data source connectivity before creating or updating a data source. The test suite covers both controller-level (API) and service-level scenarios.

Controller Layer Tests ( DataSourceControllerTest.java ):

  • testDatasourceConnectionEnableDefaultValue() - Verifies that the configuration defaults to false
  • testCreateDataSourceWithMockedService() - Tests successful data source creation API flow with valid connection parameters
  • testUpdateDataSourceWithMockedService() - Tests successful data source update API flow with valid connection parameters
  • testCreateDataSourceConnectionCheckDisabled() - Tests that data source creation succeeds even with invalid host when connection check is disabled (default behavior)
  • testUpdateDataSourceConnectionCheckDisabled() - Tests that data source update succeeds even with invalid host when connection check is disabled (default behavior)

Service Layer Tests ( DataSourceServiceTest.java ):

  • createDataSourceChecksConnectionWhenConfigured() - Verifies connection validation occurs when datasource-connection-enable=true during creation
  • updateDataSourceChecksConnectionWhenConfigured() - Verifies connection validation occurs when datasource-connection-enable=true during update
  • dataSourceDoesNotCheckConnectionByDefault() - Verifies connection validation is skipped when datasource-connection-enable=false

Test Strategy

  • Controller tests use MockBean to isolate the service layer and verify HTTP request/response handling
  • Service tests use Mockito to simulate connection success/failure scenarios and verify business logic
  • The default configuration ( api.datasource-connection-enable: false ) is set in application.yaml

Verification Scope :

  • Configuration property parsing and injection
  • API endpoint behavior under different configuration states
  • Connection validation logic conditional execution
  • Error handling when connection check fails (service layer)
  • Success path when connection check is disabled

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.

You don't understand what I mean. You can take a look at dolphinscheduler-api-test and dolphinscheduler-e2e

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You don't understand what I mean. You can take a look at dolphinscheduler-api-test and dolphinscheduler-e2e

thanks. I got it.

@njnu-seafish
njnu-seafish requested a review from SbloodyS July 20, 2026 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DSIP-101][ApiServer] How should the password be handled more elegantly when editing a data source?

2 participants