How to use the fints.segments.message.HNHBS1 function in fints

To help you get started, we’ve selected a few fints examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github raphaelm / python-fints / tests / test_formals.py View on Github external
def test_find_by_class():
    from conftest import TEST_MESSAGES
    from fints.parser import FinTS3Parser
    from fints.segments.message import HNHBS1

    m = FinTS3Parser().parse_message(TEST_MESSAGES['basic_complicated'])

    assert list(m.find_segments(HNHBS1))[0].__class__ == HNHBS1

    assert m.find_segment_first(HNHBS1).header.type == 'HNHBS'
github raphaelm / python-fints / tests / test_message_serializer.py View on Github external
fints.segments.message.HNVSD1(header=fints.formals.SegmentHeader('HNVSD', 999, 1), data=SegmentSequence([fints.segments.message.HNSHK4(
                             header=fints.formals.SegmentHeader('HNSHK', 2, 4),
                             security_profile=fints.formals.SecurityProfile(security_method='PIN', security_method_version=1), security_function='999',
                             security_reference='9166926', security_application_area='1', security_role='1',
                             security_identification_details=fints.formals.SecurityIdentificationDetails(identified_role='2', cid=None,
                                                                                                         identifier='oIm3BlHv6mQBAADYgbPpp+kWrAQA'),
                             security_reference_number=1, security_datetime=fints.formals.SecurityDateTime(date_time_type='1'),
                             hash_algorithm=fints.formals.HashAlgorithm(usage_hash='1', hash_algorithm='999', algorithm_parameter_name='1'),
                             signature_algorithm=fints.formals.SignatureAlgorithm(usage_signature='6', signature_algorithm='10', operation_mode='16'),
                             key_name=fints.formals.KeyName(bank_identifier=fints.formals.BankIdentifier(country_identifier='280', bank_code='15050500'),
                                                            user_id='hermes', key_type='S', key_number=0, key_version=0)), fints.segments.dialog.HIRMG2(
                             header=fints.formals.SegmentHeader('HIRMG', 3, 2),
                             responses=[fints.formals.Response(code='0010', reference_element=None, text='Nachricht entgegengenommen.'),
                                        fints.formals.Response(code='0100', reference_element=None, text='Dialog beendet.')]), fints.segments.message.HNSHA2(
                             header=fints.formals.SegmentHeader('HNSHA', 4, 2), security_reference='9166926')])),
                         fints.segments.message.HNHBS1(header=fints.formals.SegmentHeader('HNHBS', 5, 1), message_number=2)])

    assert FinTS3Serializer().serialize_message(s) == TEST_MESSAGES['basic_simple']
github raphaelm / python-fints / tests / test_formals.py View on Github external
def test_find_1():
    from conftest import TEST_MESSAGES
    from fints.parser import FinTS3Parser
    from fints.segments.message import HNHBS1, HNHBK3

    m = FinTS3Parser().parse_message(TEST_MESSAGES['basic_complicated'])

    assert len(list(m.find_segments('HNHBK'))) == 1
    assert len(list(m.find_segments(['HNHBK', 'HNHBS']))) == 2

    assert len(list(m.find_segments(['HNHBK', 'HNHBS'], 1))) == 1
    assert len(list(m.find_segments(['HNHBK', 'HNHBS'], (1, 3)))) == 2

    assert isinstance(m.find_segment_first('HNHBK'), HNHBK3)
    assert isinstance(m.find_segment_first('HNHBS'), HNHBS1)

    assert m.find_segment_first('ITST') is None

    assert len(m.find_segment_first('HITANS', 1).parameter.twostep_parameters) == 2
    assert len(m.find_segment_first('HITANS', 3).parameter.twostep_parameters) == 6

    assert m.find_segment_first('HITANS', recurse=False) is None
github raphaelm / python-fints / tests / test_models.py View on Github external
def test_descriptor_in_use():
    assert isinstance(HNHBS1._fields['message_number'], NumericField)
github raphaelm / python-fints / tests / test_models.py View on Github external
def test_fints3_constructor_auto_segmentheader():
    a = HNHBS1(7)

    assert a.message_number == 7
github raphaelm / python-fints / tests / test_models.py View on Github external
def test_data_element_constructor():
    a = HNHBS1(message_number='4')

    assert a.message_number == 4
github raphaelm / python-fints / fints / dialog.py View on Github external
def finish_message(self, message):
        if self.paused:
            raise FinTSDialogStateError("Cannot call finish_message() on a paused dialog")

        # Create signature(s) in reverse order: from inner to outer
        for auth_mech in reversed(self.auth_mechanisms):
            auth_mech.sign_commit(message)

        message += HNHBS1(message.segments[0].message_number)

        if self.enc_mechanism:
            self.enc_mechanism.encrypt(message)

        message.segments[0].message_size = len(message.render_bytes())