webutil.tests package
Submodules
webutil.tests.test_flask_util module
webutil.tests.test_logs module
Unit tests for logs.py. Woefully incomplete.
webutil.tests.test_models module
Unit tests for models.py.
- class EnumModel(**kwargs)[source]
Bases:
Model- field
Property for storing Python Enum values.
Stores the enum’s integer value in the datastore.
- class EncryptedModel(**kwargs)[source]
Bases:
Model- secret
Property that stores encrypted bytes.
Encrypts bytes values using AES-256-GCM before storing in the datastore, and decrypts them when reading back.
The AES-256-GCM key(s) should be in the
encrypted_property_keyfile, base64 encoded, one per line. Encryption always uses the first key. For decryption, each key is tried in order until one succeeds.Multiple keys are used during key rotation: add the new key as the first line and keep the old key as the second line. New writes will use the new key, and existing ciphertexts encrypted with the old key will still decrypt via fallback. Once all stored values have been re-encrypted with the new key, remove the old key.
Here’s example code to generate an AES-256-GCM key and base64 encode it:
import base64 from cryptography.hazmat.primitives.ciphers.aead import AESGCM
key_bytes = AESGCM.generate_key(bit_length=256) print(base64.b64encode(key_bytes))
webutil.tests.test_util module
webutil.tests.test_webmention module
Unit tests for webmention.py.