Files
test/keywords/openssl/openssl_keywords.py
Gabriel Calixto de Paula cce3287018 add k8s_dashboard_access TC part5
finished the necessary setups for the test case regarding the namespace
and some HTTPS certificates

Change-Id: I59c67de09a0799c733196f66b9e8028b9c4a36a4
Signed-off-by: Gabriel Calixto de Paula <gabrielcalixto9@gmail.com>
2025-03-05 15:23:02 -05:00

28 lines
1020 B
Python

from framework.ssh.ssh_connection import SSHConnection
from keywords.base_keyword import BaseKeyword
class OpenSSLKeywords(BaseKeyword):
def __init__(self, ssh_connection: SSHConnection):
self.ssh_connection = ssh_connection
def create_certificate(self, key: str = None, crt: str = None, sys_domain_name: str = None) -> None:
"""
Creates an SSL certificate file for the Kubernetes dashboard secret.
Args:
key (str): The path to the key file.
crt (str): The path to the certificate file.
sys_domain_name (str): The system domain name to be used in the certificate.
"""
args = ""
if key:
args += f"-keyout {key} "
if crt:
args += f"-out {crt} "
if sys_domain_name:
args += f'-subj "/CN={sys_domain_name}"'
self.ssh_connection.send(f"openssl req -x509 -nodes -days 365 -newkey rsa:2048 {args}")
self.validate_success_return_code(self.ssh_connection)