From 487432869f983b1aa0c5733b0d8e2d478d343e76 Mon Sep 17 00:00:00 2001 From: Alex Bluvstein Date: Sun, 2 Dec 2018 18:02:24 +0200 Subject: [PATCH 1/2] Added travis --- .tavis.yml | 9 +++++++++ tests/px_proxy_handler.py | 8 ++------ 2 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 .tavis.yml diff --git a/.tavis.yml b/.tavis.yml new file mode 100644 index 0000000..1a5e1cd --- /dev/null +++ b/.tavis.yml @@ -0,0 +1,9 @@ +language: python +python: + - "2.7" +# command to install dependencies +install: + - pip install -r requirements.txt +# command to run tests +script: + - python -m unittest discover -s ./tests -p 'px*' \ No newline at end of file diff --git a/tests/px_proxy_handler.py b/tests/px_proxy_handler.py index c5e7bd9..92bce42 100644 --- a/tests/px_proxy_handler.py +++ b/tests/px_proxy_handler.py @@ -60,17 +60,13 @@ def test_send_reverse_captcha_request(self, mock): def test_send_reverse_xhr_request(self, mock): content = 'captcha content' config = PxConfig({'app_id': 'PXfake_app_id'}) - ctx = PxContext({'PATH_INFO': '/fake_app_id/init.js', + ctx = PxContext({'PATH_INFO': '/fake_app_id/xhr/api/v1/collector', 'HTTP_X_FORWARDED_FOR': '127.0.0.1', 'ip': '127.0.0.1'}, PxConfig({'app_id': 'fake_app_id'})) - ctx = {'uri': '/fake_app_id/xhr/api/v1/collector', - 'headers': {'X-FORWARDED-FOR': '127.0.0.1'}, - 'ip': '127.0.0.1', - 'REQUEST_METHOD': 'POST'} headers = {'host': config.collector_host, px_constants.FIRST_PARTY_HEADER: '1', - px_constants.ENFORCER_TRUE_IP_HEADER: ctx.get('ip'), + px_constants.ENFORCER_TRUE_IP_HEADER: ctx.ip, px_constants.FIRST_PARTY_FORWARDED_FOR: '127.0.0.1'} mock.post(url='https://collector-pxfake_app_id.perimeterx.net/api/v1/collector', text=content, request_headers=headers, status_code=200, reason='OK') From 54b925ee22076e26a39321ae135f4564543b5d65 Mon Sep 17 00:00:00 2001 From: Alex Bluvstein Date: Sun, 2 Dec 2018 18:06:36 +0200 Subject: [PATCH 2/2] Added travis --- .tavis.yml => .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .tavis.yml => .travis.yml (73%) diff --git a/.tavis.yml b/.travis.yml similarity index 73% rename from .tavis.yml rename to .travis.yml index 1a5e1cd..7b5b817 100644 --- a/.tavis.yml +++ b/.travis.yml @@ -6,4 +6,4 @@ install: - pip install -r requirements.txt # command to run tests script: - - python -m unittest discover -s ./tests -p 'px*' \ No newline at end of file + - python -m unittest discover -s ./tests -p 'px*'