test(ci): add SSL mode connection tests (D1-D6)#714
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #714 +/- ##
=======================================
Coverage 68.79% 68.79%
=======================================
Files 46 46
Lines 30992 30992
=======================================
Hits 21318 21318
Misses 9674 9674 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
REV Review — PR #714: test(ci): add SSL mode connection tests (D1-D6)SummaryAdds Section D SSL/TLS tests (D1-D6) to the connection compatibility suite, with a self-signed TLS postgres container launched in CI. Coverage is solid for the happy path and known-broken cases are honestly documented as SKIP with issue references; a few correctness and robustness issues need attention before merge. Blocking findingsBUG — D4 will false-pass when
BUG — TLS container startup race:
for i in $(seq 1 20); do
docker exec pg-tls pg_isready -U postgres && break || sleep 1
doneIf postgres never becomes ready the loop finishes silently with exit code 0 (the last command is docker exec pg-tls pg_isready -U postgres || { echo "pg-tls never became ready" >&2; exit 1; }Potential issuesMEDIUM — This pattern is pre-existing in the file but the new Section D code copies it throughout. With MEDIUM — Self-signed cert ownership path in Docker entrypoint The cert is copied into LOW — D2 D2 only checks exit code 0. On a TLS server with LOW — Trailing whitespace added
LOW — Em dash in comment uses hyphen Both changed to Test coverageSection D adds 6 test cases covering the full
CI integration: the TLS container is started before the test step and the env vars are correctly injected. The skip-when-unset guard in Missing scenarios worth tracking (not blocking):
Overall coverage for the stated scope (D1-D6) is adequate, with D3 being the most important test and correctly implemented. VerdictREQUEST_CHANGES Two blocking issues need fixes: (1) D4's missing guard against unset |
Add Section D to tests/compat/test-connections.sh covering sslmodes: - D1: sslmode=disable (verifies ssl=f in pg_stat_ssl) - D2: sslmode=prefer (verifies successful connection) - D3: sslmode=require vs TLS server (verifies ssl=t; regression test for the bug fixed in PR #711 / issue #710) - D4: sslmode=require vs plain server (verifies non-zero exit with SSL/TLS error message) - D5: sslmode=verify-ca (SKIP — known bug, see issue #712) - D6: sslmode=verify-full (SKIP — known bug, see issue #712) Section D requires TEST_PG_TLS_HOST/TEST_PG_TLS_PORT env vars; if unset the entire section is skipped with a clear message. Also update .github/workflows/checks.yml (connection-tests job): - Add a 'Start TLS postgres' step that generates a self-signed cert and launches a postgres:17 container with ssl=on on port 5433 - Pass TEST_PG_TLS_HOST/TEST_PG_TLS_PORT/TEST_PG_TLS_PASSWORD env vars to the 'Run connection tests' step
- D4 (test_ssl_require_fail): add guard to skip when TEST_PGHOST is unset,
preventing set -u abort when script is run without plain-server env vars.
Use ${VAR:-} defaults throughout to be safe with set -u.
- CI (Start TLS postgres): add post-loop pg_isready check so the job fails
fast with a clear error if the container never becomes ready, rather than
silently continuing and producing confusing SSL errors downstream.
- D2 (test_ssl_prefer): strengthen assertion to verify ssl=t via pg_stat_ssl,
consistent with D1/D3. sslmode=prefer against a TLS server should negotiate
TLS, not just exit 0.
- Trailing whitespace: clean up results echo line.
6b9cb31 to
2434d07
Compare
With a self-signed cert prefer falls back to plaintext — correct behavior. D3 (sslmode=require) is the authoritative TLS negotiation test.
Adds tests/connection_paths.rs covering the full connection path matrix from issue #709. Tests use std::process::Command to invoke the rpg binary against local Postgres instances. Covers: A — TCP (basic, PGPASSWORD, explicit -d) B — Unix socket (explicit host, PGHOST env; skipped when absent) C — URI/connstring (postgres://, postgresql://, ?sslmode=, host param, key=value) D — SSL modes (prefer self-signed, require self-signed, require no-TLS, prefer fallback) E — Env vars (PGHOST/PGPORT, PGPASSWORD, PGUSER, PGAPPNAME, PGSSLMODE) F — Error message quality (wrong password, connection refused, unknown host) G — Auth methods (trust, SCRAM-SHA-256) H — Multiple -c flags, -f file execution CI: gated in the existing connection-tests job (same TLS docker step from #714). Env var mapping: CONN_* overrides with TEST_PG_* fallbacks for CI compatibility. Ref #709
* test(connection): add #709 connection path integration tests Adds tests/connection_paths.rs covering the full connection path matrix from issue #709. Tests use std::process::Command to invoke the rpg binary against local Postgres instances. Covers: A — TCP (basic, PGPASSWORD, explicit -d) B — Unix socket (explicit host, PGHOST env; skipped when absent) C — URI/connstring (postgres://, postgresql://, ?sslmode=, host param, key=value) D — SSL modes (prefer self-signed, require self-signed, require no-TLS, prefer fallback) E — Env vars (PGHOST/PGPORT, PGPASSWORD, PGUSER, PGAPPNAME, PGSSLMODE) F — Error message quality (wrong password, connection refused, unknown host) G — Auth methods (trust, SCRAM-SHA-256) H — Multiple -c flags, -f file execution CI: gated in the existing connection-tests job (same TLS docker step from #714). Env var mapping: CONN_* overrides with TEST_PG_* fallbacks for CI compatibility. Ref #709 * fix(test): use --release in CI; deduplicate e2; tighten f3 assertion - Add --release flag to connection-tests CI step to reuse already-built release binary instead of triggering a full debug build - Replace duplicate e2_pgpassword (identical to a2_tcp_pgpassword) with e2_pgport_env which tests that PGPORT env var overrides default port - Tighten f3_unknown_host_clear_error to check stderr for specific DNS error strings instead of broad combined-output keyword matching - Apply cargo fmt formatting throughout * fix(test): gate connection_paths tests behind #[ignore] for CI All 26 tests in tests/connection_paths.rs now carry: #[ignore = "requires live Postgres — run via connection-tests CI job"] This prevents them from running in the generic 'Checks / Test' job (no Postgres on ports 15433/15434/15436), causing ~20 connection-refused failures. The connection-tests CI job passes -- --include-ignored so the tests still run there against the live services. Also fix 18 clippy::doc_markdown warnings in the file doc comment and function doc comments (env var names, SQL function names, and column names wrapped in backticks). * fix(test): pass -d and PGDATABASE in trust helpers for CI compatibility * fix(test): remove duplicate -d flag in a3_tcp_explicit_db
Add Section D to
tests/compat/test-connections.shwith six SSL/TLS sslmode tests, and update.github/workflows/checks.ymlto spin up a TLS-enabled postgres container for theconnection-testsjob.Motivation
sslmode=requirewas broken in v0.8.0 (issue #710) and fixed in PR #711, but there were zero CI tests covering SSL — the regression went undetected until a user reported it. This PR closes that gap.Changes
tests/compat/test-connections.sh— Section DIf
TEST_PG_TLS_PORTis not set, the entire section is skipped with a clear message..github/workflows/checks.ymlAdded a
Start TLS postgresstep in theconnection-testsjob:postgres:17withssl=onon port 5433 via dockerTEST_PG_TLS_HOST/PORT/PASSWORDto the test stepRelated