mirror of
https://github.com/warp-tech/warpgate.git
synced 2024-11-15 12:31:55 +08:00
31 lines
856 B
Python
31 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'
|