aboutsummaryrefslogtreecommitdiffstats
path: root/src/onaptests
diff options
context:
space:
mode:
authorLukasz Rajewski <lukasz.rajewski@t-mobile.pl>2024-03-06 19:25:31 +0100
committerLukasz Rajewski <lukasz.rajewski@t-mobile.pl>2024-03-07 09:27:14 +0100
commit4af6cc86c97d4e72c70190e0888e6c558a0acc13 (patch)
tree3d5b5c8e18cae6e16187b1d460f137aaaee6d05f /src/onaptests
parent7ccb34ecddc674ad23ed1f0e607fd12b6d5954b9 (diff)
Fix CPS DB check
Fix CPS DB check to use tls authentication Issue-ID: INT-2263 Signed-off-by: Lukasz Rajewski <lukasz.rajewski@t-mobile.pl> Change-Id: I69fa15e849f6703b08a0057c4d633f951c6719f1
Diffstat (limited to 'src/onaptests')
-rw-r--r--src/onaptests/steps/onboard/cps.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/onaptests/steps/onboard/cps.py b/src/onaptests/steps/onboard/cps.py
index 04471c2..8f2525c 100644
--- a/src/onaptests/steps/onboard/cps.py
+++ b/src/onaptests/steps/onboard/cps.py
@@ -1,6 +1,7 @@
# http://www.apache.org/licenses/LICENSE-2.0
"""CPS onboard module."""
import base64
+import ssl
from abc import ABC
import pg8000
@@ -8,7 +9,8 @@ from kubernetes import client, config
from onapsdk.configuration import settings
from onapsdk.cps import Anchor, Dataspace, SchemaSet
-from onaptests.utils.exceptions import EnvironmentPreparationException
+from onaptests.utils.exceptions import (EnvironmentPreparationException,
+ OnapTestException)
from ..base import BaseStep
@@ -294,12 +296,16 @@ class CheckPostgressDataBaseConnectionStep(CpsBaseStep):
self.get_database_credentials()
if self.login and self.password:
+ ctx = ssl.create_default_context()
+ ctx.check_hostname = False
+ ctx.verify_mode = ssl.CERT_NONE
db_params = {
"user": self.login,
"password": self.password,
"host": settings.DB_PRIMARY_HOST,
"database": settings.DATABASE,
- "port": settings.DB_PORT
+ "port": settings.DB_PORT,
+ "ssl_context": ctx
}
try:
connection = pg8000.connect(**db_params)
@@ -310,9 +316,9 @@ class CheckPostgressDataBaseConnectionStep(CpsBaseStep):
cursor.close()
if connection:
connection.close()
- except pg8000.Error as e:
+ except Exception as e:
self._logger.exception(f"Error while connecting to PostgreSQL: {str(e)}")
- raise
+ raise OnapTestException(e) from e
@BaseStep.store_state
def execute(self) -> None: