예제 #1
0
def test_invalid_operation_auth_constraints():
    # ConstraintListField without required field 'auth_constraints'
    invalid_auth_rule_operation = generate_auth_rule_operation(constraint=generate_constraint_list(
        auth_constraints=[generate_constraint_entity(),
                          generate_constraint_entity()]))
    del invalid_auth_rule_operation[CONSTRAINT][AUTH_CONSTRAINTS]
    with pytest.raises(TypeError, match=AUTH_CONSTRAINTS):
        validator.validate(invalid_auth_rule_operation)
예제 #2
0
def test_auth_rule_transaction_with_large_constraint(looper,
                                                     sdk_wallet_trustee,
                                                     sdk_pool_handle):
    constraint = generate_constraint_list(auth_constraints=[generate_constraint_entity(role=TRUSTEE),
                                                            generate_constraint_entity(role=STEWARD)])
    sdk_send_and_check_auth_rule_request(looper,
                                         sdk_wallet_trustee,
                                         sdk_pool_handle,
                                         constraint=constraint)
예제 #3
0
def test_invalid_operation_constraint_id_with_large_constraint():
    # ConstraintListField without required field CONSTRAINT_ID on the 2nd level
    invalid_auth_rule_operation = generate_auth_rule_operation(constraint=generate_constraint_list(
        auth_constraints=[generate_constraint_entity(),
                          generate_constraint_list(
                              auth_constraints=[generate_constraint_entity(),
                                                generate_constraint_entity()])]))
    del invalid_auth_rule_operation[CONSTRAINT][AUTH_CONSTRAINTS][1][CONSTRAINT_ID]
    with pytest.raises(TypeError, match=CONSTRAINT_ID):
        validator.validate(invalid_auth_rule_operation)
예제 #4
0
def test_invalid_entity_role_in_extra_large_constraint():
    # ConstraintEntityField without required field 'role'
    invalid_auth_rule_operation = generate_auth_rule_operation(constraint=generate_constraint_list(
        auth_constraints=[generate_constraint_entity(),
                          generate_constraint_list(
                              auth_constraints=[generate_constraint_entity(),
                                                generate_constraint_entity()])]))
    del invalid_auth_rule_operation[CONSTRAINT][AUTH_CONSTRAINTS][1][AUTH_CONSTRAINTS][0][ROLE]
    with pytest.raises(TypeError, match=ROLE):
        validator.validate(invalid_auth_rule_operation)
예제 #5
0
def test_invalid_operation_with_empty_auth_constraints():
    # ConstraintListField without empty list in auth_constraints
    invalid_auth_rule_operation = generate_auth_rule_operation(constraint=generate_constraint_list(
        auth_constraints=[generate_constraint_entity(),
                          generate_constraint_list(
                              auth_constraints=[])]))
    with pytest.raises(TypeError, match="Fields {} should not be an empty "
                                        "list.".format(AUTH_CONSTRAINTS)):
        validator.validate(invalid_auth_rule_operation)
예제 #6
0
def test_reject_with_unacceptable_role_in_constraint(looper,
                                                     sdk_wallet_trustee,
                                                     sdk_pool_handle):
    constraint = generate_constraint_entity()
    unacceptable_role = 'olololo'
    constraint[ROLE] = unacceptable_role
    with pytest.raises(RequestNackedException) as e:
        sdk_send_and_check_auth_rule_request(looper,
                                             sdk_wallet_trustee,
                                             sdk_pool_handle,
                                             constraint=constraint)
    e.match('InvalidClientRequest')
    e.match('Role {} is not acceptable'.format(unacceptable_role))
예제 #7
0
import pytest

from indy_common.constants import CONSTRAINT, AUTH_ACTION
from indy_common.types import ClientAuthRuleOperation
from indy_node.test.auth_rule_change.helper import generate_constraint_entity, generate_constraint_list, \
    generate_auth_rule_operation
from indy_common.authorize.auth_constraints import ROLE, AUTH_CONSTRAINTS, CONSTRAINT_ID

validator = ClientAuthRuleOperation()

valid_auth_rule_operation_small = generate_auth_rule_operation()
valid_auth_rule_operation_large = generate_auth_rule_operation(constraint=generate_constraint_list(
    auth_constraints=[generate_constraint_entity(),
                      generate_constraint_entity()]))
valid_auth_rule_operation_extra_large = generate_auth_rule_operation(constraint=generate_constraint_list(
    auth_constraints=[generate_constraint_entity(),
                      generate_constraint_list(
                          auth_constraints=[generate_constraint_entity(),
                                            generate_constraint_entity()])]))


def test_valid():
    validator.validate(valid_auth_rule_operation_small)
    validator.validate(valid_auth_rule_operation_large)
    validator.validate(valid_auth_rule_operation_extra_large)


def test_invalid_operation_action():
    # must be ADD_PREFIX or EDIT_PREFIX
    invalid_auth_rule_operation = generate_auth_rule_operation(auth_action="auth_action")
    with pytest.raises(TypeError, match=AUTH_ACTION):