From f39f11133126158e28780dee91bb9c7719ef5875 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 11 Jun 2020 15:47:19 -0700 Subject: [PATCH] Fixed actor_matches_allow bug, closes #836 --- datasette/utils/__init__.py | 2 +- tests/test_utils.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/datasette/utils/__init__.py b/datasette/utils/__init__.py index 5090f67e57..69cfa40068 100644 --- a/datasette/utils/__init__.py +++ b/datasette/utils/__init__.py @@ -884,7 +884,7 @@ def actor_matches_allow(actor, allow): values = [values] actor_values = actor.get(key) if actor_values is None: - return False + continue if not isinstance(actor_values, list): actor_values = [actor_values] actor_values = set(actor_values) diff --git a/tests/test_utils.py b/tests/test_utils.py index d613e9995c..da1d298b7f 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -497,6 +497,8 @@ def test_multi_params(data, should_raise): ({"id": "garry", "roles": ["staff", "dev"]}, {"roles": ["dev", "otter"]}, True), ({"id": "garry", "roles": []}, {"roles": ["staff"]}, False), ({"id": "garry"}, {"roles": ["staff"]}, False), + # Any single matching key works: + ({"id": "root"}, {"bot_id": "my-bot", "id": ["root"]}, True), ], ) def test_actor_matches_allow(actor, allow, expected):