Exemple #1
0
def test_auth_include(monkeypatch):
    monkeypatch.setenv('WSGI_AUTH_CREDENTIALS', 'foo:bar')
    monkeypatch.setenv('WSGI_AUTH_PATHS', '/healthcheck')
    application = wsgi_basic_auth.BasicAuth(wsgi_app)
    app = TestApp(application)
    app.get('/', status=200)
    app.get('/healthcheck/foo', status=401)
Exemple #2
0
def test_auth(monkeypatch):
    monkeypatch.setenv('WSGI_AUTH_CREDENTIALS', 'foo:bar')
    application = wsgi_basic_auth.BasicAuth(wsgi_app)
    app = TestApp(application)
    app.get('/', status=401)

    app.authorization = ('Basic', ('foo', 'bar'))
    app.get('/', status=200)
def test_auth_hash(monkeypatch):
    monkeypatch.setenv('WSGI_AUTH_CREDENTIALS',
                       'foo:$apr1$yIPw8J/l$0mPnNW9gbONm8oUgO5EUX1')  # foo:bar
    application = wsgi_basic_auth.BasicAuth(wsgi_app,
                                            hash_schemes=['apr_md5_crypt'])
    app = TestApp(application)
    app.get('/', status=401)

    app.authorization = ('Basic', ('foo', 'baz'))
    app.get('/', status=401)

    app.authorization = ('Basic', ('foo', 'bar'))
    app.get('/', status=200)
Exemple #4
0
def test_no_auth(monkeypatch):
    monkeypatch.delenv('WSGI_AUTH_CREDENTIALS', None)
    application = wsgi_basic_auth.BasicAuth(wsgi_app)
    app = TestApp(application)
    response = app.get('/')
    assert response.status_code == 200
Exemple #5
0
import os
from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bugbounty.settings")
application = get_wsgi_application()

# Throw the whole site behind basic auth, if requested. This is temporary
# until the site gets ATO'd.
if 'WSGI_AUTH_CREDENTIALS' in os.environ:
    import wsgi_basic_auth
    application = wsgi_basic_auth.BasicAuth(application)