def test_auth_rule_static_validation_failed_with_excess_field(auth_rules_request, auth_rules_handler: AuthRulesHandler): rule = auth_rules_request.operation[RULES][0] rule[OLD_VALUE] = "old_value" rule[AUTH_TYPE] = ADD_PREFIX with pytest.raises(InvalidClientRequest, match="ADD must not contain field old_value"): auth_rules_handler.static_validation(auth_rules_request)
def test_auth_rule_static_validation_failed_with_incorrect_key(auth_rules_request, auth_rules_handler: AuthRulesHandler): auth_rules_request.operation[RULES].append(generate_auth_rule(auth_action=ADD_PREFIX, auth_type="wrong_type", field=ROLE, new_value=ENDORSER)) with pytest.raises(InvalidClientRequest, match="key .* is not found in authorization map"): auth_rules_handler.static_validation(auth_rules_request)
def test_auth_rule_static_validation_failed_without_old_value(auth_rules_request, auth_rules_handler: AuthRulesHandler): rule = auth_rules_request.operation[RULES][0] if OLD_VALUE in rule: del rule[OLD_VALUE] rule[AUTH_ACTION] = EDIT_PREFIX with pytest.raises(InvalidClientRequest, match="EDIT must contain field old_value"): auth_rules_handler.static_validation(auth_rules_request)
def test_auth_rule_static_validation(auth_rules_request, auth_rules_handler: AuthRulesHandler): auth_rules_handler.static_validation(auth_rules_request)