-
Notifications
You must be signed in to change notification settings - Fork 2
/
test-prejournal.sh
executable file
·91 lines (81 loc) · 3.13 KB
/
test-prejournal.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
87
88
89
90
91
#!/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"`
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 prejournal to tiki and timeld"
echo "WIKI_TOKEN=testnet-supersecret-token" >> testnet.env
echo "WIKI_HOST=http://tikiwiki.local/api/tabulars" >> testnet.env
echo "WIKI_TABULAR_ID=3" >> testnet.env
echo "TIMELD_HOST=http://timeld-gateway.local:8080/api" >> testnet.env
echo "TIMELD_USERNAME=alice" >> testnet.env
echo "TIMELD_TIMESHEET=alice/timesheet" >> testnet.env
echo "TIMELD_PROJECT=alice/project" >> testnet.env
echo "TIMELD_PASSWORD=$TIMELD_PASSWORD" >> testnet.env
docker cp testnet.env federated-timesheets-tests_prejournal_1:/app/.env
echo "--- Entering timesheet entry in prejournal"
curl -d'["23 Sep 2022","stichting","Federated Timesheets", 8, "This is the description to check for"]' http://alice:alice123@localhost:8280/v1/worked-hours
echo "--- Fetching report from timeld"
docker exec -it federated-timesheets-tests_timeld-cli_1 "/usr/local/bin/node" "/timeld/report.mjs" > timeld-report.txt
echo "--- Fetching report from tikiwiki"
curl -H "Authorization: Bearer testnet-supersecret-token" http://localhost:8180/api/trackers/1 > tiki-report.json
TIMELD_VALIDATED=`grep -c "This is the description to check for" timeld-report.txt`
TIKI_VALIDATED=`grep -c "This is the description to check for" tiki-report.json`
if [ $TIMELD_VALIDATED == '1' ]
then
echo
echo "------------------------------"
echo "Federation to TimeLD validated"
echo "------------------------------"
cat timeld-report.txt
echo "------------------------------"
else
echo
echo "------------------------------"
echo "Federation to TimeLD failed"
echo "------------------------------"
cat timeld-report.txt
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 timeld-report.txt
rm tiki-report.json
docker-compose down
if [ $TIMELD_VALIDATED == '1' ] && [ $TIKI_VALIDATED == '1' ]
then
echo
echo "-----------------------------------"
echo "Prejournal federation was a success"
echo "-----------------------------------"
echo
exit 0
else
echo
echo "----------------------------"
echo "Prejournal federation failed"
echo "----------------------------"
echo
exit 1
fi