test(utils): Add test and error handling for wiped InMemorySecret

- Updated `InMemorySecret.get_bytes()` in `src/utils/memory_protection.py` to raise a `RuntimeError` if the secret has been wiped, replacing the previous `AttributeError`.
- Added `test_access_after_wipe_raises_error` to `src/tests/test_memory_protection.py` to verify this behavior.

Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
google-labs-jules[bot]andPR0M3TH3AN committed 2026-02-16 17:21:45 +00:00
1 parent 335de7abe3
commit d729466513
2 files changed
+15

No files matched your search

+2
View File
@@ -17,6 +17,8 @@ class InMemorySecret:
def get_bytes(self) -> bytes:
"""Decrypt and return the plaintext bytes."""
if self._cipher is None:
raise RuntimeError("Secret has been wiped")
return self._cipher.decrypt(self._nonce, self._encrypted, None)
def wipe(self) -> None: