def test_no_password(self, dsn): dsn2 = make_conninfo(dsn, password="******") pgconn = psycopg3.pq.PGconn.connect_start(dsn2.encode("utf8")) info = ConnectionInfo(pgconn) assert info.password == "the-pass-word" assert "password" not in info.get_parameters() assert info.get_parameters()["dbname"] == info.dbname
def __init__(self, server_dsn): cdict = conninfo.conninfo_to_dict(server_dsn) # Get server params self.server_port = cdict.get("port", "5432") if "host" not in cdict or cdict["host"].startswith("/"): self.server_host = "localhost" else: self.server_host = cdict["host"] # Get client params self.client_host = "localhost" self.client_port = self._get_random_port() # Make a connection string to the proxy cdict["host"] = self.client_host cdict["port"] = self.client_port cdict["sslmode"] = "disable" # not supported by the proxy self.client_dsn = conninfo.make_conninfo(**cdict) # The running proxy process self.proc = None
def test_make_conninfo_bad(conninfo, kwargs): with pytest.raises(ProgrammingError): make_conninfo(conninfo, **kwargs)
def test_make_conninfo(conninfo, kwargs, exp): out = make_conninfo(conninfo, **kwargs) assert conninfo_to_dict(out) == conninfo_to_dict(exp)
def test_no_munging(): dsnin = "dbname=a host=b user=c password=d" dsnout = make_conninfo(dsnin) assert dsnin == dsnout