Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions smoketests/tests/pg_wire.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
import psycopg2


def psql(identity: str, sql: str, extra=None) -> str:
def psql(identity: str, sql: str) -> str:
"""Call `psql` and execute the given SQL statement."""
if extra is None:
extra = dict()
result = subprocess.run(
["psql", "-h", "127.0.0.1", "-p", "5432", "-U", "postgres", "-d", "quickstart", "--quiet", "-c", sql],
encoding="utf8",
env={**os.environ, **extra, "PGPASSWORD": identity},
env={**os.environ, "PGPASSWORD": identity},
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
text=True,
Expand Down Expand Up @@ -267,16 +265,6 @@ def test_failures(self):
sql_out = psql(token, "")
self.assertEqual(sql_out, "")

# Connection fails when `ssl` is required
for ssl_mode in ["require", "verify-ca", "verify-full"]:
with self.assertRaises(Exception) as cm:
psql(token, "SELECT * FROM t_uints", extra={"PGSSLMODE": ssl_mode})
self.assertIn("not support SSL", str(cm.exception))

# But works with `ssl` is disabled or optional
for ssl_mode in ["disable", "allow", "prefer"]:
psql(token, "SELECT * FROM t_uints", extra={"PGSSLMODE": ssl_mode})

# Connection fails with invalid token
with self.assertRaises(Exception) as cm:
psql("invalid_token", "SELECT * FROM t_uints")
Expand Down
Loading