-
Notifications
You must be signed in to change notification settings - Fork 12
/
smoke-test.sh
executable file
·75 lines (66 loc) · 2.27 KB
/
smoke-test.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
#!/bin/bash
# Copyright © 2020 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
cards=("0003293374" "0003278380" "0003292371")
declare -i timeoutCounter=0
while true ; do
echo "Working..."
result=$(curl -X GET http://localhost:48094/status | grep -n '{\"lock1_status\":1,\"lock2_status\":1,\"door_closed\":true') # -n shows line number
echo "timeout value = $timeoutCounter"
if [ ! -z $result ] ; then
echo "Found correct state!"
break
fi
if [[ $timeoutCounter -eq 5 ]]; then
echo "reached timeout"
exit 1
else
echo "Waiting for correct state"
timeoutCounter=$(( timeoutCounter + 1 ))
fi
sleep 1
done
for i in "${cards[@]}";
do
curl -X GET http://localhost:48094/status | jq .
# make sure locks are 1 and door is true
echo $i
echo
curl -X PUT -H "Content-Type: application/json" -d "{\"card-number\":\"$i\"}" http://localhost:48098/api/v3/device/name/card-reader/card-number | jq .
echo
echo "card read!!!!!!!!!!!!!"
sleep 5
curl -X GET http://localhost:48094/status | jq .
# should show lock1_status: 0 (false)
echo
echo "Card status!!!!!!!!!!!!!"
# open door
curl -X PUT -H "Content-Type: application/json" -d '{"setDoorClosed":"0"}' http://localhost:48097/api/v3/device/name/controller-board/setDoorClosed | jq .
echo
echo "open door!!!!!!!!!!!!!"
sleep 4
curl -X GET http://localhost:48094/status | jq .
# should show door:false
echo
echo "open door status!!!!!!!!!!!!!"
curl -X PUT -H "Content-Type: application/json" -d '{"setDoorClosed":"1"}' http://localhost:48097/api/v3/device/name/controller-board/setDoorClosed | jq .
echo
echo "close door !!!!!!!!!!!!!"
sleep 4
curl -X GET http://localhost:48094/status | jq .
# should show door:true
echo
echo "close door status!!!!!!!!!!!!!"
curl -X GET http://localhost:48095/inventory | jq .
echo
echo "Get inventory !!!!!!!!!!!!!"
curl -X GET http://localhost:48095/auditlog | jq .
echo
echo "Get Audit log!!!!!!!!!!!!!"
curl -X GET http://localhost:48093/ledger | jq .
echo
echo "Get ledger!!!!!!!!!!!!"
sleep 5
echo "GOING TO NEXT CARD NUMBER"
done
echo "NO MORE CARD NUMBERS. DONE!"