From d760dfa08ec8191b6fb3a77aff7f072cad5f087b Mon Sep 17 00:00:00 2001 From: Lenka Segura Date: Sep 22 2022 08:18:45 +0000 Subject: Add molecule test for klist --- diff --git a/CommunishiftAuthorization/molecule/default/tasks/communishiftauthorization_test.yml b/CommunishiftAuthorization/molecule/default/tasks/communishiftauthorization_test.yml index 0fc255a..8526cef 100644 --- a/CommunishiftAuthorization/molecule/default/tasks/communishiftauthorization_test.yml +++ b/CommunishiftAuthorization/molecule/default/tasks/communishiftauthorization_test.yml @@ -12,7 +12,6 @@ vars: cr_file: '_v1alpha1_communishiftauthorization.yaml' - - block: - name: 'TEST: for the existance of the CAO k8s secret' k8s_info: @@ -35,4 +34,24 @@ that: - cao_keytab_secret.resources|length == 1 -# kinit, then check klist, then curl fasjson +- block: + - name: 'Retrieve operator pod name' + k8s_info: + api_version: v1 + kind: Pod + namespace: "{{ namespace }}" + register: pod_list + + - set_fact: + cao_pod_name: "{{ pod_list.resources[0].metadata.name }}" + + - name: 'Execute klist command' + kubernetes.core.k8s_exec: + namespace: "{{ namespace }}" + pod: "{{ cao_pod_name }}" + command: klist -k /etc/communishift/communishift-authorization-keytab + register: klist_output + + - assert: + that: + - "'FEDORAPROJECT.ORG' in klist_output.stdout"