How to use test_xff_header method in localstack

Best Python code snippet using localstack_python

test_proxy.py

Source:test_proxy.py Github

copy

Full Screen

...65 router.add("/foo", ProxyHandler(backend.url_for("/bar")))66 response = requests.get(proxy.url + "/foo")67 assert response.ok68 assert response.text == "ok/bar/" # it's calling /bar/ because it's part of the root URL69 def test_xff_header(self, router_server, httpserver: HTTPServer):70 router, proxy = router_server71 backend = httpserver72 def _echo_headers(request):73 return Response(json.dumps(dict(request.headers)), mimetype="application/json")74 backend.expect_request("/echo").respond_with_handler(_echo_headers)75 router.add("/<path:path>", ProxyHandler(backend.url_for("/")))76 response = requests.get(proxy.url + "/echo")77 assert response.ok78 headers = response.json()79 assert headers["X-Forwarded-For"] == "127.0.0.1"80 # check that it appends remote address correctly if an header is already present81 response = requests.get(proxy.url + "/echo", headers={"X-Forwarded-For": "127.0.0.2"})82 assert response.ok83 headers = response.json()...

Full Screen

Full Screen

test_wsgirequest.py

Source:test_wsgirequest.py Github

copy

Full Screen

1import unittest2import StringIO3from nudge.publisher import WSGIRequest4class WSGIRequestTest(unittest.TestCase):5 def test_xff_header(self):6 input = StringIO.StringIO()7 req = WSGIRequest({8 'REQUEST_METHOD':'POST',9 'REMOTE_ADDR':'127.0.0.1',10 'wsgi.input': input,11 'HTTP_X-Forwarded-For':'10.0.10.123',12 })13 print req.headers14 assert req.headers['X-Forwarded-For'] == '10.0.10.123'15 assert req.headers.get('X-Forwarded-For') == '10.0.10.123', req.headers.get('X-Forwarded-For')16 def test_xff_header_eventlet(self):17 input = StringIO.StringIO()18 req = WSGIRequest({19 'REQUEST_METHOD':'POST',...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful