Skip to content

Commit

Permalink
Updating scripts
Browse files Browse the repository at this point in the history
Add the latest changes to the frontend API to the script.
Also removes the setup of the certificates, which is not needed for grpc.
  • Loading branch information
ineiti committed May 13, 2024
1 parent 28ad738 commit 46968e1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
11 changes: 10 additions & 1 deletion scripts/README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -13,6 +14,14 @@ The following scripts are available to configure and run D-voting locally. They
- `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_proxies.sh
```

The following script is only called by the other scripts:

- `local_login.sh` logs into the frontend and stores the cookie
3 changes: 2 additions & 1 deletion scripts/local_forms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
11 changes: 8 additions & 3 deletions scripts/local_votes.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
#!/bin/bash

if ! [[ "$1" && "$2" ]]; then
echo "Syntax is: $0 #votes FORMID"
if ! [[ "$1" ]]; 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
if [ -f $SCRIPT_DIR/formid.env ]; then
. $SCRIPT_DIR/formid.env
FORMID_ENV=$FORMID
fi

FORMID=${2:-$FORMID_ENV}
echo "Casting $1 votes to form $FORMID"
for i in $(seq $1); do
echo "Casting vote #$i"
Expand Down
7 changes: 0 additions & 7 deletions scripts/run_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 46968e1

Please sign in to comment.