Add CSITs for Truststore Merger
[integration/csit.git] / tests / oom-platform-cert-service / truststoremerger / libraries / JksTruststoreValidator.py
1
2 import jks
3
4 class JksTruststoreValidator:
5
6   def get_truststore(self, truststore_path, password_path):
7     truststore = jks.KeyStore.load(truststore_path, open(password_path, 'rb').read())
8     return truststore.certs
9
10   def assert_jks_truststores_equal(self, result_truststore_path, password_path, expected_truststore_path):
11     result_certs = self.get_truststore(result_truststore_path, password_path)
12     expected_certs = self.get_truststore(expected_truststore_path, password_path)
13     if len(result_certs) != len(expected_certs):
14       return False
15     for k in result_certs:
16       if not (k in expected_certs and result_certs[k].cert == expected_certs[k].cert):
17         return False
18     return True