summaryrefslogtreecommitdiff
path: root/integration-tests/test-ebics.py
blob: 5c5fbbbb927562ea63edbdc0473ff7a74f2e78d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env python3

from requests import post, get

# Steps implemented in this test.
#
# 1 Prepare the Sandbox to run the test.
#  -> Make a EBICS host, and make a EBICS subscriber
#     for the test runner.
#
# 2 Prepare the Nexus to run the test.
#  -> Make a Nexus user, and make a EBICS transport
#     entity associated with that user.
#
# 3 Upload keys from Nexus to the Bank (INI & HIA)
# 4 Download key from the Bank (HPB) to the Nexus
#
# 5 Request history from the Nexus to the Bank (C53).
# 6 Verify that history is empty.
# 7 Issue a payment from Nexus (Prepare & trigger CCT)
# 8 Request history again, from Nexus to Bank.
# 9 Verify that previous payment shows up.


# Nexus user details
USERNAME="person"

# EBICS details
EBICS_URL="http://localhost:5000/ebicsweb"
HOST_ID="HOST01"
PARTNER_ID="PARTNER1"
USER_ID="USER1"
EBICS_VERSION = "H004"

#0 Prepare Sandbox (make Ebics host & one subscriber)
resp = post(
    "http://localhost:5000/admin/ebics-host",
    json=dict(
	hostID=HOST_ID,
	ebicsVersion=EBICS_VERSION
    )
)

assert(resp.status_code == 200)

resp = post(
    "http://localhost:5000/admin/ebics-subscriber",
    json=dict(
        hostID=HOST_ID,
	partnerID=PARTNER_ID,
	userID=USER_ID
    )
)

assert(resp.status_code == 200)

#1 Create a Nexus user

resp = post(
    "http://localhost:5001/users/{}".format(USERNAME),
    json=dict(
	password="secret"
    )
)

assert(resp.status_code == 200)

#2 Create a EBICS user
resp = post(
    "http://localhost:5001/ebics/subscribers/{}".format(USERNAME),
    json=dict(
	ebicsURL=EBICS_URL,
	hostID=HOST_ID,
	partnerID=PARTNER_ID,
	userID=USER_ID
    )
)

assert(resp.status_code == 200)

#3 Upload keys to the bank INI & HIA
resp = post(
    "http://localhost:5001/ebics/subscribers/{}/sendINI".format(USERNAME),
    json=dict()
)

assert(resp.status_code == 200)

resp = post(
    "http://localhost:5001/ebics/subscribers/{}/sendHIA".format(USERNAME),
    json=dict()
)

assert(resp.status_code == 200)

#4 Download keys from the bank HPB
resp = post(
    "http://localhost:5001/ebics/subscribers/{}/sync".format(USERNAME),
    json=dict()
)

assert(resp.status_code == 200)

#5 Request history via EBICS
resp = post(
    "http://localhost:5001/ebics/subscribers/{}/collect-transactions-c53".format(USERNAME),
    json=dict()
)

assert(resp.status_code == 200)

# FIXME: assert that history is EMPTY at this point!
resp = get(
    "http://localhost:5001/users/{}/history".format(USERNAME)
)

assert(
    resp.status_code == 200 and \
    len(resp.json().get("payments")) == 0
)

#6 Prepare a payment (via pure Nexus service)
#7 Execute such payment via EBICS
#8 Request history again via EBICS