Skip to content

test(binding-http): add unit tests for CORS behavior - #1486

Merged
relu91 merged 2 commits into
eclipse-thingweb:masterfrom
siddharthbaleja7:test/cors-unit-tests
Feb 18, 2026
Merged

relu91 merged 2 commits into
eclipse-thingweb:masterfrom
siddharthbaleja7:test/cors-unit-tests

Conversation

@siddharthbaleja7

Copy link
Copy Markdown
Contributor

Description

This PR adds unit tests to binding-http to verify CORS behavior, addressing the need for regression testing mentioned in issue #938.

The new tests cover:

  • CORS headers for nosec security scheme (wildcard origin).
  • CORS headers for basic security scheme (reflected origin + credentials), covering both authorized (200) and unauthorized (401) responses.
  • CORS headers for OPTIONS preflight requests.

Motivation and Context

Currently, http-server implements CORS logic but lacks specific unit tests. These tests ensure that CORS headers are correctly set for different security configurations and request types, preventing future regressions.

How Has This Been Tested?

  • Ran npm run test in packages/binding-http.
  • Verified that all 80 tests (including the 4 new CORS tests) passed.
  • Ran npm run lint and npm run format to ensure code quality.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Test (adding missing tests or correcting existing tests)

Checklist:

  • My code follows the code style of this project.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@relu91 relu91 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.

Good job! I'd probably just extend this current list of tests with also "writing" operations, which means testing: POST requests too (and cover writable properties + actions invocations). Can you add those cases too?

@relu91 relu91 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.

good to go! Thanks!

@relu91
relu91 merged commit 2e6b59c into eclipse-thingweb:master Feb 18, 2026
14 checks passed
@relu91 relu91 mentioned this pull request Feb 27, 2026
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.

3 participants