[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] 03/06: redux - testing country selection
From: |
gnunet |
Subject: |
[taler-anastasis] 03/06: redux - testing country selection |
Date: |
Tue, 10 Nov 2020 13:44:50 +0100 |
This is an automated email from the git hooks/post-receive script.
dennis-neufeld pushed a commit to branch master
in repository anastasis.
commit c9fa610d4512e81b76f212e90294f9b1058afa24
Author: Dennis Neufeld <dennis.neufeld@students.bfh.ch>
AuthorDate: Tue Nov 10 11:42:05 2020 +0100
redux - testing country selection
---
src/cli/Makefile.am | 8 +-
...asis_cli.conf => test_anastasis_reducer_1.conf} | 13 +-
...asis_cli.conf => test_anastasis_reducer_2.conf} | 11 +-
...asis_cli.conf => test_anastasis_reducer_3.conf} | 11 +-
src/cli/test_anastasis_reducer_select_country.sh | 161 +++++++++++++++++++++
5 files changed, 189 insertions(+), 15 deletions(-)
diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am
index fb6ef9c..dd22cfa 100644
--- a/src/cli/Makefile.am
+++ b/src/cli/Makefile.am
@@ -12,7 +12,8 @@ endif
check_SCRIPTS = \
test_reducer.sh \
test_anastasis_reducer_initialize_state.sh \
- test_anastasis_reducer_select_continent.sh
+ test_anastasis_reducer_select_continent.sh \
+ test_anastasis_reducer_select_country.sh
AM_TESTS_ENVIRONMENT=export
ANASTASIS_PREFIX=$${ANASTASIS_PREFIX:-@libdir@};export
PATH=$${ANASTASIS_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset
XDG_CONFIG_HOME;
@@ -23,7 +24,10 @@ TESTS = \
EXTRA_DIST = \
$(check_SCRIPTS) \
test_reducer.conf \
- test_anastasis_reducer.conf
+ test_anastasis_reducer.conf \
+ test_anastasis_reducer_1.conf \
+ test_anastasis_reducer_2.conf \
+ test_anastasis_reducer_3.conf
anastasis_reducer_SOURCES = \
anastasis-cli-redux.c
diff --git a/src/cli/test_anastasis_cli.conf
b/src/cli/test_anastasis_reducer_1.conf
similarity index 97%
copy from src/cli/test_anastasis_cli.conf
copy to src/cli/test_anastasis_reducer_1.conf
index 88891f3..30fba38 100644
--- a/src/cli/test_anastasis_cli.conf
+++ b/src/cli/test_anastasis_reducer_1.conf
@@ -1,10 +1,10 @@
# This file is in the public domain.
#
[PATHS]
-# Persistent data storage for the testcase
+# Persistant data storage for the testcase
TALER_TEST_HOME = test_anastasis_api_home/
-# Persistent data storage
+# Persistant data storage
TALER_DATA_HOME = $TALER_TEST_HOME/.local/share/taler/
# Configuration files
@@ -29,7 +29,7 @@ HTTP_PORT = 8082
##########################################
[anastasis]
-PORT = 8086
+PORT = 8087
DB = postgres
@@ -41,13 +41,16 @@ PAYMENT_BACKEND_URL = http://localhost:8080/
# Annual fee we charge.
#ANNUAL_FEE = EUR:4.99
-ANNUAL_FEE = TESTKUDOS:4.99
+ANNUAL_FEE = TESTKUDOS:1.99
#ANNUAL_FEE = EUR:0
# Cost of authentication by question
#QUESTION_COST = EUR:0
QUESTION_COST = TESTKUDOS:0
+# Insurance
+INSURANCE = TESTKUDOS:1.0
+
# Upload limit
UPLOAD_LIMIT_MB = 1
@@ -229,7 +232,7 @@ ENABLE_CREDIT = YES
# wire fees
[fees-x-taler-bank]
-# Fees for the foreseeable future...
+# Fees for the forseeable future...
# If you see this after 2018, update to match the next 10 years...
WIRE-FEE-2018 = TESTKUDOS:0.01
WIRE-FEE-2019 = TESTKUDOS:0.01
diff --git a/src/cli/test_anastasis_cli.conf
b/src/cli/test_anastasis_reducer_2.conf
similarity index 98%
copy from src/cli/test_anastasis_cli.conf
copy to src/cli/test_anastasis_reducer_2.conf
index 88891f3..173fd4b 100644
--- a/src/cli/test_anastasis_cli.conf
+++ b/src/cli/test_anastasis_reducer_2.conf
@@ -1,10 +1,10 @@
# This file is in the public domain.
#
[PATHS]
-# Persistent data storage for the testcase
+# Persistant data storage for the testcase
TALER_TEST_HOME = test_anastasis_api_home/
-# Persistent data storage
+# Persistant data storage
TALER_DATA_HOME = $TALER_TEST_HOME/.local/share/taler/
# Configuration files
@@ -29,7 +29,7 @@ HTTP_PORT = 8082
##########################################
[anastasis]
-PORT = 8086
+PORT = 8088
DB = postgres
@@ -48,6 +48,9 @@ ANNUAL_FEE = TESTKUDOS:4.99
#QUESTION_COST = EUR:0
QUESTION_COST = TESTKUDOS:0
+# Insurance
+INSURANCE = TESTKUDOS:1.0
+
# Upload limit
UPLOAD_LIMIT_MB = 1
@@ -229,7 +232,7 @@ ENABLE_CREDIT = YES
# wire fees
[fees-x-taler-bank]
-# Fees for the foreseeable future...
+# Fees for the forseeable future...
# If you see this after 2018, update to match the next 10 years...
WIRE-FEE-2018 = TESTKUDOS:0.01
WIRE-FEE-2019 = TESTKUDOS:0.01
diff --git a/src/cli/test_anastasis_cli.conf
b/src/cli/test_anastasis_reducer_3.conf
similarity index 98%
rename from src/cli/test_anastasis_cli.conf
rename to src/cli/test_anastasis_reducer_3.conf
index 88891f3..9a82d0c 100644
--- a/src/cli/test_anastasis_cli.conf
+++ b/src/cli/test_anastasis_reducer_3.conf
@@ -1,10 +1,10 @@
# This file is in the public domain.
#
[PATHS]
-# Persistent data storage for the testcase
+# Persistant data storage for the testcase
TALER_TEST_HOME = test_anastasis_api_home/
-# Persistent data storage
+# Persistant data storage
TALER_DATA_HOME = $TALER_TEST_HOME/.local/share/taler/
# Configuration files
@@ -29,7 +29,7 @@ HTTP_PORT = 8082
##########################################
[anastasis]
-PORT = 8086
+PORT = 8089
DB = postgres
@@ -48,6 +48,9 @@ ANNUAL_FEE = TESTKUDOS:4.99
#QUESTION_COST = EUR:0
QUESTION_COST = TESTKUDOS:0
+# Insurance
+INSURANCE = TESTKUDOS:1.0
+
# Upload limit
UPLOAD_LIMIT_MB = 1
@@ -229,7 +232,7 @@ ENABLE_CREDIT = YES
# wire fees
[fees-x-taler-bank]
-# Fees for the foreseeable future...
+# Fees for the forseeable future...
# If you see this after 2018, update to match the next 10 years...
WIRE-FEE-2018 = TESTKUDOS:0.01
WIRE-FEE-2019 = TESTKUDOS:0.01
diff --git a/src/cli/test_anastasis_reducer_select_country.sh
b/src/cli/test_anastasis_reducer_select_country.sh
new file mode 100755
index 0000000..7091a87
--- /dev/null
+++ b/src/cli/test_anastasis_reducer_select_country.sh
@@ -0,0 +1,161 @@
+#!/bin/bash
+
+set -eu
+
+# Exit, with status code "skip" (no 'real' failure)
+function exit_skip() {
+ echo $1
+ exit 77
+}
+
+# Exit, with error message (hard failure)
+function exit_fail() {
+ echo $1
+ exit 1
+}
+
+# Cleanup to run whenever we exit
+function cleanup()
+{
+ for n in `jobs -p`
+ do
+ kill $n 2> /dev/null || true
+ done
+ rm -f $SFILE $TFILE $CONF_1 $CONF_2 $CONF_3 $CONF_4
+ wait
+}
+
+# Install cleanup handler (except for kill -9)
+CONF_1=`mktemp test_reducerXXXXXX_1.conf`
+CONF_2=`mktemp test_reducerXXXXXX_2.conf`
+CONF_3=`mktemp test_reducerXXXXXX_3.conf`
+CONF_4=`mktemp test_reducerXXXXXX_4.conf`
+SFILE=`mktemp test_reducer_stateXXXXXX`
+TFILE=`mktemp test_reducer_stateXXXXXX`
+
+trap cleanup EXIT
+
+# Check we can actually run
+echo -n "Testing for jq"
+jq -h > /dev/null || exit_skip "jq required"
+echo " FOUND"
+
+echo -n "Testing for anastasis-httpd"
+anastasis-httpd -h >/dev/null </dev/null || exit_skip " MISSING"
+echo " FOUND"
+
+
+# Name of the Postgres database we will use for the script.
+# Will be dropped, do NOT use anything that might be used
+# elsewhere
+TARGET_DB=anastasischeck
+
+# Configuration file will be edited, so we create one
+# from the template.
+cp test_anastasis_reducer.conf $CONF_1
+cp test_anastasis_reducer_1.conf $CONF_2
+cp test_anastasis_reducer_2.conf $CONF_3
+cp test_anastasis_reducer_3.conf $CONF_4
+
+# reset database
+dropdb $TARGET_DB >/dev/null 2>/dev/null || true
+createdb $TARGET_DB || exit_skip "Could not create database $TARGET_DB"
+
+# Launch services
+echo "Launching anastasis service"
+anastasis-httpd -c $CONF_1 2> anastasis-httpd_1.log &
+anastasis-httpd -c $CONF_2 2> anastasis-httpd_2.log &
+anastasis-httpd -c $CONF_3 2> anastasis-httpd_3.log &
+anastasis-httpd -c $CONF_4 2> anastasis-httpd_4.log &
+
+# Wait for anastasis service to be available
+for n in `seq 1 50`
+do
+ echo -n "."
+ sleep 0.1
+ OK=0
+ # anastasis_01
+ wget http://localhost:8086/ -o /dev/null -O /dev/null >/dev/null ||
continue
+ # anastasis_02
+ wget http://localhost:8087/ -o /dev/null -O /dev/null >/dev/null ||
continue
+ # anastasis_03
+ wget http://localhost:8088/ -o /dev/null -O /dev/null >/dev/null ||
continue
+ # anastasis_04
+ wget http://localhost:8089/ -o /dev/null -O /dev/null >/dev/null ||
continue
+ OK=1
+ break
+done
+
+if [ 1 != $OK ]
+then
+ exit_skip "Failed to launch anastasis services"
+fi
+
+echo " ANASTASIS SETUP DONE"
+echo " "
+echo " "
+echo " "
+echo "Beginning with actual reducer test"
+
+# Test country selection in a backup state
+echo " "
+echo "Test country selection in a backup state"
+./anastasis-reducer -b $SFILE
+./anastasis-reducer -a '{"continent": "Europe"}' select_continent $SFILE $TFILE
+./anastasis-reducer -a '{"country": "Switzerland", "country_code": "ch",
"currency":"TESTKUDOS"}' select_country $TFILE $SFILE
+
+STATE=`jq -r -e .backup_state < $SFILE`
+if test "$STATE" != "USER_ATTRIBUTES_COLLECTING"
+then
+ exit_fail "Expected new state to be USER_ATTRIBUTES_COLLECTING, got $STATE"
+fi
+
+SELECTED_COUNTRY=`jq -r -e .selected_country < $SFILE`
+if test "$SELECTED_COUNTRY" != "ch"
+then
+ exit_fail "Expected selected country to be ch, got $SELECTED_COUNTRY"
+fi
+
+SELECTED_CURRENCY=`jq -r -e .currency < $SFILE`
+if test "$SELECTED_CURRENCY" != "TESTKUDOS"
+then
+ exit_fail "Expected selected currency to be TESTKUDOS, got
$SELECTED_CURRENCY"
+fi
+
+REQ_ATTRIBUTES=`jq -r -e .required_attributes < $SFILE`
+if test "$REQ_ATTRIBUTES" == NULL
+then
+ exit_fail "Expected required attributes array not to be NULL"
+fi
+
+# Test country selection in a recovery state
+echo "Test country selection in a recovery state"
+./anastasis-reducer -r $SFILE
+./anastasis-reducer -a '{"continent": "Europe"}' select_continent $SFILE $TFILE
+./anastasis-reducer -a '{"country": "Switzerland", "country_code": "ch",
"currency":"TESTKUDOS"}' select_country $TFILE $SFILE
+
+STATE=`jq -r -e .recovery_state < $SFILE`
+if test "$STATE" != "USER_ATTRIBUTES_COLLECTING"
+then
+ exit_fail "Expected new state to be USER_ATTRIBUTES_COLLECTING, got $STATE"
+fi
+
+SELECTED_COUNTRY=`jq -r -e .selected_country < $SFILE`
+if test "$SELECTED_COUNTRY" != "ch"
+then
+ exit_fail "Expected selected country to be ch, got $SELECTED_COUNTRY"
+fi
+
+SELECTED_CURRENCY=`jq -r -e .currency < $SFILE`
+if test "$SELECTED_CURRENCY" != "TESTKUDOS"
+then
+ exit_fail "Expected selected currency to be TESTKUDOS, got
$SELECTED_CURRENCY"
+fi
+
+REQ_ATTRIBUTES=`jq -r -e .required_attributes < $SFILE`
+if test "$REQ_ATTRIBUTES" == NULL
+then
+ exit_fail "Expected required attributes array not to be NULL"
+fi
+
+exit 0
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-anastasis] branch master updated (4ed7e40 -> 5f18ee4), gnunet, 2020/11/10
- [taler-anastasis] 01/06: fix return value from main() when run with -h/-v, gnunet, 2020/11/10
- [taler-anastasis] 02/06: redux - test continent selection, gnunet, 2020/11/10
- [taler-anastasis] 03/06: redux - testing country selection,
gnunet <=
- [taler-anastasis] 06/06: Merge branch 'master' of ssh://git.taler.net/anastasis, gnunet, 2020/11/10
- [taler-anastasis] 04/06: testing user attributes collection, gnunet, 2020/11/10
- [taler-anastasis] 05/06: fix ahv validation, gnunet, 2020/11/10