Remove command permission lookup

This commit is contained in:
2026-07-19 18:38:38 +02:00
parent 276b5590b5
commit f68d7cbc32
4 changed files with 6 additions and 48 deletions
+3 -24
View File
@@ -29,13 +29,9 @@ class FakeStorage:
class FakeGitea:
def __init__(self, permitted: bool = True) -> None:
self.permitted = permitted
def __init__(self) -> None:
self.comments: list[str] = []
async def has_write_permission(self, *_args):
return self.permitted
async def create_comment(self, _owner, _repo, _number, body):
self.comments.append(body)
return len(self.comments)
@@ -76,25 +72,8 @@ async def test_authorized_command_is_queued() -> None:
assert "queued" in gitea.comments[0]
async def test_unauthorized_command_is_rejected_and_deduplicated() -> None:
storage = FakeStorage()
gitea = FakeGitea(permitted=False)
container = SimpleNamespace(storage=storage, gitea=gitea)
event = _event_from_payload("delivery", payload("/agent implement"))
assert event is not None
await _handle_command(container, event)
await _handle_command(container, event)
assert storage.jobs == []
assert len(gitea.comments) == 1
assert "write permission" in gitea.comments[0]
async def test_non_command_does_not_query_permission() -> None:
class ExplodingGitea(FakeGitea):
async def has_write_permission(self, *_args):
raise AssertionError("permission lookup should not run")
container = SimpleNamespace(storage=FakeStorage(), gitea=ExplodingGitea())
async def test_non_command_is_ignored() -> None:
container = SimpleNamespace(storage=FakeStorage(), gitea=FakeGitea())
event = _event_from_payload("delivery", payload("ordinary discussion"))
assert event is not None
response = await _handle_command(container, event)