only pass one func to exception kwarg in access decorator
This commit is contained in:
@@ -137,11 +137,10 @@ def test_user_can_access_decorator_exceptions(set_current_user):
|
||||
rando_calrissian = UserFactory.create()
|
||||
portfolio = PortfolioFactory.create()
|
||||
|
||||
wont_work = lambda *args, **kwargs: False
|
||||
because_i_said_so = lambda *args, **kwargs: True
|
||||
|
||||
@user_can_access_decorator(
|
||||
Permissions.EDIT_PORTFOLIO_NAME, exceptions=[wont_work, because_i_said_so]
|
||||
Permissions.EDIT_PORTFOLIO_NAME, exception=because_i_said_so
|
||||
)
|
||||
def _edit_portfolio_name(*args, **kwargs):
|
||||
return True
|
||||
|
@@ -84,10 +84,9 @@ def test_all_protected_routes_have_access_control(
|
||||
monkeypatch.setattr("atst.domain.portfolios.Portfolios.get", lambda *a: None)
|
||||
monkeypatch.setattr("atst.domain.task_orders.TaskOrders.get", lambda *a: Null())
|
||||
|
||||
# patch the two internal functions the access decorator uses so
|
||||
# that we can check that one or the other was called
|
||||
mocker.patch("atst.domain.authz.decorator.user_can_access")
|
||||
mocker.patch("atst.domain.authz.decorator.evaluate_exceptions")
|
||||
# patch the internal function the access decorator uses so that
|
||||
# we can check that it was called
|
||||
mocker.patch("atst.domain.authz.decorator.check_access")
|
||||
|
||||
user = UserFactory.create()
|
||||
user_session(user)
|
||||
@@ -96,8 +95,7 @@ def test_all_protected_routes_have_access_control(
|
||||
getattr(client, method)(route)
|
||||
|
||||
assert (
|
||||
atst.domain.authz.decorator.user_can_access.call_count == 1
|
||||
or atst.domain.authz.decorator.evaluate_exceptions.call_count == 1
|
||||
atst.domain.authz.decorator.check_access.call_count == 1
|
||||
), "no access control for {}".format(rule.endpoint)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user