2019-04-19 06:11:09 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2019-05-12 01:09:37 +00:00
|
|
|
from tests.helpers import create_ctfd, destroy_ctfd
|
2019-04-19 06:11:09 +00:00
|
|
|
from CTFd.config import TestingConfig
|
|
|
|
|
|
|
|
|
|
|
|
def test_reverse_proxy_config():
|
|
|
|
"""Test that REVERSE_PROXY configuration behaviors properly"""
|
2019-05-12 01:09:37 +00:00
|
|
|
|
2019-04-19 06:11:09 +00:00
|
|
|
class ReverseProxyConfig(TestingConfig):
|
2019-05-12 01:09:37 +00:00
|
|
|
REVERSE_PROXY = "1,2,3,4"
|
2019-04-19 06:11:09 +00:00
|
|
|
|
|
|
|
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):
|
2019-05-12 01:09:37 +00:00
|
|
|
REVERSE_PROXY = "true"
|
2019-04-19 06:11:09 +00:00
|
|
|
|
|
|
|
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)
|