connectedhomeip
Cherry-pick #37695 to v1.4-branch
#37713
Merged

Cherry-pick #37695 to v1.4-branch #37713

swan-amazon
swan-amazon38 days ago

…oading (#37695)

  • Refactor mock server to support distributed configuration loading

Refactors the mock server implementation to support loading configuration from multiple JSON files, enabling flexible mocking of different services during Matter device commissioning validation.

Key Changes:

  • Restructured configuration loading to support directory-based routing configs
  • Added dataclass-based type safety for configuration and route definitions
  • Updated path handling to use pathlib.Path for better cross-platform support
  • Modified server launch configuration to support routing config directory
  • Added configurations for mocking multiple services:
    • Distributed Compliance Ledger (DCL)
    • Product Terms & Conditions server

Technical Improvements:

  • Introduced strongly typed Route and Configuration classes
  • Simplified route matching logic with dedicated matcher
  • Improved error handling for configuration loading
  • Updated unit tests to support new configuration structure

The changes enable quick iteration of mock service responses during preproduction testing and PlugFest validation, particularly for testing new commissioning flows that rely on DCL-based configuration with indirect product server references.

Test Configuration:

  • Added example configurations for VID:65521/65522, PID:32769
  • Updated TC URL endpoints to use port 44538
  • Included sample Terms & Conditions responses
  • server: Add validation checks for SSL certificate and key files

Add input validation to verify that SSL certificate and key files exist and are regular files before attempting to create the SSL context. This provides clearer error messages to users when certificate files are missing or invalid, following the same validation pattern used for config files.

Testing

Tested on origin/master

swan-amazon [Testing] Refactor mock server to support distributed configuration l…
d095e167
semanticdiff-com
semanticdiff-com38 days ago (edited 38 days ago)

Review changes with  SemanticDiff

Changed Files
File Status
  .vscode/launch.json  13% smaller
  .github/.wordlist.txt Unsupported file format
  examples/chip-tool/commands/dcl/test_dcl_server.py  0% smaller
  integrations/mock_server/README.md Unsupported file format
  integrations/mock_server/configurations/fake_distributed_compliance_ledger/dcl-model-models-65521-32769.json  0% smaller
  integrations/mock_server/configurations/fake_distributed_compliance_ledger/dcl-model-models-65521-32785.json  0% smaller
  integrations/mock_server/configurations/fake_distributed_compliance_ledger/dcl-model-models-65521-32786.json  0% smaller
  integrations/mock_server/configurations/fake_distributed_compliance_ledger/dcl-model-models-65522-32769.json  0% smaller
  integrations/mock_server/configurations/fake_product_server/terms-and-conditions-65521-32769-v1.json  0% smaller
  integrations/mock_server/configurations/fake_product_server/terms-and-conditions-65521-32785-v1.json  0% smaller
  integrations/mock_server/configurations/fake_product_server/terms-and-conditions-65521-32786-v1.json  0% smaller
  integrations/mock_server/configurations/fake_product_server/terms-and-conditions-65522-32769-v1.json  0% smaller
  integrations/mock_server/configurations/server_config.json  0% smaller
  integrations/mock_server/configurations/unittest/config.json  0% smaller
  integrations/mock_server/src/__init__.py  0% smaller
  integrations/mock_server/src/handler.py  0% smaller
  integrations/mock_server/src/main.py  0% smaller
  integrations/mock_server/src/route_configuration.py  0% smaller
  integrations/mock_server/src/router.py  0% smaller
  integrations/mock_server/src/server.py  0% smaller
  integrations/mock_server/tests/__init__.py  0% smaller
  integrations/mock_server/tests/test_mock_server.py  0% smaller
github-actions github-actions added tools
github-actions github-actions added examples
github-actions github-actions added integrations
github-actions github-actions added vscode
github-actions github-actions added github
swan-amazon swan-amazon marked this pull request as ready for review 38 days ago
andy31415
andy31415 approved these changes on 2025-02-21
andy31415 andy31415 merged 2b4717e3 into v1.4-branch 37 days ago
swan-amazon swan-amazon deleted the v1.4-branch/cherry-pick-37695 branch 25 days ago

Login to write a write a comment.

Login via GitHub

Reviewers
Assignees
No one assigned
Labels
Milestone