Skip to content

test: verify all connection paths work correctly #709

@NikolayS

Description

@NikolayS

Motivation

@mlusetti reported on X (2026-03-22) that rpg gives connection failed: db error where psql connects fine. The error message issue is fixed in #708, but the underlying connection compatibility needs a full audit.

All connection paths to test

A. TCP connections

# Method Example Expected
A1 Basic TCP rpg -h localhost -p 5432 -U postgres ✅/❌
A2 TCP with password rpg -h host -p 5432 -U user -W ✅/❌
A3 TCP with PGPASSWORD PGPASSWORD=x rpg -h host -U user ✅/❌
A4 TCP with .pgpass ~/.pgpass file, no password prompt ✅/❌
A5 TCP no port (default 5432) rpg -h localhost -U postgres ✅/❌
A6 TCP with database rpg -h localhost -U u -d mydb ✅/❌

B. Unix socket connections

# Method Example Expected
B1 Default socket rpg -U postgres (no -h) ✅/❌
B2 Explicit socket path rpg -h /var/run/postgresql -U postgres ✅/❌
B3 Socket with port suffix rpg -h /var/run/postgresql -p 5432 -U postgres ✅/❌
B4 PGHOST as socket dir PGHOST=/tmp rpg -U postgres ✅/❌

C. URI / connection string

# Method Example Expected
C1 postgres:// URI rpg postgres://user:pass@host/db ✅/❌
C2 postgres:// no password rpg postgres://user@host/db ✅/❌
C3 postgresql:// scheme rpg postgresql://user@host/db ✅/❌
C4 URI with sslmode rpg postgres://user@host/db?sslmode=require ✅/❌
C5 URI with socket rpg postgres:///db?host=/var/run/postgresql ✅/❌
C6 key=value connstring rpg "host=localhost user=u dbname=d" ✅/❌

D. SSL modes

# sslmode Expected
D1 disable ✅/❌
D2 prefer (default) ✅/❌
D3 require ✅/❌
D4 verify-ca ✅/❌
D5 verify-full ✅/❌

E. Environment variables

# Var Expected
E1 PGHOST ✅/❌
E2 PGPORT ✅/❌
E3 PGUSER ✅/❌
E4 PGPASSWORD ✅/❌
E5 PGDATABASE ✅/❌
E6 PGPASSFILE ✅/❌
E7 PGSERVICE / pg_service.conf ✅/❌
E8 PGSSLMODE ✅/❌
E9 PGCONNECT_TIMEOUT ✅/❌
E10 PGAPPNAME ✅/❌

F. Edge cases

# Case Expected
F1 Wrong password → clear error ✅/❌
F2 Wrong host → clear error (not 'db error') ✅/❌
F3 Connection refused → clear error ✅/❌
F4 Timeout → clear error with timeout value ✅/❌
F5 Multiple hosts (failover) ✅/❌
F6 target_session_attrs=read-write ✅/❌
F7 -c flag with connection ✅/❌
F8 Multiple -c flags ✅/❌
F9 -f flag (file input) ✅/❌

G. Auth methods

# Method Expected
G1 trust ✅/❌
G2 md5 ✅/❌
G3 scram-sha-256 ✅/❌
G4 peer (unix socket) ✅/❌

Test environment

Local Docker PGs available:

  • PG17: localhost:5433 (trust auth, user=postgres)
  • PG18: localhost:5435 (trust auth, user=postgres)
  • PG13: localhost:5434 (trust auth, user=postgres)

Definition of done

All ✅ or filed as separate bugs with reproduction steps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions