Skip to content

Commit

Permalink
Fix for "require_auth" bug, closes #57 (#60)
Browse files Browse the repository at this point in the history
Thanks, Harrison Tsai @harry0123
  • Loading branch information
simonw authored Apr 10, 2020
1 parent cff5a9a commit a1dc4be
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion datasette_auth_github/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def asgi_wrapper(datasette):

# require_auth defaults to True unless set otherwise
require_auth = True
if require_auth in config:
if "require_auth" in config:
require_auth = config["require_auth"]

def wrap_with_asgi_auth(app):
Expand Down
19 changes: 19 additions & 0 deletions test_datasette_auth_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,25 @@ async def test_require_auth_is_true_when_used_as_datasette_plugin():
assert True == app.require_auth


@pytest.mark.asyncio
async def test_require_auth_is_false_when_defined_in_metadata():
app = Datasette(
[],
memory=True,
metadata={
"plugins": {
"datasette-auth-github": {
"client_id": "client_x",
"client_secret": "client_secret_x",
"require_auth": False
}
}
}
).app()
assert isinstance(app, GitHubAuthOriginal)
assert app.require_auth == False


async def hello_world_app(scope, receive, send):
assert scope["type"] == "http"
await send(
Expand Down

0 comments on commit a1dc4be

Please sign in to comment.