Spaces:
Runtime error
Runtime error
Download platform/reworkd_platform/tests/test_security.py from dia-gov/AgentGPT-Web-GUI: direct link, hf CLI and curl.
- Browser
- Download file 758 Bytes
-
https://huggingface.co/spaces/dia-gov/AgentGPT-Web-GUI/resolve/main/platform/reworkd_platform/tests/test_security.py
- Command line
-
hf download hf://spaces/dia-gov/AgentGPT-Web-GUI/platform/reworkd_platform/tests/test_security.py
-
curl -L -o test_security.py https://huggingface.co/spaces/dia-gov/AgentGPT-Web-GUI/resolve/main/platform/reworkd_platform/tests/test_security.py
758 Bytes
| import pytest | |
| from cryptography.fernet import Fernet | |
| from fastapi import HTTPException | |
| from reworkd_platform.services.security import EncryptionService | |
| def test_encrypt_decrypt(): | |
| key = Fernet.generate_key() | |
| service = EncryptionService(key) | |
| original_text = "Hello, world!" | |
| encrypted = service.encrypt(original_text) | |
| decrypted = service.decrypt(encrypted) | |
| assert original_text == decrypted | |
| def test_invalid_key(): | |
| key = Fernet.generate_key() | |
| different_key = Fernet.generate_key() | |
| different_service = EncryptionService(different_key) | |
| original_text = "Hello, world!" | |
| encrypted = Fernet(key).encrypt(original_text.encode()) | |
| with pytest.raises(HTTPException): | |
| different_service.decrypt(encrypted) | |