summaryrefslogtreecommitdiffhomepage
path: root/test/test_client_ip.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_client_ip.py')
-rw-r--r--test/test_client_ip.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/test/test_client_ip.py b/test/test_client_ip.py
index 82c76718..538db18b 100644
--- a/test/test_client_ip.py
+++ b/test/test_client_ip.py
@@ -1,4 +1,5 @@
import pytest
+
from unit.applications.lang.python import ApplicationPython
from unit.option import option
@@ -15,11 +16,11 @@ def setup_method_fixture():
def client_ip(options):
assert 'success' in client.conf(
{
- "127.0.0.1:7081": {
+ "127.0.0.1:8081": {
"client_ip": options,
"pass": "applications/client_ip",
},
- "[::1]:7082": {
+ "[::1]:8082": {
"client_ip": options,
"pass": "applications/client_ip",
},
@@ -34,8 +35,8 @@ def client_ip(options):
def get_xff(xff, sock_type='ipv4'):
address = {
- 'ipv4': ('127.0.0.1', 7081),
- 'ipv6': ('::1', 7082),
+ 'ipv4': ('127.0.0.1', 8081),
+ 'ipv6': ('::1', 8082),
'unix': (f'{option.temp_dir}/sock', None),
}
(addr, port) = address[sock_type]
@@ -51,9 +52,9 @@ def get_xff(xff, sock_type='ipv4'):
def test_client_ip_single_ip():
client_ip({'header': 'X-Forwarded-For', 'source': '123.123.123.123'})
- assert client.get(port=7081)['body'] == '127.0.0.1', 'ipv4 default'
+ assert client.get(port=8081)['body'] == '127.0.0.1', 'ipv4 default'
assert (
- client.get(sock_type='ipv6', port=7082)['body'] == '::1'
+ client.get(sock_type='ipv6', port=8082)['body'] == '::1'
), 'ipv6 default'
assert get_xff('1.1.1.1') == '127.0.0.1', 'bad source'
assert get_xff('blah') == '127.0.0.1', 'bad header'
@@ -61,9 +62,9 @@ def test_client_ip_single_ip():
client_ip({'header': 'X-Forwarded-For', 'source': '127.0.0.1'})
- assert client.get(port=7081)['body'] == '127.0.0.1', 'ipv4 default 2'
+ assert client.get(port=8081)['body'] == '127.0.0.1', 'ipv4 default 2'
assert (
- client.get(sock_type='ipv6', port=7082)['body'] == '::1'
+ client.get(sock_type='ipv6', port=8082)['body'] == '::1'
), 'ipv6 default 2'
assert get_xff('1.1.1.1') == '1.1.1.1', 'replace'
assert get_xff('blah') == '127.0.0.1', 'bad header 2'
@@ -159,7 +160,7 @@ def test_client_ip_empty_source():
def test_client_ip_invalid():
assert 'error' in client.conf(
{
- "127.0.0.1:7081": {
+ "127.0.0.1:8081": {
"client_ip": {"source": '127.0.0.1'},
"pass": "applications/client_ip",
}
@@ -170,7 +171,7 @@ def test_client_ip_invalid():
def check_invalid_source(source):
assert 'error' in client.conf(
{
- "127.0.0.1:7081": {
+ "127.0.0.1:8081": {
"client_ip": {
"header": "X-Forwarded-For",
"source": source,