(ip=None, proxy_username=None, auth_username=None, proxied_ip=None)
| 7 | |
| 8 | |
| 9 | def mock_request_handler(ip=None, proxy_username=None, auth_username=None, proxied_ip=None): |
| 10 | handler_mock = mock_object() |
| 11 | |
| 12 | handler_mock.application = mock_object() |
| 13 | |
| 14 | handler_mock.application.identification = mock_object() |
| 15 | handler_mock.application.identification.identify_for_audit = lambda x: auth_username |
| 16 | |
| 17 | handler_mock.request = mock_object() |
| 18 | handler_mock.request.headers = {} |
| 19 | if proxy_username: |
| 20 | credentials = proxy_username + ':pwd' |
| 21 | credentials_base64 = base64.encodebytes(credentials.encode('utf-8')) |
| 22 | handler_mock.request.headers['Authorization'] = 'Basic ' + credentials_base64.decode('utf-8') |
| 23 | |
| 24 | handler_mock.request.remote_ip = ip |
| 25 | |
| 26 | if proxied_ip: |
| 27 | handler_mock.request.headers['X-Forwarded-For'] = proxied_ip |
| 28 | |
| 29 | return handler_mock |
| 30 | |
| 31 | |
| 32 | def get_audit_name(request_handler): |
no test coverage detected