Introduce real Kesystore check
[integration/csit.git] / tests / oom-platform-cert-service / postprocessor / libraries / PemTruststoreValidator.py
1 import re
2
3 BEGIN_CERT = "-----BEGIN CERTIFICATE-----"
4 END_CERT = "-----END CERTIFICATE-----"
5
6 class PemTruststoreValidator:
7
8   def assert_pem_truststores_equal(self, result_pem_path, expected_pem_path):
9     result_certs = self.get_list_of_pem_certificates(result_pem_path)
10     expected_certs = self.get_list_of_pem_certificates(expected_pem_path)
11     result_certs.sort()
12     expected_certs.sort()
13     if len(result_certs) != len(expected_certs):
14       return False
15     return result_certs == expected_certs
16
17
18   def get_list_of_pem_certificates(self, path):
19     return re.findall(BEGIN_CERT + '(.+?)' + END_CERT, open(path, 'rb').read(), re.DOTALL)