def test_get_secret_fingerprint(self, secrets): a, b, c, d = [secrets[x] for x in sorted(secrets)] assert SecretUtils.get_secret_fingerprint(a) == "AA:BB" assert SecretUtils.get_secret_fingerprint(b) == "AA:CC" assert SecretUtils.get_secret_fingerprint(c) == "AA:DD" assert SecretUtils.get_secret_fingerprint(d) is None
def is_secret_deployed(self, domain, name, fingerprint): # type: (str, str, str) -> bool """Check whether a secret is already deployed based on fingerprints. :param domain str: The domain the secret authenticates. :param name str: The name of the secret. :param fingerprint str: The fingerprint of the *certificate* corresponding to this secret. :return: True if deployed, False otherwise. :rtype: bool """ existing_secrets = self.get_secrets(domain, name) if len(existing_secrets) != 0: newest = existing_secrets[-1] newest_fp = SecretUtils.get_secret_fingerprint(newest) if newest_fp == fingerprint: # Skip deployment if the secret has already been deployed. return True return False