Skip to content

test: extend identity injection and auth header regression coverage#385

Draft
cursor[bot] wants to merge 12 commits into
mainfrom
cursor/missing-test-coverage-a802
Draft

test: extend identity injection and auth header regression coverage#385
cursor[bot] wants to merge 12 commits into
mainfrom
cursor/missing-test-coverage-a802

Conversation

@cursor

@cursor cursor Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds focused regression tests for recently merged identity-injection and auth-header behavior in the Harness MCP server.

Risky behavior now covered

  • Wrapped-body identifier injectionbuildBodyNormalized must inject connector_id / service_id / environment_id into wrapped YAML/JSON update bodies, not the outer envelope.
  • Conflicting identifiers — update calls must fail before the API when resource_id and body identifier disagree (connectors, services, environments).
  • Create vs update semantics — connector create must not silently substitute connector_id for a missing body identifier; explicit body identifiers are preserved.
  • Case-insensitive auth headers — caller-provided Authorization / x-api-key must be honored regardless of header casing; FME requests must strip all x-api-key variants.
  • FME duplicate x-api-key headers — when multiple x-api-key headers are present, the first non-placeholder value is used for bearer auth and all variants are removed before the request is sent.
  • Disabled toolset resources — pipeline YAML and execution summary resources degrade gracefully when their toolsets are disabled.
  • Scalar identifier coercion — numeric/boolean body identifiers are compared against string resource_id values without false conflicts.

Test files added/updated

File Coverage
tests/utils/body-normalizer.test.ts Wrapped/unwrapped injection, YAML parsing, conflict detection, injectFields with wrapKey, boolean/numeric coercion
tests/client/harness-client.test.ts Case-insensitive auth preservation, FME x-api-key stripping, duplicate-header bearer selection
tests/tools/tool-handlers.test.ts End-to-end harness_update / harness_create flows for connector, service, and environment identity handling
tests/resources/pipeline-yaml.test.ts Disabled pipeline toolset discovery and direct-read fallback
tests/resources/execution-summary.test.ts Disabled execution toolset skip behavior

Why this reduces regression risk

These paths sit on the boundary between agent input and Harness API calls — silent mis-injection or auth layering bugs cause hard-to-debug 4xx failures or credential leaks to third-party endpoints (Split.io). The tests lock the public contract at both the unit layer (body-normalizer, HarnessClient) and the tool dispatch layer (harness_update/harness_create), so refactors to shared body builders or header helpers cannot regress without a failing test.

Validation

pnpm test  # 2111 passed
Open in Web View Automation 

cursoragent and others added 12 commits June 11, 2026 11:09
Co-authored-by: Rohan Gupta <thisrohangupta@users.noreply.github.com>
Co-authored-by: Rohan Gupta <thisrohangupta@users.noreply.github.com>
Co-authored-by: Rohan Gupta <thisrohangupta@users.noreply.github.com>
Co-authored-by: Rohan Gupta <thisrohangupta@users.noreply.github.com>
Co-authored-by: Rohan Gupta <thisrohangupta@users.noreply.github.com>
Co-authored-by: Rohan Gupta <thisrohangupta@users.noreply.github.com>
Co-authored-by: Rohan Gupta <thisrohangupta@users.noreply.github.com>
Add focused unit tests for buildBodyNormalized wrapped-body identifier
injection and conflict detection, plus harness-client non-FME header
casing and connector update success path regression coverage for PR #328.

Co-authored-by: Rohan Gupta <thisrohangupta@users.noreply.github.com>
Co-authored-by: Rohan Gupta <thisrohangupta@users.noreply.github.com>
Co-authored-by: Rohan Gupta <thisrohangupta@users.noreply.github.com>
…nd create path

Add body-normalizer unit tests for unwrapKey injection (service, environment)
and flat-body override updates. Add harness_update integration tests for
service identifier injection and environment conflict rejection. Assert
connector create never auto-injects connector_id from params.

Co-authored-by: Rohan Gupta <thisrohangupta@users.noreply.github.com>
… id coercion

Co-authored-by: Rohan Gupta <thisrohangupta@users.noreply.github.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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