
Added the remaining test steps for the newe automated TC: Step 5: Navigate to K8s dashboard login page - Get the k8s dashboard URL. - Open the k8s dashboard login page. - Login to the dashboard using the token. Step 6 : Logout from the dashboard - Logout from the dashboard Step 7 : Login to the dashboard using kubeconfig file - Update the token in the kubeconfig file - Open the k8s dashboard login page. - Login to the dashboard using the kubeconfig file. Change-Id: Id3d68c4d3ec41c8ea108a7744494f81fad1e0691 Signed-off-by: Gabriel Calixto <Gabriel.CalixtodePaula@windriver.com>
42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
from pytest import fail
|
|
|
|
from framework.ssh.ssh_connection import SSHConnection
|
|
from keywords.base_keyword import BaseKeyword
|
|
from keywords.k8s.k8s_command_wrapper import export_k8s_config
|
|
|
|
|
|
class KubectlCreateTokenKeywords(BaseKeyword):
|
|
"""
|
|
Keywords for creating a token with kubectl
|
|
"""
|
|
|
|
def __init__(self, ssh_connection: SSHConnection):
|
|
"""
|
|
Initializes the KubectlCreateTokenKeywords class with an SSH connection.
|
|
|
|
Args:
|
|
ssh_connection (SSHConnection): An object representing the SSH connection.
|
|
"""
|
|
self.ssh_connection = ssh_connection
|
|
|
|
def create_token(self, namespace: str, user: str) -> list:
|
|
"""
|
|
Create a Kubernetes token for a specified user in a given namespace.
|
|
|
|
Args:
|
|
namespace (str): The Kubernetes namespace where the token will be created.
|
|
user (str): The name of the Kubernetes service account for which the token will be created.
|
|
|
|
Returns:
|
|
list: The output from the kubectl command execution.
|
|
"""
|
|
args = f"{user} -n {namespace}"
|
|
output = self.ssh_connection.send(export_k8s_config(f"kubectl create token {args}"))
|
|
if output and len(output) == 1:
|
|
output = output[0]
|
|
else:
|
|
fail("Token creation failed.")
|
|
|
|
self.validate_success_return_code(self.ssh_connection)
|
|
return output
|