Test in the simplest situation.

This commit is contained in:
Jiangge Zhang
2015-04-24 17:45:09 +08:00
parent 6f042e4379
commit 8d2ab77815
3 changed files with 100 additions and 0 deletions
+61
View File
@@ -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/
View File
+39
View File
@@ -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'