for i in range(len(self)):
yield self[i]
+ def __repr__(self):
+ return "{!r}".format(list(self))
+
class Field:
def __init__(self, length=None, min_length=None, max_length=None, count=None, min_count=None, max_count=None, required=True):
if length is not None and (min_length is not None or max_length is not None):
class Certificate(DataElementGroup):
certificate_type = DataElementField(type='code')
certificate_content = DataElementField(type='bin', max_length=4096)
+
+class UserDefinedSignature(DataElementGroup):
+ pin = DataElementField(type='an', max_length=99)
+ tan = DataElementField(type='an', max_length=99, required=False)
+
+class Response(DataElementGroup):
+ response_code = DataElementField(type='dig', length=4)
+ reference_element = DataElementField(type='an', max_length=7)
+ response_text = DataElementField(type='an', max_length=80)
+ parameters = DataElementField(type='an', max_length=35, max_count=10)
import re
-from fints.formals import Container, SegmentHeader, DataElementGroupField, DataElementField, ReferenceMessage, SegmentSequenceField, SecurityProfile, SecurityIdentificationDetails, SecurityDateTime, EncryptionAlgorithm, KeyName, Certificate, HashAlgorithm, SignatureAlgorithm
+from fints.formals import Container, SegmentHeader, DataElementGroupField, DataElementField, ReferenceMessage, SegmentSequenceField, SecurityProfile, SecurityIdentificationDetails, SecurityDateTime, EncryptionAlgorithm, KeyName, Certificate, HashAlgorithm, SignatureAlgorithm, UserDefinedSignature, Response
from fints.utils import classproperty, SubclassesMixin
key_name = DataElementGroupField(type=KeyName)
certificate = DataElementGroupField(type=Certificate, required=False)
+class HNSHA2(FinTS3Segment):
+ security_reference = DataElementField(type='an', max_length=14)
+ validation_result = DataElementField(type='bin', max_length=512, required=False)
+ user_defined_signature = DataElementGroupField(type=UserDefinedSignature, required=False)
-
+class HIRMG2(FinTS3Segment):
+ response = DataElementGroupField(type=Response, min_count=1, max_count=99)
assert len(m.segments) == 4
assert m.segments[3].__class__.__name__ == "HNHBS1"
+def test_HIRMG2_parse():
+ d = b"HIRMG:3:2+0010::Nachricht entgegengenommen.+0100::Dialog beendet.'"
+ m = FinTS3Parser().parse_message(d)
+
+ seg = m.segments[0]
+ assert seg.header.type == 'HIRMG'
+ assert seg.response[0].response_code == '0010'
+ assert seg.response[1].response_code == '0100'
+ assert len(seg.response) == 2
+
def test_invalid():
message1 = rb"""12"""