Skip to content

test: MongoDB driver — normalizeConfig aliases and detectAuthMethod#510

Closed
anandgupta42 wants to merge 1 commit intomainfrom
test/hourly-20260327-1111
Closed

test: MongoDB driver — normalizeConfig aliases and detectAuthMethod#510
anandgupta42 wants to merge 1 commit intomainfrom
test/hourly-20260327-1111

Conversation

@anandgupta42
Copy link
Copy Markdown
Contributor

@anandgupta42 anandgupta42 commented Mar 27, 2026

What does this PR do?

MongoDB driver support was added in v0.5.13 (commit abcaa1d, PR #482), but the config normalization aliases and auth method detection for MongoDB had zero test coverage. This PR adds targeted tests to close that gap.

1. normalizeConfig — MongoDB aliases in packages/drivers/src/normalize.ts (10 new tests)

The MONGODB_ALIASES map (lines 76–84) and the mongo type alias (lines 99–100) were added alongside the MongoDB driver but the existing test file (driver-normalize.test.ts) covered every other driver type except MongoDB. Without these tests, a regression in alias resolution would cause silent connection failures for users configuring MongoDB with dbt/SDK-style field names like uri, connectionString, authSource, replicaSet, etc.

New coverage includes:

  • Each individual alias: connectionString, uri, urlconnection_string; authSourceauth_source; replicaSetreplica_set; directConnectiondirect_connection; connectTimeoutMSconnect_timeout; serverSelectionTimeoutMSserver_selection_timeout
  • The mongo type alias resolves identically to mongodb
  • A combined test verifying all aliases resolve correctly in a single realistic config object

2. detectAuthMethod — MongoDB auth detection in src/altimate/native/connections/registry.ts (4 new assertions)

The MongoDB-specific auth detection branch (line 229) was added but had no test assertions. Added coverage for:

  • connection_string field → "connection_string"
  • password field → "password" (caught by generic check at line 226)
  • Bare mongodb type with no credentials → "connection_string" fallback (line 229)
  • mongo type alias → same fallback behavior

Type of change

  • New feature (non-breaking change which adds functionality)

Issue for this PR

N/A — proactive test coverage for newly shipped MongoDB driver support

How did you verify your code works?

bun test test/altimate/driver-normalize.test.ts       # 88 pass (78 existing + 10 new)
bun test test/altimate/telemetry-safety.test.ts --test-name-pattern "detectAuthMethod"  # 2 pass (4 new assertions in existing test)

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

https://claude.ai/code/session_01U7mUcNzrnXfdtJSJxVTuQv

Summary by CodeRabbit

  • Tests
    • Expanded test coverage for MongoDB configuration normalization, including alias property resolution and authentication method detection.

…overage

MongoDB support was added in v0.5.13 (commit abcaa1d) but the normalize alias map
and auth detection had zero test coverage, risking silent connection failures for
users configuring MongoDB with dbt/SDK-style field names.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

https://claude.ai/code/session_01U7mUcNzrnXfdtJSJxVTuQv
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3f836a99-fea4-48c4-b8ed-7a8f6b9a0798

📥 Commits

Reviewing files that changed from the base of the PR and between abcaa1d and 1697954.

📒 Files selected for processing (2)
  • packages/opencode/test/altimate/driver-normalize.test.ts
  • packages/opencode/test/altimate/telemetry-safety.test.ts

📝 Walkthrough

Walkthrough

This pull request adds comprehensive test coverage for MongoDB configuration normalization and authentication method detection, including alias property resolution and type alias handling without modifications to production code.

Changes

Cohort / File(s) Summary
MongoDB Config Normalization Tests
packages/opencode/test/altimate/driver-normalize.test.ts
New test suite verifying alias normalization for MongoDB configs, asserting that connection properties (connectionString, uri, url) normalize to connection_string and that configuration properties like authSource, replicaSet, directConnection, and timeout settings normalize to their snake_case equivalents with original alias fields removed.
Auth Method Detection Tests
packages/opencode/test/altimate/telemetry-safety.test.ts
Extended test coverage for detectAuthMethod function with MongoDB scenarios, validating that type: "mongodb" with various auth configurations (connection_string, omitted, password) and the mongo type alias correctly resolve to appropriate auth methods.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

Suggested labels

contributor

Poem

🐰 Config fields hop and dance,
Aliases normalize in perfect stance—
camelCase to snake_case they fly,
MongoDB's secrets safely comply! 🔐

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately and concisely summarizes the main changes: adding MongoDB-specific tests for normalizeConfig aliases and detectAuthMethod.
Description check ✅ Passed The PR description comprehensively covers all required template sections with detailed context, test coverage details, verification steps, and completed checklists.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/hourly-20260327-1111

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

anandgupta42 added a commit that referenced this pull request Mar 27, 2026
Deduplicate overlapping tests from PRs #494, #499, #502, #504, #506,
#507, #508, #510, #511, #512. Most MongoDB/env-var/dbt coverage was
already on main; this adds only genuinely new tests:

- SSH tunnel: `extractSshConfig` validation + lifecycle safety (7 tests)
- dbt profiles: spark->databricks, trino->postgres adapter mapping
- `dbtConnectionsToConfigs` conversion + empty input handling
- `containerToConfig` with fully-populated container
- MongoDB assertions in `telemetry-safety.test.ts`
- Sanity suite: branding, deny, driver, resilience expansions (#494)

Closes #513

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@anandgupta42
Copy link
Copy Markdown
Contributor Author

Consolidated into #514. This PR's test coverage was either already on main or has been included in the consolidated PR.

anandgupta42 added a commit that referenced this pull request Mar 27, 2026
…514)

* test: consolidate test coverage from 10 hourly PRs into single PR

Deduplicate overlapping tests from PRs #494, #499, #502, #504, #506,
#507, #508, #510, #511, #512. Most MongoDB/env-var/dbt coverage was
already on main; this adds only genuinely new tests:

- SSH tunnel: `extractSshConfig` validation + lifecycle safety (7 tests)
- dbt profiles: spark->databricks, trino->postgres adapter mapping
- `dbtConnectionsToConfigs` conversion + empty input handling
- `containerToConfig` with fully-populated container
- MongoDB assertions in `telemetry-safety.test.ts`
- Sanity suite: branding, deny, driver, resilience expansions (#494)

Closes #513

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: address code review findings from 6-model consensus review

- Use `require.resolve()` instead of `require()` for driver resolvability
  checks to avoid false negatives from native binding load failures
- Remove unnecessary `altimate_change` markers from new ssh-tunnel test file
- Add `closeAllTunnels()` cleanup in `afterEach` to prevent state leaks

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: address convergence review findings — driver warns, unshare guard

- Driver resolvability checks now emit warnings instead of failures
  since drivers are intentionally absent from sanity Docker image (#295)
- `unshare --net` now tests with a dry-run before use, falling back to
  proxy-based network blocking when unprivileged (macOS, containers)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants