예제 #1
0
 def test_submit_transaction_checks_if_key_is_allowed(self, mock_queue, mock_gen_model):
     mock_key = MagicMock()
     mock_key.is_key_allowed.return_value = True
     transactions.submit_transaction_v1({}, None, api_key=mock_key)
     mock_key.is_key_allowed.assert_called_once()
     mock_key.is_key_allowed.return_value = False
     self.assertRaises(exceptions.ActionForbidden, transactions.submit_transaction_v1, {}, None, api_key=mock_key)
예제 #2
0
def post_transaction_v1(**kwargs) -> Tuple[str, int, Dict[str, str]]:
    if not flask.request.is_json:
        raise exceptions.BadRequest("Could not parse JSON")

    txn = flask.request.json

    try:
        _validate_txn_create_v1(txn)
    except fastjsonschema.JsonSchemaException as e:
        raise exceptions.ValidationException(str(e))

    return helpers.flask_http_response(
        201, transactions.submit_transaction_v1(txn, flask.request.headers.get("X-Callback-URL"), api_key=kwargs["used_auth_key"])
    )
예제 #3
0
def post_transaction_v1() -> Tuple[str, int, Dict[str, str]]:
    if not flask.request.is_json:
        raise exceptions.BadRequest("Could not parse JSON")

    txn = flask.request.json

    try:
        _validate_txn_create_v1(txn)
    except fastjsonschema.JsonSchemaException:
        raise exceptions.ValidationException(
            "User input did not match JSON schema")

    return helpers.flask_http_response(
        201,
        transactions.submit_transaction_v1(
            txn, flask.request.headers.get("X-Callback-URL")))