Support SSL in the regression tests. Fixes #2170

This commit is contained in:
Murtuza Zabuawala
2017-07-18 15:23:11 +01:00
committed by Dave Page
parent 6396b8ce18
commit bab3da24e6
55 changed files with 266 additions and 119 deletions

View File

@@ -16,7 +16,8 @@ class TestCheckRecovery(BaseTestGenerator):
self.server['username'],
self.server['db_password'],
self.server['host'],
self.server['port']).cursor()
self.server['port'],
self.server['sslmode']).cursor()
if cursor is not None and cursor.connection is not None:
server_version = cursor.connection.server_version

View File

@@ -0,0 +1,39 @@
##########################################################################
#
# pgAdmin 4 - PostgreSQL Tools
#
# Copyright (C) 2013 - 2017, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
##########################################################################
from pgadmin.utils.route import BaseTestGenerator
from regression.python_test_utils import test_utils
class TestSSLConnection(BaseTestGenerator):
"""This will check if SSL is used in our database connection"""
scenarios = [
("Test for SSL connection", dict())
]
def runTest(self):
if hasattr(self, "ignore_test"):
return
supported_modes = ['require', 'verify-ca', 'verify-full']
if self.server['sslmode'] in supported_modes:
with test_utils.Database(self.server) as (
connection, database_name
):
cursor = connection.cursor()
cursor.execute("CREATE EXTENSION sslinfo")
connection.commit()
cursor.execute("SELECT ssl_is_used()")
is_ssl_used = cursor.fetchone()[0]
self.assertEquals(True, is_ssl_used)
else:
self.skipTest("Cannot run SSL connection check test "
"with '{0}' sslmode".format(
self.server['sslmode']
))