Spaces:
Running on Zero
Running on Zero
Download tests/test_logging.py from fffiloni/ZONOS3-Mini: direct link, hf CLI and curl.
- Browser
- Download file 953 Bytes
-
https://huggingface.co/spaces/fffiloni/ZONOS3-Mini/resolve/main/tests/test_logging.py
- Command line
-
hf download hf://spaces/fffiloni/ZONOS3-Mini/tests/test_logging.py
-
curl -L -o test_logging.py https://huggingface.co/spaces/fffiloni/ZONOS3-Mini/resolve/main/tests/test_logging.py
953 Bytes
| import logging | |
| import sys | |
| from logging_setup import QueryRedactingFormatter | |
| def test_http_status_survives_but_query_credentials_do_not(): | |
| record=logging.LogRecord("httpx",logging.INFO,"",0,'HTTP Request: POST %s "HTTP/1.1 200 OK"', | |
| ('http://device-api.zero/release?allowToken=test-secret&fail=false',),None) | |
| result=QueryRedactingFormatter('%(message)s').format(record) | |
| assert 'test-secret' not in result and 'allowToken' not in result | |
| assert '/release?[redacted]' in result and '200 OK' in result | |
| def test_exception_urls_are_redacted_too(): | |
| try: | |
| raise ValueError('https://example.test/path?token=test-secret') | |
| except ValueError: | |
| record=logging.LogRecord('httpx',logging.ERROR,'',0,'Request failed',(),sys.exc_info()) | |
| result=QueryRedactingFormatter('%(message)s').format(record) | |
| assert 'test-secret' not in result and 'ValueError' in result and 'Request failed' in result | |