Download tests/test_audit.py from dev-collab-org/dev-bucket-sync: direct link, hf CLI and curl.
- Browser
- Download file 988 Bytes
-
https://huggingface.co/spaces/dev-collab-org/dev-bucket-sync/resolve/main/tests/test_audit.py
- Command line
-
hf download hf://spaces/dev-collab-org/dev-bucket-sync/tests/test_audit.py
-
curl -L -o test_audit.py https://huggingface.co/spaces/dev-collab-org/dev-bucket-sync/resolve/main/tests/test_audit.py
988 Bytes
| import json | |
| import pytest | |
| from app.audit import AuditLogger | |
| from app.config import Settings | |
| from fakes import FakeHub | |
| def test_caller_ip_omitted_when_audit_bucket_is_in_challenge_org(audit_bucket, in_org): | |
| settings = Settings(ORG="test-org", COLLAB_SLUG="test", AUDIT_BUCKET=audit_bucket) | |
| assert settings.audit_bucket_in_org is in_org | |
| hub = FakeHub(settings) | |
| AuditLogger(hub, record_client=not settings.audit_bucket_in_org).write( | |
| agent_id="agent-1", route="/v1/sync", via=None, source=None, | |
| target_path=None, bytes_count=0, status_code=200, | |
| caller_ip="203.0.113.7", user_agent="curl/8", | |
| ) | |
| (log,) = hub.buckets[audit_bucket].values() | |
| record = json.loads(log) | |
| assert record["agent_id"] == "agent-1" | |
| assert ("caller_ip" in record) is not in_org | |
| assert ("user_agent" in record) is not in_org | |