Adding pytest config / env and basic auth

This commit is contained in:
evilchili
2022-11-19 16:06:23 -08:00
parent e28a2ffb95
commit 27b97f2bc4
8 changed files with 60 additions and 10 deletions
+7
View File
@@ -0,0 +1,7 @@
import logging
import os
def is_authenticated(username, password):
logging.debug(f"Authentication attempt for {username}, {password}")
return (username == os.environ.get('USERNAME') and password == os.environ.get('PASSWORD'))
+6
View File
@@ -0,0 +1,6 @@
import pytest
@pytest.fixture(scope='session')
def valid_credentials():
return (os.environ.get('USERNAME'), os.environ.get('PASSWORD'))
+8 -1
View File
@@ -1,4 +1,5 @@
from bottle import Bottle
from bottle import Bottle, auth_basic
from groove.auth import is_authenticated
server = Bottle()
@@ -6,3 +7,9 @@ server = Bottle()
@server.route('/')
def index():
return "Groovy."
@server.route('/admin')
@auth_basic(is_authenticated)
def admin():
return "Authenticated. Groovy."