crypto: add colon seperator for fingerprint

This commit is contained in:
Jens Langhammer 2020-07-07 17:05:31 +02:00
parent c00e01626e
commit 169475ab39
5 changed files with 6 additions and 5 deletions

View File

@ -56,7 +56,9 @@ class CertificateKeyPair(CreatedUpdatedModel):
@property
def fingerprint(self) -> str:
"""Get SHA256 Fingerprint of certificate_data"""
return hexlify(self.certificate.fingerprint(hashes.SHA256())).decode("utf-8")
return hexlify(self.certificate.fingerprint(hashes.SHA256()), ":").decode(
"utf-8"
)
def __str__(self) -> str:
return f"Certificate-Key Pair {self.name} {self.fingerprint}"

View File

@ -23,4 +23,4 @@ def get_client_ip(request: Optional[HttpRequest]) -> Optional[str]:
Returns none if no IP Could be found"""
if request:
return _get_client_ip_from_meta(request.META)
return ""
return None

View File

@ -14,7 +14,6 @@ def invalidate_policy_cache(sender, instance, **_):
from passbook.policies.models import Policy, PolicyBinding
if isinstance(instance, Policy):
LOGGER.debug("Invalidating policy cache", policy=instance)
total = 0
for binding in PolicyBinding.objects.filter(policy=instance):
prefix = (
@ -23,4 +22,4 @@ def invalidate_policy_cache(sender, instance, **_):
keys = cache.keys(prefix)
total += len(keys)
cache.delete_many(keys)
LOGGER.debug("Deleted keys", len=total)
LOGGER.debug("Invalidating policy cache", policy=instance, keys=total)

View File

@ -9,7 +9,7 @@ from passbook.policies.expression.models import ExpressionPolicy
from passbook.policies.models import Policy, PolicyBinding, PolicyBindingModel
class PolicyTestEngine(TestCase):
class TestPolicyEngine(TestCase):
"""PolicyEngine tests"""
def setUp(self):