summaryrefslogtreecommitdiff
path: root/nlnet/task3/start.sh
blob: a6c3ab2bf5cf4c1bd5cf8d76d451d301cbf94fe1 (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
#!/bin/bash

set -eu

function finish() {
  exit 1       
}

trap finish SIGINT

# Expected arguments are:
#
# $1 := EBICS user ID
# $2 := EBICS partner ID
# $3 := IBAN as assigned by the PostFinance test platform.

# Suggested invocation via 'docker':
#
# docker run -it $IMAGE_TAG $EBICS_USER_ID $EBICS_PARTNER_ID
service postgresql start
sudo -u postgres createuser -s root
createdb libeufincheck
# This script conducts the key exchange with the bank
# and guides the user to download and upload docuemts
# to the bank.  It pauses the execution to let the user
# check and set the Web UI as a double-check mean.

# Setting the EBICS keys.  It'll place them in the container's
# /tmp/pofi.json, where Kotlin expects them.
export EBICS_USER_ID=$1
export EBICS_PARTNER_ID=$2
/keys.sh

# If the keys are ready, it proceeds to invoke the uploading
# and downloading logic.

# Upload test.

# The test runner will upload one pain.001 document to
# the bank.  Thereafter, the user can check the existtence
# of such document via the bank Web UI.  Moreover, the user
# is offered the possibility to specify a custom payment
# subject.

PAIN_SALT=$RANDOM
echo
echo "Now preparing the pain.001 to upload to the bank via LibEuFin."
echo "This document instructs the bank to send money to an arbitrary"
echo "IBAN by debiting the test platform bank account."
echo "The outgoing payment defaults to have this subject: $PAIN_SALT".
echo "Please enter any value in this prompt, in case you want to"
echo -n "change the default subject: "
read MAYBE_PAIN_SALT

if ! test "x" = "x$MAYBE_PAIN_SALT"; then
  PAIN_SALT=$MAYBE_PAIN_SALT
fi

echo "The pain.001 will have this subject: '$PAIN_SALT', now calling"
echo "LibEuFin to upload it via EBICS.."
cd /libeufin; ./gradlew -q :nexus:pofi --args="upload --subject \"$PAIN_SALT\""; cd -
echo DONE

echo
echo "Please check the bank Web UI to find the pain.001 document"
echo "whose subject is '$PAIN_SALT'.  If that is found, then LibEuFin"
echo "has successfully uploaded it.  In the next step, LibEuFin"
echo "will download the new banking records.  If '$PAIN_SALT' is found"
echo "in the logs, then it succeeded.  Press Enter to continue.. "
read -s

# Download test.

# The test runnner proceeds with downloading the banking
# records that witness the payment that was uploaded shortly
# ago.  If the logs show the payment subject that belongs
# to such payment, then the download went through.
cd /libeufin; ./gradlew -q :nexus:pofi --args="download"; cd -