mirror of https://github.com/nucypher/nucypher.git
commit
0839427718
|
@ -258,6 +258,27 @@ def test_json_api_condition_evaluation_with_auth_token(mocker):
|
|||
)
|
||||
|
||||
|
||||
def test_json_api_condition_evaluation_with_user_address_context_variable(
|
||||
mocker, valid_eip4361_auth_message
|
||||
):
|
||||
mocked_get = mocker.patch(
|
||||
"requests.get",
|
||||
return_value=mocker.Mock(status_code=200, json=lambda: 0.0),
|
||||
)
|
||||
condition = JsonApiCondition(
|
||||
endpoint="https://randomapi.com/api/v3/:userAddress",
|
||||
return_value_test=ReturnValueTest("==", 0.0),
|
||||
)
|
||||
auth_message = valid_eip4361_auth_message
|
||||
context = {":userAddress": auth_message}
|
||||
assert condition.verify(**context) == (True, 0.0)
|
||||
assert mocked_get.call_count == 1
|
||||
call_args = mocked_get.call_args
|
||||
assert (
|
||||
call_args.args[0] == f"https://randomapi.com/api/v3/{auth_message['address']}"
|
||||
)
|
||||
|
||||
|
||||
def test_json_api_condition_evaluation_with_various_context_variables(mocker):
|
||||
mocked_get = mocker.patch(
|
||||
"requests.get",
|
||||
|
|
Loading…
Reference in New Issue