Merge pull request #3564 from theref/json

Json Condition :userAddress context variable
epic-non-evm
Derek Pierre 2024-12-04 09:33:44 -05:00 committed by GitHub
commit 0839427718
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 0 deletions

View File

View File

@ -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",