Let AUTHFILE be absolute path

This commit is contained in:
Ruben van Staveren 2022-03-14 15:20:49 +01:00
parent 27bc683f8f
commit feb8c93737
Signed by: ruben
GPG Key ID: 886F6BECD477A93F
2 changed files with 4 additions and 5 deletions

View File

@ -1,5 +1,4 @@
from flask import current_app, g from flask import current_app, g
import os
def get_users(): def get_users():
@ -9,10 +8,10 @@ def get_users():
current_app.logger.debug('Reading %s for users', authfile) current_app.logger.debug('Reading %s for users', authfile)
with current_app.open_resource(os.path.join("..", with current_app.open_resource(authfile) as f:
authfile)) as f:
for entry in f: for entry in f:
users.update({tuple(entry.decode('ascii').strip().split(':', 1))}) users.update({
tuple(entry.decode('ascii').strip().split(':', 1))})
g.users = users g.users = users
current_app.logger.debug(g.users) current_app.logger.debug(g.users)
return g.users return g.users

View File

@ -8,7 +8,7 @@ def app():
app.config.update({ app.config.update({
"TESTING": True, "TESTING": True,
"SECRET_KEY": 'Testing', "SECRET_KEY": 'Testing',
"AUTHFILE": 'tests/users-test.txt' "AUTHFILE": '../tests/users-test.txt'
}) })
# other setup can go here # other setup can go here