mirror of
https://github.com/not-kennethreitz/flask-sslify.git
synced 2026-06-05 06:56:15 +00:00
Test in the simplest situation.
This commit is contained in:
+61
@@ -0,0 +1,61 @@
|
||||
# Created by https://www.gitignore.io
|
||||
|
||||
### Python ###
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
env/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*,cover
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
from flask import Flask
|
||||
from flask_sslify import SSLify
|
||||
from pytest import fixture
|
||||
|
||||
|
||||
@fixture
|
||||
def sslify():
|
||||
app = Flask(__name__)
|
||||
app.config['DEBUG'] = False
|
||||
app.config['TESTING'] = False
|
||||
app.config['SERVER_NAME'] = 'example.com'
|
||||
sslify = SSLify(app)
|
||||
|
||||
@app.route('/')
|
||||
def home():
|
||||
return 'home'
|
||||
|
||||
return sslify
|
||||
|
||||
|
||||
def test_default_config(sslify):
|
||||
assert sslify.hsts_include_subdomains is False
|
||||
assert sslify.permanent is False
|
||||
assert sslify.skip_list is None
|
||||
|
||||
|
||||
def test_redirection(sslify):
|
||||
client = sslify.app.test_client()
|
||||
r = client.get('/')
|
||||
assert r.status_code == 302
|
||||
assert r.headers['Location'] == 'https://example.com/'
|
||||
|
||||
|
||||
def test_hsts_header(sslify):
|
||||
client = sslify.app.test_client()
|
||||
r = client.get('/', base_url='https://example.com')
|
||||
assert r.status_code == 200
|
||||
assert r.data == 'home'
|
||||
assert r.headers['Strict-Transport-Security'] == 'max-age=31536000'
|
||||
Reference in New Issue
Block a user