forked from muze-nl/federated-timesheets-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-timeld.sh
executable file
·86 lines (75 loc) · 2.89 KB
/
test-timeld.sh
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
docker-compose --compatibility -p federated-timesheets-tests up -d
echo "--- Initializing timeld"
export TIMELD_PASSWORD=`docker exec -it federated-timesheets-tests_timeld-cli_1 "/usr/local/bin/node" "/timeld/init.mjs"`
docker exec -it federated-timesheets-tests_timeld-cli_1 "/usr/local/bin/node" "/timeld/report.mjs"
echo "--- Extracted key: $TIMELD_PASSWORD"
echo "--- Installing tikiwiki"
docker exec -u www-data -it federated-timesheets-tests_tikiwiki_1 "/bin/sh" "/usr/local/bin/tiki-init.sh"
echo "--- Setting up environment for prejournal"
cp prejournal/testnet.env testnet.env
docker cp testnet.env federated-timesheets-tests_prejournal_1:/app/.env
curl -d'["alice","alice123"]' http://localhost:8280/v1/register
echo "--- Connecting timeld to prejournal and tiki"
docker exec -it federated-timesheets-tests_timeld-cli_1 "/usr/local/bin/node" "/timeld/connect-prejournal.mjs"
docker exec -it federated-timesheets-tests_timeld-cli_1 "/usr/local/bin/node" "/timeld/connect-tiki.mjs"
echo "--- Entering timesheet entry in timeld"
docker exec -it federated-timesheets-tests_timeld-cli_1 "/usr/local/bin/node" "/timeld/timesheet-entry.mjs"
echo "--- Fetching report from prejournal"
curl -d'["0"]' http://alice:alice123@localhost:8280/v1/print-timesheet-json > prejournal-report.json
echo "--- Fetching report from tikiwiki"
curl -H "Authorization: Bearer testnet-supersecret-token" http://localhost:8180/api/trackers/1 > tiki-report.json
PREJOURNAL_VALIDATED=`grep -c "This is the description to check for" prejournal-report.json`
TIKI_VALIDATED=`grep -c "This is the description to check for" tiki-report.json`
if [ $PREJOURNAL_VALIDATED == '1' ]
then
echo
echo "----------------------------------"
echo "Federation to prejournal validated"
echo "----------------------------------"
cat prejournal-report.json
echo "----------------------------------"
else
echo
echo "-------------------------------"
echo "Federation to prejournal failed"
echo "-------------------------------"
cat prejournal-report.json
echo "-------------------------------"
fi
if [ $TIKI_VALIDATED == '1' ]
then
echo
echo "--------------------------------"
echo "Federation to tikiwiki validated"
echo "--------------------------------"
cat tiki-report.json
echo "--------------------------------"
else
echo
echo "------------------------------"
echo "Federation to tikiwiki failed"
echo "------------------------------"
cat tiki-report.json
echo "------------------------------"
fi
rm testnet.env
rm prejournal-report.json
rm tiki-report.json
docker-compose down
if [ $PREJOURNAL_VALIDATED == '1' ] && [ $TIKI_VALIDATED == '1' ]
then
echo
echo "-------------------------------"
echo "TimeLD federation was a success"
echo "-------------------------------"
echo
exit 0
else
echo
echo "------------------------"
echo "TimeLD federation failed"
echo "------------------------"
echo
exit 1
fi