# SPDX-License-Identifier: 0BSD def route(role, operation): allowed = {"reporter": {"balance"}, "auditor": {"utxos"}} if operation not in allowed.get(role, set()): raise PermissionError("denied") return "/api/v5/btc/wallet/" + operation assert route("reporter", "balance").endswith("/balance") try: route("reporter", "send") except PermissionError: pass else: raise AssertionError("unexpected write permission")