crypto: add colon seperator for fingerprint
This commit is contained in:
parent
c00e01626e
commit
169475ab39
|
@ -56,7 +56,9 @@ class CertificateKeyPair(CreatedUpdatedModel):
|
||||||
@property
|
@property
|
||||||
def fingerprint(self) -> str:
|
def fingerprint(self) -> str:
|
||||||
"""Get SHA256 Fingerprint of certificate_data"""
|
"""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:
|
def __str__(self) -> str:
|
||||||
return f"Certificate-Key Pair {self.name} {self.fingerprint}"
|
return f"Certificate-Key Pair {self.name} {self.fingerprint}"
|
||||||
|
|
|
@ -23,4 +23,4 @@ def get_client_ip(request: Optional[HttpRequest]) -> Optional[str]:
|
||||||
Returns none if no IP Could be found"""
|
Returns none if no IP Could be found"""
|
||||||
if request:
|
if request:
|
||||||
return _get_client_ip_from_meta(request.META)
|
return _get_client_ip_from_meta(request.META)
|
||||||
return ""
|
return None
|
||||||
|
|
|
@ -14,7 +14,6 @@ def invalidate_policy_cache(sender, instance, **_):
|
||||||
from passbook.policies.models import Policy, PolicyBinding
|
from passbook.policies.models import Policy, PolicyBinding
|
||||||
|
|
||||||
if isinstance(instance, Policy):
|
if isinstance(instance, Policy):
|
||||||
LOGGER.debug("Invalidating policy cache", policy=instance)
|
|
||||||
total = 0
|
total = 0
|
||||||
for binding in PolicyBinding.objects.filter(policy=instance):
|
for binding in PolicyBinding.objects.filter(policy=instance):
|
||||||
prefix = (
|
prefix = (
|
||||||
|
@ -23,4 +22,4 @@ def invalidate_policy_cache(sender, instance, **_):
|
||||||
keys = cache.keys(prefix)
|
keys = cache.keys(prefix)
|
||||||
total += len(keys)
|
total += len(keys)
|
||||||
cache.delete_many(keys)
|
cache.delete_many(keys)
|
||||||
LOGGER.debug("Deleted keys", len=total)
|
LOGGER.debug("Invalidating policy cache", policy=instance, keys=total)
|
||||||
|
|
|
@ -9,7 +9,7 @@ from passbook.policies.expression.models import ExpressionPolicy
|
||||||
from passbook.policies.models import Policy, PolicyBinding, PolicyBindingModel
|
from passbook.policies.models import Policy, PolicyBinding, PolicyBindingModel
|
||||||
|
|
||||||
|
|
||||||
class PolicyTestEngine(TestCase):
|
class TestPolicyEngine(TestCase):
|
||||||
"""PolicyEngine tests"""
|
"""PolicyEngine tests"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
Reference in New Issue