8000 Skip ssl check by demonolock · Pull Request #149 · postgrespro/testgres · GitHub
[go: up one dir, main page]

Skip to content

Skip ssl check #149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Move _get_ssl_options in separate function
  • Loading branch information
vshepard committed Dec 3, 2024
commit dc4b4c3dbf26e1d019b7fe0395a2fb8f933b0c38
15 changes: 13 additions & 2 deletions testgres/operations/os_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,27 @@ def get_pid(self):
def get_process_children(self, pid):
raise NotImplementedError()

def _get_ssl_options(self):
"""
Determine the SSL options based on available modules.
"""
if self.conn_params.skip_ssl:
if 'psycopg2' in sys.modules:
return {"sslmode": "disable"}
elif 'pg8000' in sys.modules:
return {"ssl_context": None}
return {}

# Database control
def db_connect(self, dbname, user, password=None, host="localhost", port=5432):
ssl_options = {"sslmode": "disable"} if self.conn_params.skip_ssl and 'psycopg2' in sys.modules else {}
ssl_options = self._get_ssl_options()
conn = pglib.connect(
host=host,
port=port,
database=dbname,
user=user,
password=password,
**({"ssl_context": None} if self.conn_params.skip_ssl and 'pg8000' in sys.modules else ssl_options)
**ssl_options
)

return conn
8 changes: 5 additions & 3 deletions tests/test_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -1039,9 +1039,11 @@ def test_parse_pg_version(self):
def test_the_same_port(self):
with get_new_node() as node:
node.init().start()
with get_new_node() as node2:
node2.port = node.port
node2.init().start()
with get_new_node() as node2:
node2.port = node.port
# _should_free_port is true if port was set up manually
node2._should_free_port = False
node2.init().start()

def test_make_simple_with_bin_dir(self):
with get_new_node() as node:
Expand Down
0