def test_cache_update_time(self):
"""
Test if the cache next_update works
"""
# Create a pem encoded public key
private_key = generate_private_key(
public_exponent=65537,
key_size=2048,
backend=default_backend()
)
public_key = private_key.public_key()
public_pem = public_key.public_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PublicFormat.SubjectPublicKeyInfo
)
self.keycache.addkeyinfo("https://doesnotexists.com/", "blahstuff", public_key, cache_timer=60, next_update=-1)
# Even though the cache is still valid, the next update is triggered
# We should still get the key, even though the next update fails
# (invalid url)
pubkey = self.keycache.getkeyinfo("https://doesnotexists.com/", "blahstuff")
public_pem2 = pubkey.public_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PublicFormat.SubjectPublicKeyInfo
)
self.assertEqual(public_pem, public_pem2)
评论列表
文章目录