From b56fbc625de86c93bf07065164a6221fa7aa2651 Mon Sep 17 00:00:00 2001 From: Linus Gasser Date: Mon, 13 May 2024 15:36:28 +0200 Subject: [PATCH] Updating scripts Add the latest changes to the frontend API to the script. Also removes the setup of the certificates, which is not needed for grpc. --- scripts/README.md | 13 ++++++++++--- scripts/local_forms.sh | 3 ++- scripts/local_votes.sh | 20 -------------------- scripts/run_local.sh | 7 ------- 4 files changed, 12 insertions(+), 31 deletions(-) delete mode 100755 scripts/local_votes.sh diff --git a/scripts/README.md b/scripts/README.md index 80ef9ba27..3ffeb222e 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -1,6 +1,7 @@ # Scripts for running D-voting locally -The following scripts are available to configure and run D-voting locally. They should be called in this order: +The following scripts are available to configure and run D-voting locally. +They should be called in this order: - `run_local.sh` - sets up a complete system with 4 nodes, the db, the authentication-server, and the frontend. @@ -10,8 +11,14 @@ The following scripts are available to configure and run D-voting locally. They For debugging Dela, you still need to re-run everything. - `local_proxies.sh` needs to be run once after the `run_local.sh` script - `local_forms.sh` creates a new form and prints its ID -- `local_votes.sh` casts the given number of votes. THE ENCRYPTION IS WRONG AND WILL NOT WORK. But it allows to test - missing votes + +Every script must be called from the root of the repository: + +```bash +./scripts/run_local.sh +./scripts/local_proxies.sh +./scripts/local_forms.sh +``` The following script is only called by the other scripts: diff --git a/scripts/local_forms.sh b/scripts/local_forms.sh index df8e98b5e..9388bb912 100755 --- a/scripts/local_forms.sh +++ b/scripts/local_forms.sh @@ -4,7 +4,8 @@ SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) . "$SCRIPT_DIR/local_login.sh" echo "add form" -RESP=$(curl -sk "$FRONTEND_URL/api/evoting/forms" -X POST -H 'Content-Type: application/json' -b cookies.txt --data-raw '{"Title":{"En":"Something","Fr":"","De":""},"Scaffold":[{"ID":"99hYV4uy","Title":{"En":"More stuff","Fr":"","De":""},"Order":["0c7RSRKs"],"Ranks":[],"Selects":[{"ID":"0c7RSRKs","Title":{"En":"Choose","Fr":"","De":""},"MaxN":3,"MinN":1,"Choices":[{"Choice":"{\"en\":\"First\"}","URL":""},{"Choice":"{\"en\":\"Second\"}","URL":""},{"Choice":"{\"en\":\"Third\"}","URL":""}],"Hint":{"En":"","Fr":"","De":""}}],"Texts":[],"Subjects":[]}]}') +FORMJSON='{"Configuration":{"Title":{"En":"title","Fr":"","De":"","URL":""},"Scaffold":[{"ID":"ozCI7gKv","Title":{"En":"subtitle","Fr":"","De":"","URL":""},"Order":["nVjQ0jMK"],"Ranks":[],"Selects":[{"ID":"nVjQ0jMK","Title":{"En":"vote","Fr":"","De":"","URL":""},"MaxN":3,"MinN":1,"Choices":[{"Choice":"{\"en\":\"one\"}","URL":""},{"Choice":"{\"en\":\"two\"}","URL":""},{"Choice":"{\"en\":\"three\"}","URL":""}],"Hint":{"En":"","Fr":"","De":""}}],"Texts":[],"Subjects":[]}],"AdditionalInfo":""}}' +RESP=$(curl -sk "$FRONTEND_URL/api/evoting/forms" -X POST -H 'Content-Type: application/json' -b cookies.txt --data-raw "$FORMJSON") FORMID=$(echo "$RESP" | jq -r .FormID) echo "FORMID=$FORMID" > "$SCRIPT_DIR/formid.env" diff --git a/scripts/local_votes.sh b/scripts/local_votes.sh deleted file mode 100755 index c48a90d03..000000000 --- a/scripts/local_votes.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -if ! [[ "$1" && "$2" ]]; then - echo "Syntax is: $0 #votes FORMID" - exit 1 -fi - -SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) -. "$SCRIPT_DIR/local_login.sh" - -FORMID=$2 -echo "Casting $1 votes to form $FORMID" -for i in $(seq $1); do - echo "Casting vote #$i" - curl -sk "$FRONTEND_URL/api/evoting/forms/$FORMID/vote" -X POST -H 'Content-Type: Application/json' \ - -H "Origin: $FRONTEND_URL" -b cookies.txt \ - --data-raw '{"Ballot":[{"K":[54,152,33,11,201,233,212,157,204,176,136,138,54,213,239,198,79,55,71,26,91,244,98,215,208,239,48,253,195,53,192,94],"C":[105,121,87,164,68,242,166,194,222,179,253,231,213,63,34,66,212,41,214,175,178,83,229,156,255,38,55,234,168,222,81,185]}],"UserID":null}' \ - >/dev/null - sleep 1 -done diff --git a/scripts/run_local.sh b/scripts/run_local.sh index c185e5e48..0154cb89f 100755 --- a/scripts/run_local.sh +++ b/scripts/run_local.sh @@ -94,13 +94,6 @@ function init_nodes() { function init_dela() { echo "Initializing dela" - echo " Share the certificate" - for n in $(seq 2 4); do - TOKEN_ARGS=$(dvoting --config ./nodes/node-1 minogrpc token) - NODEDIR=./nodes/node-$n - dvoting --config $NODEDIR minogrpc join --address grpc://localhost:2000 $TOKEN_ARGS - done - echo " Create a new chain with the nodes" for n in $(seq 4); do NODEDIR=./nodes/node-$n