summaryrefslogtreecommitdiff
path: root/nlnet/task3/start.sh
diff options
context:
space:
mode:
Diffstat (limited to 'nlnet/task3/start.sh')
-rwxr-xr-xnlnet/task3/start.sh79
1 files changed, 79 insertions, 0 deletions
diff --git a/nlnet/task3/start.sh b/nlnet/task3/start.sh
new file mode 100755
index 0000000..2f8b2a2
--- /dev/null
+++ b/nlnet/task3/start.sh
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+set -eu
+
+function finish() {
+ exit 1
+}
+
+trap finish SIGINT
+
+# Expected arguments are:
+#
+# $1 := EBICS user ID
+# $2 := EBICS partner ID (a.k.a. customer 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.
+
+MY_IBAN=$3
+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="--my-iban \"$MY_IBAN\" 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="--my-iban \"$MY_IBAN\" download"; cd -