mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 14:04:20 +01:00
* Fixes insufficiently documented changes in ProxyFix
* https://github.com/pallets/werkzeug/issues/1484
* Pin `Werkzeug==0.15.2` in requirements.txt
* Allow exports test to parallelize
36 lines
1012 B
Python
36 lines
1012 B
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from tests.helpers import (
|
|
create_ctfd,
|
|
destroy_ctfd,
|
|
)
|
|
from CTFd.config import TestingConfig
|
|
|
|
|
|
def test_reverse_proxy_config():
|
|
"""Test that REVERSE_PROXY configuration behaviors properly"""
|
|
class ReverseProxyConfig(TestingConfig):
|
|
REVERSE_PROXY = '1,2,3,4'
|
|
|
|
app = create_ctfd(config=ReverseProxyConfig)
|
|
with app.app_context():
|
|
assert app.wsgi_app.x_for == 1
|
|
assert app.wsgi_app.x_proto == 2
|
|
assert app.wsgi_app.x_host == 3
|
|
assert app.wsgi_app.x_port == 4
|
|
assert app.wsgi_app.x_prefix == 0
|
|
destroy_ctfd(app)
|
|
|
|
class ReverseProxyConfig(TestingConfig):
|
|
REVERSE_PROXY = 'true'
|
|
|
|
app = create_ctfd(config=ReverseProxyConfig)
|
|
with app.app_context():
|
|
assert app.wsgi_app.x_for == 1
|
|
assert app.wsgi_app.x_proto == 1
|
|
assert app.wsgi_app.x_host == 1
|
|
assert app.wsgi_app.x_port == 1
|
|
assert app.wsgi_app.x_prefix == 1
|
|
destroy_ctfd(app)
|