-
Notifications
You must be signed in to change notification settings - Fork 0
/
manual
executable file
·42 lines (35 loc) · 1.01 KB
/
manual
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
#!/bin/bash
# Helper scripts to manually invoke running services.
SIGNING="4000"
ANALYTICS="4001"
# Expose services on the host machine (in background jobs).
kubectl port-forward service/signing $SIGNING:80 &
kubectl port-forward service/analytics $ANALYTICS:80 &
# Wait for port forwarding to finish setting up.
sleep 0.5
# Sign a payload using the signing service.
PAYLOAD=$(cat <<EOF
{
"payload": {
"question": {"id": "q123"},
"answers": [
{"id": "a123"},
{"id": "a456"},
{"id": "a789"}
]
}
}
EOF
)
TOKEN=$(curl -s -X "POST" -H "Content-Type: application/json" -d "$PAYLOAD" localhost:$SIGNING/sign | jq -r .token)
# Submit the token and a choice to the analytics service.
PAYLOAD=$(cat <<EOF
{
"token": "$TOKEN",
"choice": "a000"
}
EOF
)
curl -s -X "POST" -H "Content-Type: application/json" -d "$PAYLOAD" localhost:$ANALYTICS/submit
# Cleanup background jobs before exiting.
kill $(jobs -p)