diff options
Diffstat (limited to 'tests/oom-platform-cert-service')
38 files changed, 240 insertions, 160 deletions
diff --git a/tests/oom-platform-cert-service/postprocessor/assets/expected_keystores/keystore.jks b/tests/oom-platform-cert-service/postprocessor/assets/expected_keystores/keystore.jks Binary files differnew file mode 100644 index 00000000..390f2410 --- /dev/null +++ b/tests/oom-platform-cert-service/postprocessor/assets/expected_keystores/keystore.jks diff --git a/tests/oom-platform-cert-service/postprocessor/assets/expected_keystores/keystore.jks.bak b/tests/oom-platform-cert-service/postprocessor/assets/expected_keystores/keystore.jks.bak Binary files differnew file mode 100644 index 00000000..390f2410 --- /dev/null +++ b/tests/oom-platform-cert-service/postprocessor/assets/expected_keystores/keystore.jks.bak diff --git a/tests/oom-platform-cert-service/truststoremerger/assets/expected_truststores/jksAndPemAndP12.jks b/tests/oom-platform-cert-service/postprocessor/assets/expected_truststores/jksAndPemAndP12.jks Binary files differindex 1c9f111a..1c9f111a 100644 --- a/tests/oom-platform-cert-service/truststoremerger/assets/expected_truststores/jksAndPemAndP12.jks +++ b/tests/oom-platform-cert-service/postprocessor/assets/expected_truststores/jksAndPemAndP12.jks diff --git a/tests/oom-platform-cert-service/truststoremerger/assets/expected_truststores/pemAndP12.pem b/tests/oom-platform-cert-service/postprocessor/assets/expected_truststores/pemAndP12.pem index 978e682d..978e682d 100644 --- a/tests/oom-platform-cert-service/truststoremerger/assets/expected_truststores/pemAndP12.pem +++ b/tests/oom-platform-cert-service/postprocessor/assets/expected_truststores/pemAndP12.pem diff --git a/tests/oom-platform-cert-service/truststoremerger/assets/invalid_different_lists_size.env b/tests/oom-platform-cert-service/postprocessor/assets/invalid_different_lists_size.env index 9edfaa41..9edfaa41 100644 --- a/tests/oom-platform-cert-service/truststoremerger/assets/invalid_different_lists_size.env +++ b/tests/oom-platform-cert-service/postprocessor/assets/invalid_different_lists_size.env diff --git a/tests/oom-platform-cert-service/truststoremerger/assets/invalid_duplicated_aliases.env b/tests/oom-platform-cert-service/postprocessor/assets/invalid_duplicated_aliases.env index f98b3366..f98b3366 100644 --- a/tests/oom-platform-cert-service/truststoremerger/assets/invalid_duplicated_aliases.env +++ b/tests/oom-platform-cert-service/postprocessor/assets/invalid_duplicated_aliases.env diff --git a/tests/oom-platform-cert-service/truststoremerger/assets/invalid_empty_certs.env b/tests/oom-platform-cert-service/postprocessor/assets/invalid_empty_certs.env index 95c00fc2..95c00fc2 100644 --- a/tests/oom-platform-cert-service/truststoremerger/assets/invalid_empty_certs.env +++ b/tests/oom-platform-cert-service/postprocessor/assets/invalid_empty_certs.env diff --git a/tests/oom-platform-cert-service/truststoremerger/assets/invalid_empty_file.env b/tests/oom-platform-cert-service/postprocessor/assets/invalid_empty_file.env index e69de29b..e69de29b 100644 --- a/tests/oom-platform-cert-service/truststoremerger/assets/invalid_empty_file.env +++ b/tests/oom-platform-cert-service/postprocessor/assets/invalid_empty_file.env diff --git a/tests/oom-platform-cert-service/postprocessor/assets/invalid_empty_keystore_destination_path.env b/tests/oom-platform-cert-service/postprocessor/assets/invalid_empty_keystore_destination_path.env new file mode 100644 index 00000000..526357b0 --- /dev/null +++ b/tests/oom-platform-cert-service/postprocessor/assets/invalid_empty_keystore_destination_path.env @@ -0,0 +1,3 @@ +TRUSTSTORES_PATHS=/var/certs/truststore.jks:/var/certs/truststore.pem:/var/certs/truststore.p12 +TRUSTSTORES_PASSWORDS_PATHS=/var/certs/truststoreJks.pass::/var/certs/truststoreP12.pass +KEYSTORE_SOURCE_PATHS=/var/certs/external/keystore13.jks diff --git a/tests/oom-platform-cert-service/truststoremerger/assets/invalid_empty_passwords.env b/tests/oom-platform-cert-service/postprocessor/assets/invalid_empty_passwords.env index 840728bb..840728bb 100644 --- a/tests/oom-platform-cert-service/truststoremerger/assets/invalid_empty_passwords.env +++ b/tests/oom-platform-cert-service/postprocessor/assets/invalid_empty_passwords.env diff --git a/tests/oom-platform-cert-service/truststoremerger/assets/invalid_extension.env b/tests/oom-platform-cert-service/postprocessor/assets/invalid_extension.env index 5b971616..5b971616 100644 --- a/tests/oom-platform-cert-service/truststoremerger/assets/invalid_extension.env +++ b/tests/oom-platform-cert-service/postprocessor/assets/invalid_extension.env diff --git a/tests/oom-platform-cert-service/truststoremerger/assets/invalid_file_password_pair.env b/tests/oom-platform-cert-service/postprocessor/assets/invalid_file_password_pair.env index 1a195116..1a195116 100644 --- a/tests/oom-platform-cert-service/truststoremerger/assets/invalid_file_password_pair.env +++ b/tests/oom-platform-cert-service/postprocessor/assets/invalid_file_password_pair.env diff --git a/tests/oom-platform-cert-service/postprocessor/assets/invalid_keystore_source_paths.env b/tests/oom-platform-cert-service/postprocessor/assets/invalid_keystore_source_paths.env new file mode 100644 index 00000000..7090151c --- /dev/null +++ b/tests/oom-platform-cert-service/postprocessor/assets/invalid_keystore_source_paths.env @@ -0,0 +1,4 @@ +TRUSTSTORES_PATHS=/var/certs/truststore.jks:/var/certs/truststore.pem:/var/certs/truststore.p12 +TRUSTSTORES_PASSWORDS_PATHS=/var/certs/truststoreJks.pass::/var/certs/truststoreP12.pass +KEYSTORE_SOURCE_PATHS=/var/certs/external/keystore13.jks +KEYSTORE_DESTINATION_PATHS=/var/certs/cert.jks diff --git a/tests/oom-platform-cert-service/truststoremerger/assets/invalid_password_path.env b/tests/oom-platform-cert-service/postprocessor/assets/invalid_password_path.env index b397f9ac..b397f9ac 100644 --- a/tests/oom-platform-cert-service/truststoremerger/assets/invalid_password_path.env +++ b/tests/oom-platform-cert-service/postprocessor/assets/invalid_password_path.env diff --git a/tests/oom-platform-cert-service/truststoremerger/assets/invalid_truststore_paths.env b/tests/oom-platform-cert-service/postprocessor/assets/invalid_truststore_paths.env index 52fa88c6..52fa88c6 100644 --- a/tests/oom-platform-cert-service/truststoremerger/assets/invalid_truststore_paths.env +++ b/tests/oom-platform-cert-service/postprocessor/assets/invalid_truststore_paths.env diff --git a/tests/oom-platform-cert-service/truststoremerger/assets/truststores/empty.pem b/tests/oom-platform-cert-service/postprocessor/assets/truststores/empty.pem index e69de29b..e69de29b 100644 --- a/tests/oom-platform-cert-service/truststoremerger/assets/truststores/empty.pem +++ b/tests/oom-platform-cert-service/postprocessor/assets/truststores/empty.pem diff --git a/tests/oom-platform-cert-service/postprocessor/assets/truststores/external/keystore.jks b/tests/oom-platform-cert-service/postprocessor/assets/truststores/external/keystore.jks Binary files differnew file mode 100644 index 00000000..390f2410 --- /dev/null +++ b/tests/oom-platform-cert-service/postprocessor/assets/truststores/external/keystore.jks diff --git a/tests/oom-platform-cert-service/postprocessor/assets/truststores/external/keystore.pass b/tests/oom-platform-cert-service/postprocessor/assets/truststores/external/keystore.pass new file mode 100644 index 00000000..8b11c5b6 --- /dev/null +++ b/tests/oom-platform-cert-service/postprocessor/assets/truststores/external/keystore.pass @@ -0,0 +1 @@ +wgg2_fLSQ8I4sLfyUOCC7uYn
\ No newline at end of file diff --git a/tests/oom-platform-cert-service/truststoremerger/assets/truststores/truststore.jks b/tests/oom-platform-cert-service/postprocessor/assets/truststores/truststore.jks Binary files differindex 3bd85a06..3bd85a06 100644 --- a/tests/oom-platform-cert-service/truststoremerger/assets/truststores/truststore.jks +++ b/tests/oom-platform-cert-service/postprocessor/assets/truststores/truststore.jks diff --git a/tests/oom-platform-cert-service/truststoremerger/assets/truststores/truststore.p12 b/tests/oom-platform-cert-service/postprocessor/assets/truststores/truststore.p12 Binary files differindex 3a98c4a2..3a98c4a2 100644 --- a/tests/oom-platform-cert-service/truststoremerger/assets/truststores/truststore.p12 +++ b/tests/oom-platform-cert-service/postprocessor/assets/truststores/truststore.p12 diff --git a/tests/oom-platform-cert-service/truststoremerger/assets/truststores/truststore.pem b/tests/oom-platform-cert-service/postprocessor/assets/truststores/truststore.pem index 8815d6cb..8815d6cb 100644 --- a/tests/oom-platform-cert-service/truststoremerger/assets/truststores/truststore.pem +++ b/tests/oom-platform-cert-service/postprocessor/assets/truststores/truststore.pem diff --git a/tests/oom-platform-cert-service/truststoremerger/assets/truststores/truststoreJks.pass b/tests/oom-platform-cert-service/postprocessor/assets/truststores/truststoreJks.pass index 817b6194..817b6194 100644 --- a/tests/oom-platform-cert-service/truststoremerger/assets/truststores/truststoreJks.pass +++ b/tests/oom-platform-cert-service/postprocessor/assets/truststores/truststoreJks.pass diff --git a/tests/oom-platform-cert-service/truststoremerger/assets/truststores/truststoreP12.pass b/tests/oom-platform-cert-service/postprocessor/assets/truststores/truststoreP12.pass index 48036abd..48036abd 100644 --- a/tests/oom-platform-cert-service/truststoremerger/assets/truststores/truststoreP12.pass +++ b/tests/oom-platform-cert-service/postprocessor/assets/truststores/truststoreP12.pass diff --git a/tests/oom-platform-cert-service/postprocessor/assets/valid_envs_and_extra_optional.env b/tests/oom-platform-cert-service/postprocessor/assets/valid_envs_and_extra_optional.env new file mode 100644 index 00000000..928bf637 --- /dev/null +++ b/tests/oom-platform-cert-service/postprocessor/assets/valid_envs_and_extra_optional.env @@ -0,0 +1,4 @@ +TRUSTSTORES_PATHS=/var/certs/truststore.pem:/var/certs/truststore.p12 +TRUSTSTORES_PASSWORDS_PATHS=:/var/certs/truststoreP12.pass +KEYSTORE_SOURCE_PATHS=/var/certs/external/keystore.jks:/var/certs/external/keystore.pass +KEYSTORE_DESTINATION_PATHS=/var/certs/keystore.jks:/var/certs/keystore.pass diff --git a/tests/oom-platform-cert-service/truststoremerger/assets/valid_jks_pem_p12.env b/tests/oom-platform-cert-service/postprocessor/assets/valid_jks_pem_p12.env index 4afa1a27..4afa1a27 100644 --- a/tests/oom-platform-cert-service/truststoremerger/assets/valid_jks_pem_p12.env +++ b/tests/oom-platform-cert-service/postprocessor/assets/valid_jks_pem_p12.env diff --git a/tests/oom-platform-cert-service/truststoremerger/assets/valid_pem_p12.env b/tests/oom-platform-cert-service/postprocessor/assets/valid_pem_p12.env index e0240a74..e0240a74 100644 --- a/tests/oom-platform-cert-service/truststoremerger/assets/valid_pem_p12.env +++ b/tests/oom-platform-cert-service/postprocessor/assets/valid_pem_p12.env diff --git a/tests/oom-platform-cert-service/truststoremerger/assets/valid_single_truststore.env b/tests/oom-platform-cert-service/postprocessor/assets/valid_single_truststore.env index 66b6f66f..66b6f66f 100644 --- a/tests/oom-platform-cert-service/truststoremerger/assets/valid_single_truststore.env +++ b/tests/oom-platform-cert-service/postprocessor/assets/valid_single_truststore.env diff --git a/tests/oom-platform-cert-service/postprocessor/certservice-postprocessor-test.robot b/tests/oom-platform-cert-service/postprocessor/certservice-postprocessor-test.robot new file mode 100644 index 00000000..338f16ff --- /dev/null +++ b/tests/oom-platform-cert-service/postprocessor/certservice-postprocessor-test.robot @@ -0,0 +1,88 @@ +*** Settings *** + +Documentation Certifcate Post Processors test case scenarios +Library RequestsLibrary +Resource ./resources/test-keywords.robot + +*** Test Cases *** + +Cert Post Processor fails when file extension is invalid (merger) + [Tags] OOM-CERTSERVICE-POST-PROCESSOR + [Documentation] Run with invalid truststore extension env and expect error code + Run Cert Service Post Processor And Expect Error ${ENV_FILE_INVALID_FILE_EXTENSION} ${EXITCODE_CERTIFICATES_PATHS_VALIDATION_EXCEPTION} + +Cert Post Processor fails when a variable is empty (merger) + [Tags] OOM-CERTSERVICE-POST-PROCESSOR + [Documentation] Run with empty truststore password path env and expect error code + Run Cert Service Post Processor And Expect Error ${ENV_FILE_EMPTY_PASSWORDS} ${EXITCODE_CERTIFICATES_PATHS_VALIDATION_EXCEPTION} + +Cert Post Processor fails when truststore and passwords envs not provided (merger) + [Tags] OOM-CERTSERVICE-POST-PROCESSOR + [Documentation] Run with invalid empty envs and expect error code + Run Cert Service Post Processor And Expect Error ${ENV_FILE_EMPTY} ${EXITCODE_CONFIGURATION_EXCEPTION} + +Cert Post Processor fails when list sizes are different (merger) + [Tags] OOM-CERTSERVICE-POST-PROCESSOR + [Documentation] Run with different truststore and password envs size and expect error code + Run Cert Service Post Processor And Expect Error ${ENV_FILE_INVALID_FILE_LIST_SIZE} ${EXITCODE_CONFIGURATION_EXCEPTION} + +Cert Post Processor fails when truststore paths are invalid (merger) + [Tags] OOM-CERTSERVICE-POST-PROCESSOR + [Documentation] Run with invalid truststore path and expect error code + Run Cert Service Post Processor And Expect Error ${ENV_FILE_INVALID_TRUSTSTORE_PATHS} ${EXITCODE_TRUSTSTORE_FILE_FACTORY_EXCEPTION} + +Cert Post Processor fails when password path is invalid (merger) + [Tags] OOM-CERTSERVICE-POST-PROCESSOR + [Documentation] Run with invalid password path and expect error code + Run Cert Service Post Processor And Expect Error ${ENV_FILE_INVALID_PASSWORD_PATHS} ${EXITCODE_PASSWORD_READER_EXCEPTION} + +Cert Post Processor fails when password file pair is invalid (merger) + [Tags] OOM-CERTSERVICE-POST-PROCESSOR + [Documentation] Run with incorrect password env and expect error code + Run Cert Service Post Processor And Expect Error ${ENV_FILE_INVALID_PASSWORD} ${EXITCODE_TRUSTSTORE_LOAD_FILE_EXCEPTION} + +Cert Post Processor fails when pem does not contain cert (merger) + [Tags] OOM-CERTSERVICE-POST-PROCESSOR + [Documentation] Run with empty pem truststore and expect error code + Run Cert Service Post Processor And Expect Error ${ENV_FILE_EMPTY_CERTS} ${EXITCODE_MISSING_TRUSTSTORE_EXCEPTIONSUCCESS} + +Cert Post Processor fails when aliases are duplicated (merger) + [Tags] OOM-CERTSERVICE-POST-PROCESSOR + [Documentation] Run with duplicated aliases in truststores and expect error code + Run Cert Service Post Processor And Expect Error ${ENV_FILE_DUPLICATED_ALIASES} ${EXITCODE_ALIAS_CONFLICT_EXCEPTION} + +Cert Post Processor merges successfully jks pem p12 (merger) + [Tags] OOM-CERTSERVICE-POST-PROCESSOR + [Documentation] Run with valid env file and expect merged certs from jks, pem and p12 + Run Cert Service Post Processor And Merge Truststore Files To Jks ${ENV_FILE_JKS_PEM_P12} ${EXITCODE_SUCCESS} ${JKS_TRUSTSTORE_MOUNT_PATH} ${TRUSTSTORE_JKS_PASS} ${JKS_TRUSTSTORE_EXPECTED_PATH} + +Cert Post Processor merges successfully pem p12 (merger) + [Tags] OOM-CERTSERVICE-POST-PROCESSOR + [Documentation] Run with valid env file and expect merged certs from pem and p12 + Run Cert Service Post Processor And Merge Truststore Files To Pem ${ENV_FILE_PEM_P12} ${EXITCODE_SUCCESS} ${PEM_TRUSTSTORE_MOUNT_PATH} ${PEM_TRUSTSTORE_EXPECTED_PATH} + +Cert Post Processor ends successfully with single truststore (merger) + [Tags] OOM-CERTSERVICE-POST-PROCESSOR + [Documentation] Run with one truststore in env file and expect code 0 + Run Cert Service Post Processor And Merge Truststore Files To Jks ${ENV_FILE_SINGLE_TRUSTSTORE} ${EXITCODE_SUCCESS} ${JKS_TRUSTSTORE_MOUNT_PATH} ${TRUSTSTORE_JKS_PASS} ${TRUSTSTORE_JKS} + +Cert Post Processor fails when file to copy does not exist (merger) + [Tags] OOM-CERTSERVICE-POST-PROCESSOR + [Documentation] Run with invalid extra optional env as a path to file and expect error code + Run Cert Service Post Processor And Expect Error ${ENV_FILE_INVALID_KEYSTORE_SOURCE_PATHS} ${EXITCODE_KEYSTORE_NOT_EXIST_EXCEPTION} + +Cert Post Processor fails when only one extra optional env is set (merger) + [Tags] OOM-CERTSERVICE-POST-PROCESSOR + [Documentation] Run with empty extra optional env and expect code + Run Cert Service Post Processor And Expect Error ${ENV_FILE_EMPTY_KEYSTORE_DESTINATION_PATH} ${EXITCODE_CONFIGURATION_EXCEPTION} + +Cert Post Processor successfully backs up files (copier) + [Tags] OOM-CERTSERVICE-POST-PROCESSOR + [Documentation] Run with valid env file and expect successfully backed up file + Run Cert Service Post Processor And Check Copied Keystore Files ${ENV_FILE_EXTRA_OPTIONAL_ENVS} ${EXITCODE_SUCCESS} ${JKS_KEYSTORE_MOUNT_PATH} ${KEYSTORE_JKS_PASS} ${JKSBAK_KEYSTORE_EXPECTED_PATH} + +Cert Post Processor successfully copies file (copier) + [Tags] OOM-CERTSERVICE-POST-PROCESSOR + [Documentation] Run with valid env file and expect successfully copied file + Run Cert Service Post Processor And Check Copied Keystore Files ${ENV_FILE_EXTRA_OPTIONAL_ENVS} ${EXITCODE_SUCCESS} ${JKS_KEYSTORE_MOUNT_PATH} ${KEYSTORE_JKS_PASS} ${JKS_KEYSTORE_EXPECTED_PATH} + diff --git a/tests/oom-platform-cert-service/truststoremerger/libraries/EnvsReader.py b/tests/oom-platform-cert-service/postprocessor/libraries/EnvsReader.py index cc60eed6..cc60eed6 100644 --- a/tests/oom-platform-cert-service/truststoremerger/libraries/EnvsReader.py +++ b/tests/oom-platform-cert-service/postprocessor/libraries/EnvsReader.py diff --git a/tests/oom-platform-cert-service/postprocessor/libraries/JksValidator.py b/tests/oom-platform-cert-service/postprocessor/libraries/JksValidator.py new file mode 100644 index 00000000..983f66bb --- /dev/null +++ b/tests/oom-platform-cert-service/postprocessor/libraries/JksValidator.py @@ -0,0 +1,28 @@ + +import jks + +class JksValidator: + + def get_jks_entries(self, jks_path, password_path): + store = jks.KeyStore.load(jks_path, open(password_path, 'rb').read()) + return store.entries + + def assert_jks_truststores_equal(self, result_truststore_path, password_path, expected_truststore_path): + result_keys = self.get_jks_entries(result_truststore_path, password_path) + expected_keys = self.get_jks_entries(expected_truststore_path, password_path) + if len(result_keys) != len(expected_keys): + return False + for k in result_keys: + if not (k in expected_keys and result_keys[k].cert == expected_keys[k].cert): + return False + return True + + def assert_jks_keystores_equal(self, result_keystore_path, password_path, expected_keystore_path): + result_keys = self.get_jks_entries(result_keystore_path, password_path) + expected_keys = self.get_jks_entries(expected_keystore_path, password_path) + if len(result_keys) != len(expected_keys): + return False + for k in result_keys: + if not (k in expected_keys and result_keys[k].pkey == expected_keys[k].pkey): + return False + return True diff --git a/tests/oom-platform-cert-service/truststoremerger/libraries/PemTruststoreValidator.py b/tests/oom-platform-cert-service/postprocessor/libraries/PemTruststoreValidator.py index 8dc9623d..8dc9623d 100644 --- a/tests/oom-platform-cert-service/truststoremerger/libraries/PemTruststoreValidator.py +++ b/tests/oom-platform-cert-service/postprocessor/libraries/PemTruststoreValidator.py diff --git a/tests/oom-platform-cert-service/truststoremerger/libraries/TrustMergerManager.py b/tests/oom-platform-cert-service/postprocessor/libraries/PostProcessorDockerContainerUtils.py index f7a493c4..e0563b3f 100644 --- a/tests/oom-platform-cert-service/truststoremerger/libraries/TrustMergerManager.py +++ b/tests/oom-platform-cert-service/postprocessor/libraries/PostProcessorDockerContainerUtils.py @@ -7,20 +7,20 @@ from docker.types import Mount ARCHIVES_PATH = os.getenv("WORKSPACE") + "/archives/" -class TrustMergerManager: +class PostProcessorDockerContainerUtils: def __init__(self, mount_path, truststores_path): self.mount_path = mount_path self.truststores_path = truststores_path - def run_merger_container(self, merger_image, merger_name, path_to_env): + def run_container(self, docker_image, image_name, path_to_env): self.remove_mount_dir() shutil.copytree(self.truststores_path, self.mount_path) client = docker.from_env() environment = EnvsReader().read_env_list_from_file(path_to_env) container = client.containers.run( - image=merger_image, - name=merger_name, + image=docker_image, + name=image_name, environment=environment, user='root', # Run container as root to avoid permission issues with volume mount access mounts=[Mount(target='/var/certs', source=self.mount_path, type='bind')], @@ -37,10 +37,10 @@ class TrustMergerManager: if os.path.exists(self.mount_path): shutil.rmtree(self.mount_path) - def remove_merger_container_and_save_logs(self, container_name, log_file_name): + def remove_container_and_save_logs(self, container_name, log_file_name): client = docker.from_env() container = client.containers.get(container_name) - text_file = open(ARCHIVES_PATH + "merger_container_" + log_file_name + ".log", "w") + text_file = open(ARCHIVES_PATH + "certservice_postprocessor_container_" + log_file_name + ".log", "w") text_file.write(container.logs()) text_file.close() container.remove() diff --git a/tests/oom-platform-cert-service/postprocessor/resources/test-keywords.robot b/tests/oom-platform-cert-service/postprocessor/resources/test-keywords.robot new file mode 100644 index 00000000..404ec0ae --- /dev/null +++ b/tests/oom-platform-cert-service/postprocessor/resources/test-keywords.robot @@ -0,0 +1,44 @@ +*** Settings *** + +Resource ../../../common.robot +Resource ./test-properties.robot +Library ../libraries/PostProcessorDockerContainerUtils.py ${MOUNT_PATH} ${TRUSTSTORES_PATH} +Library ../libraries/JksValidator.py +Library ../libraries/PemTruststoreValidator.py + +*** Keywords *** + +Run Cert Service Post Processor And Expect Error + [Documentation] Run Cert Service Post Processor Container And Validate Exit Code + [Arguments] ${env_file} ${expected_exit_code} + ${exit_code}= Run Container ${CERT_POST_PROCESSOR_DOCKER_IMAGE} ${CERT_POST_PROCESSOR_CONTAINER_NAME} ${env_file} + Remove Container And Save Logs ${CERT_POST_PROCESSOR_CONTAINER_NAME} negative_path + Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return unexpected exit code return: ${exitcode} , but expected: ${expected_exit_code} + +Run Cert Service Post Processor And Merge Truststore Files To Jks + [Documentation] Run Cert Service Post Processor Container And Validate Exit Code And Provided Truststore Files + [Arguments] ${env_file} ${expected_exit_code} ${jks_path} ${jks_password} ${expected_jks_path} + ${exit_code}= Run Container ${CERT_POST_PROCESSOR_DOCKER_IMAGE} ${CERT_POST_PROCESSOR_CONTAINER_NAME} ${env_file} + ${files_equal}= Assert Jks Truststores Equal ${jks_path} ${jks_password} ${expected_jks_path} + Remove Container And Save Logs ${CERT_POST_PROCESSOR_CONTAINER_NAME} positive_path + Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return unexpected exit code return: ${exitcode} , but expected: ${expected_exit_code} + Should Be True ${files_equal} + +Run Cert Service Post Processor And Check Copied Keystore Files + [Documentation] Run Cert Service Post Processor Container And Validate Exit Code And Provided Keystore Files + [Arguments] ${env_file} ${expected_exit_code} ${jks_path} ${jks_password} ${expected_jks_path} + ${exit_code}= Run Container ${CERT_POST_PROCESSOR_DOCKER_IMAGE} ${CERT_POST_PROCESSOR_CONTAINER_NAME} ${env_file} + ${files_equal}= Assert Jks Keystores Equal ${jks_path} ${jks_password} ${expected_jks_path} + Remove Container And Save Logs ${CERT_POST_PROCESSOR_CONTAINER_NAME} positive_path + Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return unexpected exit code return: ${exitcode} , but expected: ${expected_exit_code} + Should Be True ${files_equal} + +Run Cert Service Post Processor And Merge Truststore Files To Pem + [Documentation] Run Cert Service Post Processor Container And Validate Exit Code And Files + [Arguments] ${env_file} ${expected_exit_code} ${pem_path} ${expected_pem_path} + ${exit_code}= Run Container ${CERT_POST_PROCESSOR_DOCKER_IMAGE} ${CERT_POST_PROCESSOR_CONTAINER_NAME} ${env_file} + ${files_equal}= Assert Pem Truststores Equal ${pem_path} ${expected_pem_path} + Remove Container And Save Logs ${CERT_POST_PROCESSOR_CONTAINER_NAME} positive_path + Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return unexpected exit code return: ${exitcode} , but expected: ${expected_exit_code} + Should Be True ${files_equal} + diff --git a/tests/oom-platform-cert-service/postprocessor/resources/test-properties.robot b/tests/oom-platform-cert-service/postprocessor/resources/test-properties.robot new file mode 100644 index 00000000..80fc06af --- /dev/null +++ b/tests/oom-platform-cert-service/postprocessor/resources/test-properties.robot @@ -0,0 +1,62 @@ +*** Variables *** + +${CERT_POST_PROCESSOR_DOCKER_IMAGE} nexus3.onap.org:10001/onap/org.onap.oom.platform.cert-service.oom-certservice-post-processor:latest +${CERT_POST_PROCESSOR_CONTAINER_NAME} %{CertServicePostProcessorContainerName} +${BASE_PATH} %{WORKSPACE}/tests/oom-platform-cert-service/postprocessor +${MOUNT_PATH} ${BASE_PATH}/tmp +${TRUSTSTORES_PATH} ${BASE_PATH}/assets/truststores +${EXPECTED_TRUSTSTORES_PATH} ${BASE_PATH}/assets/expected_truststores + +${JKS_TRUSTSTORE_MOUNT_PATH} ${BASE_PATH}/tmp/truststore.jks +${JKS_PASSWORD_MOUNT_PATH} ${BASE_PATH}/tmp/truststoreJks.pass +${P12_TRUSTSTORE_MOUNT_PATH} ${BASE_PATH}/tmp/truststore.p12 +${P12_PASSWORD_MOUNT_PATH} ${BASE_PATH}/tmp/truststoreP12.pass +${PEM_TRUSTSTORE_MOUNT_PATH} ${BASE_PATH}/tmp/truststore.pem +${JKS_KEYSTORE_MOUNT_PATH} ${BASE_PATH}/tmp/external/keystore.jks + +${JKS_TRUSTSTORE_EXPECTED_PATH} ${BASE_PATH}/assets/expected_truststores/jksAndPemAndP12.jks +${PEM_TRUSTSTORE_EXPECTED_PATH} ${BASE_PATH}/assets/expected_truststores/pemAndP12.pem +${JKSBAK_KEYSTORE_EXPECTED_PATH} ${BASE_PATH}/assets/expected_keystores/keystore.jks.bak +${JKS_KEYSTORE_EXPECTED_PATH} ${BASE_PATH}/assets/expected_keystores/keystore.jks + +${ENV_FILE_EMPTY} ${BASE_PATH}/assets/invalid_empty_file.env +${ENV_FILE_INVALID_FILE_LIST_SIZE} ${BASE_PATH}/assets/invalid_different_lists_size.env +${ENV_FILE_EMPTY_PASSWORDS} ${BASE_PATH}/assets/invalid_empty_passwords.env +${ENV_FILE_INVALID_PASSWORD_PATHS} ${BASE_PATH}/assets/invalid_password_path.env +${ENV_FILE_INVALID_TRUSTSTORE_PATHS} ${BASE_PATH}/assets/invalid_truststore_paths.env +${ENV_FILE_INVALID_PASSWORD} ${BASE_PATH}/assets/invalid_file_password_pair.env +${ENV_FILE_INVALID_FILE_EXTENSION} ${BASE_PATH}/assets/invalid_extension.env +${ENV_FILE_DUPLICATED_ALIASES} ${BASE_PATH}/assets/invalid_duplicated_aliases.env +${ENV_FILE_EMPTY_CERTS} ${BASE_PATH}/assets/invalid_empty_certs.env +${ENV_FILE_JKS_PEM_P12} ${BASE_PATH}/assets/valid_jks_pem_p12.env +${ENV_FILE_PEM_P12} ${BASE_PATH}/assets/valid_pem_p12.env +${ENV_FILE_SINGLE_TRUSTSTORE} ${BASE_PATH}/assets/valid_single_truststore.env +${ENV_FILE_INVALID_KEYSTORE_SOURCE_PATHS} ${BASE_PATH}/assets/invalid_keystore_source_paths.env +${ENV_FILE_EMPTY_KEYSTORE_DESTINATION_PATH} ${BASE_PATH}/assets/invalid_empty_keystore_destination_path.env +${ENV_FILE_EXTRA_OPTIONAL_ENVS} ${BASE_PATH}/assets/valid_envs_and_extra_optional.env + +${KEYSTORE_JKS} ${BASE_PATH}/assets/truststores/external/keystore.jks +${KEYSTORE_JKS_PASS} ${BASE_PATH}/assets/truststores/external/keystore.pass +${TRUSTSTORE_JKS} ${BASE_PATH}/assets/truststores/truststore.jks +${TRUSTSTORE_JKS_PASS} ${BASE_PATH}/assets/truststores/truststoreJks.pass +${TRUSTSTORE_P12} ${BASE_PATH}/assets/truststores/truststore.p12 +${TRUSTSTORE_P12_PASS} ${BASE_PATH}/assets/truststores/truststore.pass +${TRUSTSTORE_PEM} ${BASE_PATH}/assets/truststores/truststore.pem + +${EXITCODE_SUCCESS} 0 +${EXITCODE_CERTIFICATES_PATHS_VALIDATION_EXCEPTION} 1 +${EXITCODE_CONFIGURATION_EXCEPTION} 2 +${EXITCODE_TRUSTSTORE_FILE_FACTORY_EXCEPTION} 3 +${EXITCODE_PASSWORD_READER_EXCEPTION} 4 +${EXITCODE_CREATE_BACKUP_EXCEPTION} 5 +${EXITCODE_KEYSTORE_INSTANCE_EXCEPTION} 6 +${EXITCODE_TRUSTSTORE_LOAD_FILE_EXCEPTION} 7 +${EXITCODE_TRUSTSTORE_DATA_OPERATION_EXCEPTION} 8 +${EXITCODE_MISSING_TRUSTSTORE_EXCEPTIONSUCCESS} 9 +${EXITCODE_ALIAS_CONFLICT_EXCEPTION} 10 +${EXITCODE_WRITE_TRUSTSTORE_FILE_EXCEPTION} 11 +${EXITCODE_KEYSTORE_FILE_COPY_EXCEPTION} 12 +${EXITCODE_KEYSTORE_NOT_EXIST_EXCEPTION} 13 +${EXITCODE_UNEXPECTED_EXCEPTION} 99 + + diff --git a/tests/oom-platform-cert-service/truststoremerger/libraries/JksTruststoreValidator.py b/tests/oom-platform-cert-service/truststoremerger/libraries/JksTruststoreValidator.py deleted file mode 100644 index e18ca12c..00000000 --- a/tests/oom-platform-cert-service/truststoremerger/libraries/JksTruststoreValidator.py +++ /dev/null @@ -1,18 +0,0 @@ - -import jks - -class JksTruststoreValidator: - - def get_truststore(self, truststore_path, password_path): - truststore = jks.KeyStore.load(truststore_path, open(password_path, 'rb').read()) - return truststore.certs - - def assert_jks_truststores_equal(self, result_truststore_path, password_path, expected_truststore_path): - result_certs = self.get_truststore(result_truststore_path, password_path) - expected_certs = self.get_truststore(expected_truststore_path, password_path) - if len(result_certs) != len(expected_certs): - return False - for k in result_certs: - if not (k in expected_certs and result_certs[k].cert == expected_certs[k].cert): - return False - return True diff --git a/tests/oom-platform-cert-service/truststoremerger/resources/trust-merger-keywords.robot b/tests/oom-platform-cert-service/truststoremerger/resources/trust-merger-keywords.robot deleted file mode 100644 index 1040afab..00000000 --- a/tests/oom-platform-cert-service/truststoremerger/resources/trust-merger-keywords.robot +++ /dev/null @@ -1,34 +0,0 @@ -*** Settings *** - -Resource ../../../common.robot -Resource ./trust-merger-properties.robot -Library ../libraries/TrustMergerManager.py ${MOUNT_PATH} ${TRUSTSTORES_PATH} -Library ../libraries/JksTruststoreValidator.py -Library ../libraries/PemTruststoreValidator.py - -*** Keywords *** - -Run Trust Merger And Expect Error - [Documentation] Run Truststore Merger Container And Validate Exit Code - [Arguments] ${env_file} ${expected_exit_code} - ${exit_code}= Run Merger Container ${DOCKER_MERGER_IMAGE} ${MERGER_CONTAINER_NAME} ${env_file} - Remove Merger Container And Save Logs ${MERGER_CONTAINER_NAME} negative_path - Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return unexpected exit code return: ${exitcode} , but expected: ${expected_exit_code} - -Run Trust Merger And Merge Truststore Files To Jks - [Documentation] Run Truststore Merger Container And Validate Exit Code And Files - [Arguments] ${env_file} ${expected_exit_code} ${jks_path} ${jks_password} ${expected_jks_path} - ${exit_code}= Run Merger Container ${DOCKER_MERGER_IMAGE} ${MERGER_CONTAINER_NAME} ${env_file} - ${files_equal}= Assert Jks Truststores Equal ${jks_path} ${jks_password} ${expected_jks_path} - Remove Merger Container And Save Logs ${MERGER_CONTAINER_NAME} positive_path - Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return unexpected exit code return: ${exitcode} , but expected: ${expected_exit_code} - Should Be True ${files_equal} - -Run Trust Merger And Merge Truststore Files To Pem - [Documentation] Run Truststore Merger Container And Validate Exit Code And Files - [Arguments] ${env_file} ${expected_exit_code} ${pem_path} ${expected_pem_path} - ${exit_code}= Run Merger Container ${DOCKER_MERGER_IMAGE} ${MERGER_CONTAINER_NAME} ${env_file} - ${files_equal}= Assert Pem Truststores Equal ${pem_path} ${expected_pem_path} - Remove Merger Container And Save Logs ${MERGER_CONTAINER_NAME} positive_path - Should Be Equal As Strings ${exit_code} ${expected_exit_code} Client return unexpected exit code return: ${exitcode} , but expected: ${expected_exit_code} - Should Be True ${files_equal} diff --git a/tests/oom-platform-cert-service/truststoremerger/resources/trust-merger-properties.robot b/tests/oom-platform-cert-service/truststoremerger/resources/trust-merger-properties.robot deleted file mode 100644 index d356f604..00000000 --- a/tests/oom-platform-cert-service/truststoremerger/resources/trust-merger-properties.robot +++ /dev/null @@ -1,35 +0,0 @@ -*** Variables *** - -${DOCKER_MERGER_IMAGE} nexus3.onap.org:10001/onap/org.onap.oom.platform.cert-service.oom-truststore-merger:latest -${MERGER_CONTAINER_NAME} %{MergerContainerName} -${MOUNT_PATH} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/tmp -${TRUSTSTORES_PATH} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/assets/truststores -${EXPECTED_TRUSTSTORES_PATH} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/assets/expected_truststores - -${JKS_TRUSTSTORE_MOUNT_PATH} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/tmp/truststore.jks -${JKS_PASSWORD_MOUNT_PATH} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/tmp/truststoreJks.pass -${P12_TRUSTSTORE_MOUNT_PATH} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/tmp/truststore.p12 -${P12_PASSWORD_MOUNT_PATH} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/tmp/truststoreP12.pass -${PEM_TRUSTSTORE_MOUNT_PATH} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/tmp/truststore.pem - -${JKS_TRUSTSTORE_EXPECTED_PATH} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/assets/expected_truststores/jksAndPemAndP12.jks -${PEM_TRUSTSTORE_EXPECTED_PATH} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/assets/expected_truststores/pemAndP12.pem - -${INVALID_ENV_EMPTY_FILE} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/assets/invalid_empty_file.env -${INVALID_ENV_LIST_SIZE} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/assets/invalid_different_lists_size.env -${INVALID_ENV_EMPTY_PASSWORDS} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/assets/invalid_empty_passwords.env -${INVALID_PASSWORD_PATHS} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/assets/invalid_password_path.env -${INVALID_ENV_TRUSTSTORE_PATHS} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/assets/invalid_truststore_paths.env -${INVALID_ENV_FILE_PASSWORD} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/assets/invalid_file_password_pair.env -${INVALID_ENV_EXTENSION} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/assets/invalid_extension.env -${INVALID_ENV_DUPLICATED_ALIASES} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/assets/invalid_duplicated_aliases.env -${INVALID_ENV_EMPTY_CERTS} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/assets/invalid_empty_certs.env -${VALID_ENV_JKS_PEM_P12} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/assets/valid_jks_pem_p12.env -${VALID_ENV_PEM_P12} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/assets/valid_pem_p12.env -${VALID_ENV_SINGLE_TRUSTSTORE} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/assets/valid_single_truststore.env - -${TRUSTSTORE_JKS} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/assets/truststores/truststore.jks -${TRUSTSTORE_JKS_PASS} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/assets/truststores/truststoreJks.pass -${TRUSTSTORE_P12} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/assets/truststores/truststore.p12 -${TRUSTSTORE_P12_PASS} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/assets/truststores/truststore.pass -${TRUSTSTORE_PEM} %{WORKSPACE}/tests/oom-platform-cert-service/truststoremerger/assets/truststores/truststore.pem diff --git a/tests/oom-platform-cert-service/truststoremerger/trust-merger-test.robot b/tests/oom-platform-cert-service/truststoremerger/trust-merger-test.robot deleted file mode 100644 index 966a4243..00000000 --- a/tests/oom-platform-cert-service/truststoremerger/trust-merger-test.robot +++ /dev/null @@ -1,67 +0,0 @@ -*** Settings *** - -Documentation Truststore merger test case scenarios -Library RequestsLibrary -Resource ./resources/trust-merger-keywords.robot - -*** Test Cases *** - -Trust Merger fails when file extension is invalid - [Tags] OOM-TRUST-STORE-MERGER - [Documentation] Run with invalid truststore extension env and expect error code - Run Trust Merger And Expect Error ${INVALID_ENV_EXTENSION} 1 - -Trust Merger fails when truststore and passwords envs not provided - [Tags] OOM-TRUST-STORE-MERGER - [Documentation] Run with invalid empty envs and expect error code - Run Trust Merger And Expect Error ${INVALID_ENV_EMPTY_FILE} 1 - -Trust Merger fails when list sizes are different - [Tags] OOM-TRUST-STORE-MERGER - [Documentation] Run with different truststore and password envs size and expect error code - Run Trust Merger And Expect Error ${INVALID_ENV_LIST_SIZE} 2 - -Trust Merger fails when a variable is empty - [Tags] OOM-TRUST-STORE-MERGER - [Documentation] Run with empty truststore password path env and expect error code - Run Trust Merger And Expect Error ${INVALID_ENV_EMPTY_PASSWORDS} 2 - -Trust Merger fails when truststore paths are invalid - [Tags] OOM-TRUST-STORE-MERGER - [Documentation] Run with invalid truststore path and expect error code - Run Trust Merger And Expect Error ${INVALID_ENV_TRUSTSTORE_PATHS} 3 - -Trust Merger fails when password path is invalid - [Tags] OOM-TRUST-STORE-MERGER - [Documentation] Run with invalid password path and expect error code - Run Trust Merger And Expect Error ${INVALID_PASSWORD_PATHS} 4 - -Trust Merger fails when password file pair is invalid - [Tags] OOM-TRUST-STORE-MERGER - [Documentation] Run with incorrect password env and expect error code - Run Trust Merger And Expect Error ${INVALID_ENV_FILE_PASSWORD} 7 - -Trust Merger fails when pem does not contain cert - [Tags] OOM-TRUST-STORE-MERGER - [Documentation] Run with empty pem truststore and expect error code - Run Trust Merger And Expect Error ${INVALID_ENV_EMPTY_CERTS} 9 - -Trust Merger fails when aliases are duplicated - [Tags] OOM-TRUST-STORE-MERGER - [Documentation] Run with duplicated aliases in truststores and expect error code - Run Trust Merger And Expect Error ${INVALID_ENV_DUPLICATED_ALIASES} 10 - -Trust Merger merges successfully jks pem p12 - [Tags] OOM-TRUST-STORE-MERGER - [Documentation] Run with valid env file and expect merged certs from jks, pem and p12 - Run Trust Merger And Merge Truststore Files To Jks ${VALID_ENV_JKS_PEM_P12} 0 ${JKS_TRUSTSTORE_MOUNT_PATH} ${TRUSTSTORE_JKS_PASS} ${JKS_TRUSTSTORE_EXPECTED_PATH} - -Trust Merger merges successfully pem p12 - [Tags] OOM-TRUST-STORE-MERGER - [Documentation] Run with valid env file and expect merged certs from pem and p12 - Run Trust Merger And Merge Truststore Files To Pem ${VALID_ENV_PEM_P12} 0 ${PEM_TRUSTSTORE_MOUNT_PATH} ${PEM_TRUSTSTORE_EXPECTED_PATH} - -Trust Merger ends successfully with single truststore - [Tags] OOM-TRUST-STORE-MERGER - [Documentation] Run with one truststore in env file and expect code 0 - Run Trust Merger And Merge Truststore Files To Jks ${VALID_ENV_SINGLE_TRUSTSTORE} 0 ${JKS_TRUSTSTORE_MOUNT_PATH} ${TRUSTSTORE_JKS_PASS} ${TRUSTSTORE_JKS} |