warpgate/tests/test_http_redirects.py
2022-08-14 12:36:49 +02:00

30 lines
856 B
Python

import requests
from .util import wait_port
class TestHTTPRedirects:
def test(
self,
http_common_wg_port,
echo_server_port,
):
wait_port(http_common_wg_port, recv=False)
session = requests.Session()
session.verify = False
url = f'https://localhost:{http_common_wg_port}'
headers = {'Host': f'localhost:{http_common_wg_port}'}
session.post(
f'{url}/@warpgate/api/auth/login',
json={
'username': 'user',
'password': '123',
},
headers=headers,
)
response = session.get(f'{url}/redirect/http://localhost:{echo_server_port}/test?warpgate-target=echo', headers=headers, allow_redirects=False)
print(response.headers)
assert response.headers['location'] == '/test'