test: renew the expired server certificate, add a podman/docker test-server script - #430
Conversation
…server script
docker/certs/server.crt expired on 2024-12-20. Every image built from
docker/ since then has presented an expired certificate, so the TLS
handshake fails and the whole server-dependent suite fails with
Tls("connection closed via error") — which reads like a client bug rather
than a stale fixture.
Regenerated with the repository's own certs/generate-signed-cert.sh. The
customCA is untouched and still valid until 2027-11-14; only the leaf is
renewed, so nothing that trusts the CA needs updating.
Also adds docker/test-server.sh, which builds, starts and waits for a
server with either podman or docker:
./docker/test-server.sh up
export TIBERIUS_TEST_CONNECTION_STRING='server=tcp:localhost,1433;user=SA;password=<YourStrong@Passw0rd>;IntegratedSecurity=true;TrustServerCertificate=true'
cargo test
It defaults to the azure-sql-edge image because the full SQL Server images
are x86_64 only, so on arm64 they refuse to run or run under emulation.
It polls the log for readiness rather than the port, because the port
accepts connections well before the server answers.
Verified: 390 tests pass against a server built by this script.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review. Summary by CodeRabbit
WalkthroughThe change renews the server certificate chain, private key, and certificate serial metadata. It adds a Bash utility that builds and runs a SQL Server test container through Podman or Docker. The utility supports configurable settings, readiness polling, failure diagnostics, container removal, and log following. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
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. Comment |
Additive helper from upstream #430 (author Joel Parker Henderson): brings a SQL Server container up under podman or docker, defaults to arm64-friendly azure-sql-edge, and polls the log for readiness. (The cert-renewal part of #430 is already covered by #419.)
Mirrors the non-cert-renewal half of tiberius-rs/tiberius#430. The cert-renewal half is moot here -- this fork's docker/certs/server.crt was already regenerated with a 5-year validity in ea6bb6a -- so only the new script is added, ported to this fork's mssql crate name and MSSQL_TEST_CONNECTION_STRING (was TIBERIUS_TEST_CONNECTION_STRING). `./docker/test-server.sh up|down|logs` builds and starts a local SQL Server via podman or docker (auto-detected, podman preferred), defaulting to azure-sql-edge for cross-arch (x86_64/arm64) portability, and polls the container log for the ready message rather than the socket (the port opens well before the server will answer). Verified end to end, not just started: ran it against a real container and used it to run 276 tests (196 in tests/query.rs, 80 in tests/bulk.rs) against a live SQL Server via the rustls feature, which is also how two real bugs were found and fixed in the two preceding commits. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0156Di1tRRLsJK8ctU1AmAJr
Mirrors the non-cert-renewal half of tiberius-rs/tiberius#430. The cert-renewal half is moot here -- this fork's docker/certs/server.crt was already regenerated with a 5-year validity in 430202d -- so only the new script is added, ported to this fork's mssql crate name and MSSQL_TEST_CONNECTION_STRING (was TIBERIUS_TEST_CONNECTION_STRING). `./docker/test-server.sh up|down|logs` builds and starts a local SQL Server via podman or docker (auto-detected, podman preferred), defaulting to azure-sql-edge for cross-arch (x86_64/arm64) portability, and polls the container log for the ready message rather than the socket (the port opens well before the server will answer). Verified end to end, not just started: ran it against a real container and used it to run 276 tests (196 in tests/query.rs, 80 in tests/bulk.rs) against a live SQL Server via the rustls feature, which is also how two real bugs were found and fixed in the two preceding commits. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0156Di1tRRLsJK8ctU1AmAJr
I'm human. During my Rust work, this issue below came up during AI automatic review. The issue report below is by Claude. Happy to explain more if that can help. -Joel
The problem
docker/certs/server.crtexpired on 2024-12-20.Every image built from
docker/since then presents an expired certificate. The server starts fine and reports the certificate loaded successfully, so nothing looks wrong from its side — but the client aborts the handshake, and the entire server-dependent suite fails with:That reads like a client or configuration bug rather than a stale fixture, which makes it an expensive thing to walk into. It is currently the first thing a new contributor hits when they try to run the tests.
The fix
Regenerated with this repository's own
docker/certs/generate-signed-cert.sh, unchanged:The
customCAis untouched and remains valid until 2027-11-14, so only the leaf is renewed and anything already trusting the CA keeps working.openssl verify -CAfile customCA.crt server.crtpasses.The script mints 200-day certificates, so this will lapse again around March 2027. Worth a calendar note, or a CI job that fails when the leaf is within a month of expiry — happy to add the latter here if you want it.
Also:
docker/test-server.shA small script that brings a server up under podman or docker, since there was no one-liner for this:
It picks podman if present, otherwise docker, and both engine and image are overridable (
ENGINE=docker IMAGE=mssql-2022 ./docker/test-server.sh up).Two decisions worth explaining:
azure-sql-edge. The full SQL Server images are x86_64 only, so on arm64 (Apple silicon) they refuse to run or run slowly under emulation. The edge image is the one that works on both, and this repo already had a dockerfile for it.docker-compose.ymlis left alone — this is additive.Verification
With the certificate renewed, against a server built by this script:
One thing I did not fix
With the renewed certificate the suite passes under
--features rustls, but still fails under the defaultnative-tlson macOS with the sameTls("connection closed via error"). The server log shows no complaint, so the rejection is client-side in Security.framework. I did not chase it down and it is out of scope here — but it means a macOS contributor running plaincargo testwill still see failures after this PR, and I would rather say so than let it look fixed.