diff options
author | Pawel <pawel.kasperkiewicz@nokia.com> | 2020-08-07 14:53:48 +0200 |
---|---|---|
committer | Pawel <pawel.kasperkiewicz@nokia.com> | 2020-08-12 11:15:39 +0200 |
commit | b7a057e8017b7899de26f977fa3841882035200b (patch) | |
tree | e17cb11f4464c16d526f3399199156bab7798a7a /tests/oom-platform-cert-service/certservice/libraries/P12ArtifactsValidator.py | |
parent | 8380fca432d740fe0c1d00fb9a39d3917672d91e (diff) |
Move csits form aaf to oom
create csit folder under oom
move csits from aaf to oom
reconfigure csits: remove aaf word, use new image
Issue-ID: OOM-2526
Signed-off-by: Pawel <pawel.kasperkiewicz@nokia.com>
Change-Id: I7b1f010fe46420cb734c67133f038bdadffd5ecc
Diffstat (limited to 'tests/oom-platform-cert-service/certservice/libraries/P12ArtifactsValidator.py')
-rw-r--r-- | tests/oom-platform-cert-service/certservice/libraries/P12ArtifactsValidator.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/oom-platform-cert-service/certservice/libraries/P12ArtifactsValidator.py b/tests/oom-platform-cert-service/certservice/libraries/P12ArtifactsValidator.py new file mode 100644 index 00000000..b0701718 --- /dev/null +++ b/tests/oom-platform-cert-service/certservice/libraries/P12ArtifactsValidator.py @@ -0,0 +1,37 @@ +from OpenSSL import crypto +from EnvsReader import EnvsReader +from ArtifactParser import ArtifactParser + +class P12ArtifactsValidator: + + def __init__(self, mount_path): + self.parser = ArtifactParser(mount_path, "p12") + + def get_and_compare_data_p12(self, path_to_env): + data = self.get_data(path_to_env) + return data, self.parser.contains_expected_data(data) + + def can_open_keystore_and_truststore_with_pass(self): + can_open_keystore = self.can_open_store_file_with_pass_file(self.parser.keystorePassPath, self.parser.keystorePath) + can_open_truststore = self.can_open_store_file_with_pass_file(self.parser.truststorePassPath, self.parser.truststorePath) + + return can_open_keystore & can_open_truststore + + def can_open_store_file_with_pass_file(self, pass_file_path, store_file_path): + try: + self.get_certificate(pass_file_path, store_file_path) + return True + except: + return False + + def get_data(self, path_to_env): + envs = self.parser.get_envs_as_dict(EnvsReader().read_env_list_from_file(path_to_env)) + certificate = self.get_certificate(self.parser.keystorePassPath, self.parser.keystorePath) + data = self.parser.get_owner_data_from_certificate(certificate) + data['SANS'] = self.parser.get_sans(certificate) + return type('', (object,), {"expectedData": envs, "actualData": data}) + + def get_certificate(self, pass_file_path, store_file_path): + password = open(pass_file_path, 'rb').read() + crypto.load_pkcs12(open(store_file_path, 'rb').read(), password) + return crypto.load_pkcs12(open(store_file_path, 'rb').read(), password).get_certificate() |