summaryrefslogtreecommitdiff
path: root/contrib/taler-nexus-prepare
blob: 112891f3976b4f383df866d9237e9feca201f642 (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
#!/usr/bin/env python3
# This file is in the public domain.

from requests import get, post
from subprocess import call
import base64

USERNAME="Exchange"
USER_AUTHORIZATION_HEADER = "basic {}".format(
    base64.b64encode(b"Exchange:x").decode("utf-8")
)

def assertResponse(response):
    if response.status_code != 200:
        print("Test failed on URL: {}".format(response.url))
        # stdout/stderr from both services is A LOT of text.
        # Confusing to dump all that to console.
        print("Check nexus.log and sandbox.log, probably under /tmp")
        exit(1)
    # Allows for finer grained checks.
    return response

# Create a nexus (super-) user
call(["nexus", "superuser", "Exchange", "--password", "x"])
# Create a loopback bank connection.
assertResponse(
    post(
        "http://localhost:5001/bank-connections",
        json=dict(
            name="my-loopback",
            source="new",
            type="loopback",
            data=dict(
                bankAccount="my-bank-account"
            )
        ),
        headers=dict(Authorization=USER_AUTHORIZATION_HEADER),
    )
)
# Create a facade
assertResponse(
    post(
        "http://localhost:5001/facades",
        json=dict(
            name="my-facade",
            type="taler-wire-gateway",
            creator=USERNAME,
            config=dict(
                bankAccount="my-bank-account",
                bankConnection="my-local",
                reserveTransferLevel="UNUSED",
                intervalIncremental="UNUSED"
            )
        ),
        headers=dict(Authorization=USER_AUTHORIZATION_HEADER),
    )
)