microsoft / microsoft/mssql-rs

Add capability-based gating for ODBC e2e tests (mssql-odbc)

Open
#117 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Rust
Stars
53
Forks
14
Avg merge
1d 15h
Merged PRs (30d)
137

Description

Problem statement

The ODBC e2e DriverConnectLiveTest fixture gates every live test on ODBCTestConfig::HasConnection(), which is true whenever any connection method is configured (ODBC_TEST_CONNSTR, ODBC_TEST_DSN, or ODBC_TEST_SERVER). Most tests are fine with "any connection string that authenticates."

But some tests have stronger requirements. The connection-string parser-parity tests (MalformedTokenReturnsSuccessWithInfo, ConnectionStringParserParityBehaviors) assemble their own login strings from cfg.Server()/Uid()/Pwd() and deliberately corrupt individual auth tokens. In environments configured via ODBC_TEST_CONNSTR, a DSN, or integrated auth, Uid()/Pwd() are legitimately empty, so these tests would build broken empty-credential strings and fail even though the suite is configured correctly.

A tactical guard was added in PR #107 (ODBCTestConfig::HasSqlAuth() + GTEST_SKIP) to stop the spurious failures. This issue tracks the proper design: a small capability model so tests can declare what they need instead of hand-checking individual fields.

Proposed solution

Introduce a capability model on ODBCTestConfig and let each test declare its requirements:

  • enum class ODBCCap { SqlAuth, MutableDatabase, IntegratedAuth, Dsn, Encrypt };
  • bool ODBCTestConfig::HasCapability(ODBCCap) const;
    • SqlAuth = Server && Uid && Pwd all present
    • other values wired as best-effort predicates for future tests
  • A one-line per-test skip helper (macro-backed, because GTEST_SKIP() must return from the test body to actually skip):
    • ODBC_REQUIRE_CAP(ODBCCap::SqlAuth); at the top of a test
  • Base-connection reuse so auth-neutral tests append to the configured connection instead of rebuilding it:
    • std::string ODBCTestUtils::BuildConnectionStringNarrow() delegating to the existing BuildConnectionString() (single source of truth), plus the existing SqlTString overload.

Then split the parser-parity tests:

  • Auth-neutral cases (assert 01S00, connection still succeeds) append malformed tokens to BuildConnectionStringNarrow() and run against any working config — no capability gate.
  • Identity-corruption cases (assert SQL_ERROR + 28000, and first-wins duplicates) declare ODBC_REQUIRE_CAP(ODBCCap::SqlAuth).

Note on first-wins: keep those UID-based under SqlAuth rather than converting to duplicate Database keys — BuildConnectionString() already emits a Database= key and the parser is first-wins, so an appended Database=bad;Database=good would lose to the base's existing Database and silently break the negative case.

Affected crate

Not sure / Multiple

Alternatives considered
  • Keep the tactical HasSqlAuth() + inline GTEST_SKIP (current state in PR #107): works, but every future special-requirement test re-implements its own field checks; doesn't scale.
  • A dedicated SqlAuthLiveTest fixture whose SetUp() skips unless SQL auth is present: reasonable, but a capability enum is more flexible when a test needs a combination of capabilities and keeps the requirement visible at the call site.
Additional context

Tactical fix commit: f457cff on saurabh500-odbc-connstr-parser (PR #107). The parity tests live in mssql-odbc/tests/e2e/tests/driver_connect_test.cpp; the fixture/config are in mssql-odbc/tests/e2e/include/odbc_test_fixture.h and lib/odbc_test_config.cpp; the base builder is ODBCTestUtils::BuildConnectionString() in lib/odbc_test_utils.cpp.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read mssql-odbc/tests/e2e/tests/driver_connect_test.cpp, mssql-odbc/tests/e2e/include/odbc_test_fixture.h, lib/odbc_test_config.cpp, and lib/odbc_test_utils.cpp, starting with the existing HasSqlAuth guard and connection-string builder. Add the capability checks and reuse the base connection string, then split the parser-parity cases so auth-neutral tests run with any configured connection and identity-corruption cases require SqlAuth.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, sql
Domain
databases, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.