Commit ac7b74e4 authored by Jérome Perrin's avatar Jérome Perrin

software/erp5/test: make forwarded for test more relaxed

The test expecting that X-Forwarded-For is empty can also accept the
case where X-Forwarded-For header is not present.
parent be655d15
...@@ -586,7 +586,7 @@ class TestFrontendXForwardedFor(BalancerTestCase): ...@@ -586,7 +586,7 @@ class TestFrontendXForwardedFor(BalancerTestCase):
cert=(client_certificate.cert_file, client_certificate.key_file), cert=(client_certificate.cert_file, client_certificate.key_file),
verify=False, verify=False,
).json() ).json()
self.assertEqual(result['Incoming Headers'].get('x-forwarded-for').split(', ')[0], '1.2.3.4') self.assertEqual(result['Incoming Headers'].get('x-forwarded-for', '').split(', ')[0], '1.2.3.4')
def test_x_forwarded_for_stripped_when_not_verified_connection(self): def test_x_forwarded_for_stripped_when_not_verified_connection(self):
# type: () -> None # type: () -> None
...@@ -596,7 +596,7 @@ class TestFrontendXForwardedFor(BalancerTestCase): ...@@ -596,7 +596,7 @@ class TestFrontendXForwardedFor(BalancerTestCase):
headers={'X-Forwarded-For': '1.2.3.4'}, headers={'X-Forwarded-For': '1.2.3.4'},
verify=False, verify=False,
).json() ).json()
self.assertNotEqual(result['Incoming Headers'].get('x-forwarded-for').split(', ')[0], '1.2.3.4') self.assertNotEqual(result['Incoming Headers'].get('x-forwarded-for', '').split(', ')[0], '1.2.3.4')
balancer_url = json.loads(self.computer_partition.getConnectionParameterDict()['_'])['default-auth'] balancer_url = json.loads(self.computer_partition.getConnectionParameterDict()['_'])['default-auth']
with self.assertRaises(OpenSSL.SSL.Error): with self.assertRaises(OpenSSL.SSL.Error):
requests.get( requests.get(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment