Skip to content

fix(sql_workbench): set passwordSaved on ODC datasource sync requests#642

Merged
Seechi-Yolo merged 3 commits into
mainfrom
dms/fix-886
Jun 18, 2026
Merged

fix(sql_workbench): set passwordSaved on ODC datasource sync requests#642
Seechi-Yolo merged 3 commits into
mainfrom
dms/fix-886

Conversation

@LordofAvernus

@LordofAvernus LordofAvernus commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

User description

Summary

  • Add passwordSaved to ODC create/update datasource request structs
  • Set passwordSaved: true when DMS syncs datasources to ODC SQL workbench
  • Add unit tests for passwordSaved on ODC sync requests

Problem

After editing a datasource password in DMS, ODC connect_connection.password could remain unchanged because the update request did not explicitly indicate the password should be saved and re-encrypted.

Test plan

  • go test ./internal/sql_workbench/service -run PasswordSaved

Fixes actiontech/dms-ee#886


Description

  • 为创建更新请求添加PasswordSaved字段

  • 服务层自动设置PasswordSaved为true

  • 添加单元测试验证字段正确性


Diagram Walkthrough

flowchart LR
  client["\"internal/sql_workbench/client/sql_workbench_client.go\""]
  service["\"internal/sql_workbench/service/sql_workbench_service.go\""]
  test["\"internal/sql_workbench/service/sql_workbench_service_test.go\""]
  client -- "新增字段定义" --> service
  service -- "内置字段值设置" --> test
Loading

File Walkthrough

Relevant files
Enhancement
sql_workbench_client.go
新增PasswordSaved字段到数据源请求                                                                   

internal/sql_workbench/client/sql_workbench_client.go

  • 添加PasswordSaved字段到创建请求结构
  • 添加PasswordSaved字段到更新请求结构
+2/-0     
sql_workbench_service.go
服务层设置PasswordSaved字段逻辑                                                                     

internal/sql_workbench/service/sql_workbench_service.go

  • 在构建创建请求时设置PasswordSaved: true
  • 在构建更新请求时设置PasswordSaved: true
+2/-0     
Tests
sql_workbench_service_test.go
添加PasswordSaved字段的单元测试                                                                     

internal/sql_workbench/service/sql_workbench_service_test.go

  • 导入encoding/json
  • 添加单元测试检查PasswordSaved字段
  • 验证创建与更新请求中PasswordSaved值
+85/-0   

Refs #886

Explicitly send passwordSaved:true when creating or updating ODC
datasources so edited passwords are encrypted into connect_connection
instead of silently retaining the previous ciphertext.
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit 3c1a160)

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@github-actions

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
确认密码保存字段逻辑


请确认在数据结构中新增的PasswordSaved字段是否符合预期业务逻辑,避免因默认值设置不当导致密码状态误判。建议在代码或文档中说明该字段的作用和默认行为,以便后续维护人员理解。

internal/sql_workbench/client/sql_workbench_client.go [982]

+// PasswordSaved标志用于指示密码是否已被安全保存。请确保此默认行为与业务逻辑保持一致。
 PasswordSaved     bool                   `json:"passwordSaved"`
Suggestion importance[1-10]: 3

__

Why: The suggestion asks to verify the business logic for the new PasswordSaved field without changing functionality. Its impact is minimal, serving mainly as a reminder to document the behavior.

Low
审查标志字段设置


请确认在buildCreateDatasourceRequestbuildUpdateDatasourceRequest中将PasswordSaved硬编码为true是否符合实际业务场景。建议审查此处逻辑,确保在不同情况下均能正确反映密码保存状态,避免后续可能导致逻辑错误。

internal/sql_workbench/service/sql_workbench_service.go [940]

-PasswordSaved:     true,
+PasswordSaved:     true, // 请确保此处与实际业务需求匹配
Suggestion importance[1-10]: 3

__

Why: The suggestion points out the hardcoded use of PasswordSaved: true and advises a review, but it only appends a comment. Its effect is limited to documentation and confirmation of intent.

Low

Add service tests asserting passwordSaved on ODC sync requests and an HTTP
E2E script that rotates real Mongo credentials to verify ODC recovery.
@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit 13138c4

@github-actions

Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.

Keep unit tests only; integration script stays in local workspace.
@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit 3c1a160

@github-actions

Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.

@Seechi-Yolo Seechi-Yolo merged commit fa090a0 into main Jun 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants