]> git.ipfire.org Git - thirdparty/python-fints.git/commitdiff
Test 2step transfer
authorHenryk Plötz <henryk@ploetzli.ch>
Mon, 10 Sep 2018 16:39:58 +0000 (18:39 +0200)
committerRaphael Michel <mail@raphaelmichel.de>
Mon, 3 Dec 2018 18:34:29 +0000 (19:34 +0100)
tests/conftest.py
tests/test_client.py

index 2894b4eb0362dba141d77a9745b196578389ded4..509a524907d0389d515e78168f723cd8c5c9e578 100644 (file)
@@ -78,6 +78,31 @@ def fints_server():
                 if memomatch and recvrmatch and amountmatch:
                     if memomatch.group(1).endswith('1step'):
                         result.append("HIRMS::2:{}+0010::Transfer {} to {} re {}'".format(segno, amountmatch.group(1), recvrmatch.group(1), repr(memomatch.group(1)).replace("'", "?'")).encode('iso-8859-1'))
+                    else:
+                        hktan = re.search(rb"'HKTAN:(\d+):(\d+)", message)
+                        if hktan:
+                            ref = uuid.uuid4().hex
+                            datadict.setdefault('pending', {})[ref] = {
+                                'seg': segno,
+                                'pain': pain,
+                                'memo': memomatch.group(1),
+                                'recv': recvrmatch.group(1),
+                                'amount': amountmatch.group(1),
+                            }
+                            result.append("HIRMS::2:{}+0030::Auftragsfreigabe erforderlich'".format(hktan.group(1).decode('us-ascii')).encode('us-ascii'))
+                            result.append("HITAN::{}:{}+2++{}+Geben Sie die TAN an'".format(hktan.group(2).decode('us-ascii'), hktan.group(1).decode('us-ascii'), ref).encode('us-ascii'))
+
+            hktan = re.search(rb"'HKTAN:(\d+):(\d+)\+2\+\+\+\+([^+]+)\+", message)
+            if hktan:
+                segno = hktan.group(1).decode('us-ascii')
+                tanver = hktan.group(2).decode('us-ascii')
+                ref = hktan.group(3).decode('us-ascii')
+
+                task = datadict.setdefault('pending', {}).get(ref, None)
+                if task:
+                    result.append("HIRMS::2:{}+0010::Transfer {} to {} re {}'".format(segno, task['amount'], task['recv'], repr(task['memo']).replace("'", "?'")).encode('iso-8859-1'))
+
+                datadict['pending'].pop(ref, None)
 
             return b"".join(result)
 
index d79102765ec2bc5752377a366dd95be360a183db..8fd1f48ef4ab6c261baef4bba30d688fd89e1b65 100644 (file)
@@ -84,3 +84,22 @@ def test_transfer_1step_regression(fints_client):
 
         assert isinstance(a, TransactionResponse)
         assert a.responses[0].text == "Transfer 1.23 to DE111234567800000002 re 'Test transfer 1step'"
+
+def test_transfer_2step(fints_client):
+    with fints_client:
+        accounts = fints_client.get_sepa_accounts()
+        a = fints_client.simple_sepa_transfer(
+            accounts[0],
+            'DE111234567800000002',
+            'GENODE00TES',
+            'Test Receiver',
+            Decimal('2.34'),
+            'Test Sender',
+            'Test transfer 2step'
+        )
+
+        assert isinstance(a, NeedTANResponse)
+
+        b = fints_client.send_tan(a, '123456')
+        assert b.status == ResponseStatus.SUCCESS
+        assert b.responses[0].text == "Transfer 2.34 to DE111234567800000002 re 'Test transfer 2step'"