summaryrefslogtreecommitdiff
path: root/contrib/taler-bank-manage-testing
blob: 7e4da516fe8a5d7700d8671483d8cdc4fe327c09 (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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/bin/sh
# This file is in the public domain
# Wrapper around 'taler-bank-manage' to first configure the required
# testing accounts before launching the bank properly.
#
# Takes 3 arguments:
# $1: the Nexus port (Sandbox port prepends 1 to it)
# $2: the database name
# $3: exchange base URL (used to specify the default exchange)
# $4: config file (needs patch to specify exchange's PAYTO_URI)

set -eu

if [ "$#" -ne 4 ];
then
    echo "illegal number of parameters.  \
Give: Nexus port number, SQLite file path, exchange base URL, config file path."
    exit 1
fi

# Must not terminate jobs here, as they are needed
# by the script _importing_ this one.  Those script
# will then manage the termination.
# trap cleanup EXIT

export LIBEUFIN_SANDBOX_DB_CONNECTION="jdbc:sqlite:$2"
# Create the default demobank.
libeufin-sandbox config --currency TESTKUDOS default
export LIBEUFIN_SANDBOX_ADMIN_PASSWORD=secret
libeufin-sandbox serve --port "1$1" \
  > libeufin-sandbox-stdout.log \
  2> libeufin-sandbox-stderr.log &
echo $! > libeufin-sandbox.pid
export LIBEUFIN_SANDBOX_URL="http://localhost:1$1/demobanks/default"
set +e
echo -n "Waiting for Sandbox.."
for n in `seq 1 50`; do
  echo -n "."
  sleep 1
  wget --timeout=1 \
    --tries=3 --waitretry=0 \
    -o /dev/null -O /dev/null \
    $LIBEUFIN_SANDBOX_URL
  break
done
sleep 1  #7293
echo OK

register_sandbox_account() {
    export LIBEUFIN_SANDBOX_USERNAME=$1
    export LIBEUFIN_SANDBOX_PASSWORD=$2
    libeufin-cli sandbox \
      demobank \
      register --name "$3"
    unset LIBEUFIN_SANDBOX_USERNAME
    unset LIBEUFIN_SANDBOX_PASSWORD
}
set -e
echo -n "Register the 'fortytwo' Sandbox user.."
register_sandbox_account fortytwo x "Forty Two"
echo OK
echo -n "Register the 'fortythree' Sandbox user.."
register_sandbox_account fortythree x "Forty Three"
echo OK
echo -n "Register 'exchange' Sandbox user.."
register_sandbox_account exchange x "Exchange Company"
echo OK
echo -n "Register 'tor' Sandbox user.."
register_sandbox_account tor x "Tor Project"
echo OK
echo -n "Register 'gnunet' Sandbox user.."
register_sandbox_account gnunet x "GNUnet"
echo OK
echo -n "Register 'tutorial' Sandbox user.."
register_sandbox_account tutorial x "Tutorial"
echo OK
echo -n "Register 'survey' Sandbox user.."
register_sandbox_account survey x "Survey"
echo OK
echo -n "Specify exchange's PAYTO_URI in the config ..."
export LIBEUFIN_SANDBOX_USERNAME=exchange
export LIBEUFIN_SANDBOX_PASSWORD=x
PAYTO=`libeufin-cli sandbox demobank info --bank-account exchange | jq --raw-output '.paytoUri'`
taler-config -c $4 -s exchange-account-1 -o PAYTO_URI -V $PAYTO
echo " OK"
echo -n "Setting this exchange as the bank's default ..."
EXCHANGE_PAYTO=`libeufin-cli sandbox demobank info --bank-account exchange | jq --raw-output '.paytoUri'`
libeufin-sandbox default-exchange "$3" "$EXCHANGE_PAYTO"
echo " OK"
# Prepare EBICS: create Ebics host and Exchange subscriber.
# Shortly becoming admin to setup Ebics.
export LIBEUFIN_SANDBOX_USERNAME=admin
export LIBEUFIN_SANDBOX_PASSWORD=secret
echo -n "Create EBICS host at Sandbox.."
libeufin-cli sandbox \
  --sandbox-url http://localhost:1$1 \
  ebicshost create --host-id talerebics
echo OK
echo -n "Create exchange EBICS subscriber at Sandbox.."
libeufin-cli sandbox \
  demobank new-ebicssubscriber --host-id talerebics \
  --user-id exchangeebics --partner-id talerpartner \
  --bank-account exchange # that's a username _and_ a bank account name
echo OK
unset LIBEUFIN_SANDBOX_USERNAME
unset LIBEUFIN_SANDBOX_PASSWORD
# Prepare Nexus, which is the side actually talking
# to the exchange.
export LIBEUFIN_NEXUS_DB_CONNECTION="jdbc:sqlite:$2"
# For convenience, username and password are
# identical to those used at the Sandbox.
echo -n Create exchange Nexus user..
libeufin-nexus superuser exchange --password x
echo OK
libeufin-nexus serve --port $1 \
  2> libeufin-nexus-stderr.log \
  > libeufin-nexus-stdout.log &
echo $! > libeufin-nexus.pid
export LIBEUFIN_NEXUS_URL=http://localhost:$1
echo -n Waiting for Nexus..
set +e
for n in `seq 1 50`; do
  echo -n "."
  sleep 1
  wget --timeout=1 \
    --tries=3 --waitretry=0 \
    -o /dev/null -O /dev/null \
    $LIBEUFIN_NEXUS_URL
  break
done
sleep 1 #7293
set -e
echo OK
export LIBEUFIN_NEXUS_USERNAME=exchange
export LIBEUFIN_NEXUS_PASSWORD=x
echo -n Creating a EBICS connection at Nexus..
libeufin-cli connections new-ebics-connection \
  --ebics-url "http://localhost:1$1/ebicsweb" \
  --host-id talerebics \
  --partner-id talerpartner \
  --ebics-user-id exchangeebics \
  talerconn
echo OK
echo -n Setup EBICS keying..
libeufin-cli connections connect talerconn > /dev/null
echo OK
echo -n Download bank account name from Sandbox..
libeufin-cli connections download-bank-accounts talerconn
echo OK
echo -n Importing bank account info into Nexus..
libeufin-cli connections import-bank-account \
  --offered-account-id exchange \
  --nexus-bank-account-id exchange-nexus \
  talerconn
echo OK
echo -n Setup payments submission task..
# Tries every second.
libeufin-cli accounts task-schedule \
  --task-type submit \
  --task-name exchange-payments \
  --task-cronspec "* * *" \
  exchange-nexus
echo OK
# Tries every second.  Ask C52
echo -n Setup history fetch task..
libeufin-cli accounts task-schedule \
  --task-type fetch \
  --task-name exchange-history \
  --task-cronspec "* * *" \
  --task-param-level report \
  --task-param-range-type latest \
  exchange-nexus
echo OK
# TBD: create Taler facade.
echo -n Create the Taler facade at Nexus..
libeufin-cli facades \
  new-taler-wire-gateway-facade \
  --currency TESTKUDOS --facade-name test-facade \
  talerconn exchange-nexus
echo OK
# Facade schema: http://localhost:$1/facades/test-facade/taler-wire-gateway/