コード例 #1
0
 def fill_auth_map_for_node(node, txn_type):
     validator = node.write_req_validator
     for rule_id, constraint in validator.auth_map.items():
         add_rule_id = compile_action_id(txn_type=txn_type, field='*', old_value='*', new_value='*',
                                         prefix=ADD_PREFIX)
         edit_rule_id = compile_action_id(txn_type=txn_type, field='*', old_value='*', new_value='*',
                                          prefix=EDIT_PREFIX)
         if AbstractAuthStrategy.is_accepted_action_id(add_rule_id, rule_id) or \
                 AbstractAuthStrategy.is_accepted_action_id(edit_rule_id, rule_id):
             constraint = copy.deepcopy(constraint)
             if constraint:
                 constraint.set_metadata({FEES_FIELD_NAME: txn_type_to_alias[txn_type]})
                 validator.auth_map[rule_id] = constraint
コード例 #2
0
def test_get_action_id_action_add(action_add):
    assert action_add.get_action_id() == compile_action_id(
        txn_type='SomeType',
        field='some_field',
        old_value='*',
        new_value='new_value',
        prefix=ADD_PREFIX)
コード例 #3
0
def test_get_action_id_action_edit(action_edit):
    assert action_edit.get_action_id() == compile_action_id(
        txn_type='SomeType',
        field='some_field',
        old_value='old_value',
        new_value='new_value',
        prefix=EDIT_PREFIX)
コード例 #4
0
def test_split_action_id():
    origin = ActionDef('PREFIX', 'SomeType', 'some_field', 'old_value', 'new_value')
    splitted_action = split_action_id(compile_action_id(txn_type='SomeType',
                                                        field='some_field',
                                                        old_value='old_value',
                                                        new_value='new_value',
                                                        prefix='PREFIX'))
    assert origin.prefix == splitted_action.prefix
    assert origin.txn_type == splitted_action.txn_type
    assert origin.field == splitted_action.field
    assert origin.old_value == splitted_action.old_value
    assert origin.new_value == splitted_action.new_value