forked from AsamK/signal-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.sh
executable file
·208 lines (176 loc) · 7.32 KB
/
run_tests.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#!/bin/sh
if [ $# -ne 2 ]; then
echo "Usage: $0 NUMBER_1 NUMBER_2"
exit 1
fi
set -e
# To update graalvm config, set GRAALVM_HOME, e.g:
# export GRAALVM_HOME=/usr/lib/jvm/java-17-graalvm
if [ ! -z "$GRAALVM_HOME" ]; then
export JAVA_HOME=$GRAALVM_HOME
export SIGNAL_CLI_OPTS='-agentlib:native-image-agent=config-merge-dir=graalvm-config-dir/'
fi
NUMBER_1="$1"
NUMBER_2="$2"
TEST_PIN_1=456test_pin_foo123
NATIVE=0
PATH_TEST_CONFIG="$PWD/build/test-config"
PATH_MAIN="$PATH_TEST_CONFIG/main"
PATH_LINK="$PATH_TEST_CONFIG/link"
if [ "$NATIVE" -eq 1 ]; then
SIGNAL_CLI="$PWD/build/native/nativeCompile/signal-cli"
else
./gradlew installDist
SIGNAL_CLI="$PWD/build/install/signal-cli/bin/signal-cli"
fi
run() {
set -x
"$SIGNAL_CLI" --service-environment="staging" $@
set +x
}
run_main() {
run --config="$PATH_MAIN" $@
}
run_linked() {
run --config="$PATH_LINK" $@
}
register() {
NUMBER=$1
PIN=$2
echo -n "Enter a captcha token (https://signalcaptchas.org/staging/challenge/generate.html): "
read CAPTCHA
run_main -a "$NUMBER" register --captcha "$CAPTCHA"
echo -n "Enter validation code for ${NUMBER}: "
read CODE
if [ -z "$PIN" ]; then
run_main -a "$NUMBER" verify "$CODE"
else
run_main -a "$NUMBER" verify "$CODE" --pin "$PIN"
fi
}
link() {
NUMBER=$1
LINK_CODE_FILE="$PATH_TEST_CONFIG/link_code"
rm -f "$LINK_CODE_FILE"
mkfifo "$LINK_CODE_FILE"
run_linked link -n "test-device" >"$LINK_CODE_FILE" &
read LINK_CODE <"$LINK_CODE_FILE"
run_main -a "$NUMBER" addDevice --uri "$LINK_CODE"
wait
run_linked -a "$NUMBER" send --note-to-self -m hi
run_main -a "$NUMBER" receive
run_linked -a "$NUMBER" receive
run_main -a "$NUMBER" receive
}
run_main --version
run_main --help
## Register
register "$NUMBER_1" "$TEST_PIN_1"
register "$NUMBER_2"
sleep 5
run_main listAccounts
run_main --output=json listAccounts
## DBus
#run_main -a "$NUMBER_1" --dbus send "$NUMBER_2" -m daemon_not_running || true
#run_main daemon &
#DAEMON_PID=$!
#sleep 10
#run_main -a "$NUMBER_1" --dbus send "$NUMBER_2" -m hii
#run_main -a "$NUMBER_2" --dbus receive
#kill "$DAEMON_PID"
# JSON-RPC
FIFO_FILE="${PATH_MAIN}/dbus-fifo"
rm -f "$FIFO_FILE"
mkfifo "$FIFO_FILE"
run_main -a "$NUMBER_1" send "$NUMBER_2" -m hi
run_main -a "$NUMBER_2" jsonRpc < "$FIFO_FILE" &
exec 3<> "$FIFO_FILE"
echo '{"jsonrpc":"2.0","id":"id","method":"updateContact","params":{"recipient":"'"$NUMBER_1"'","name":"NUMBER_1","expiration":10}}' >&3
echo '{"jsonrpc":"2.0","id":5,"method":"block","params":{"recipient":"'"$NUMBER_1"'"}}' >&3
echo '{"jsonrpc":"2.0","id":null,"method":"unblock","params":{"recipient":"'"$NUMBER_1"'"}}' >&3
echo '{"jsonrpc":"2.0","id":"id","method":"listContacts"}' >&3
echo '{"jsonrpc":"2.0","id":"id","method":"listGroups"}' >&3
echo '{"jsonrpc":"2.0","id":"id","method":"listDevices"}' >&3
echo '{"jsonrpc":"2.0","id":"id","method":"listIdentities"}' >&3
echo '{"jsonrpc":"2.0","id":"id","method":"sendSyncRequest"}' >&3
echo '{"jsonrpc":"2.0","id":"id","method":"sendContacts"}' >&3
echo '{"jsonrpc":"2.0","id":"id","method":"version"}' >&3
echo '{"jsonrpc":"2.0","id":"id","method":"updateAccount"}' >&3
echo '{"jsonrpc":"2.0","id":7,"method":"sendReceipt","params":{"recipient":"'"$NUMBER_1"'","targetTimestamp":1629919505575}}' >&3
echo '{"jsonrpc":"2.0","id":7,"method":"sendTyping","params":{"recipient":"'"$NUMBER_1"'"}}' >&3
echo '{"jsonrpc":"2.0","id":7,"method":"send","params":{"recipient":"'"$NUMBER_1"'","message":"some text"}}' >&3
echo '{"jsonrpc":"2.0","id":7,"method":"send","params":{"recipients":["'"$NUMBER_1"'","'"$NUMBER_2"'"],"message":"some other text"}}' >&3
echo '{"jsonrpc":"2.0","id":7,"method":"updateProfile","params":{"givenName":"n1","familyName":"n2","about":"ABA","aboutEmoji":"EMO","avatar":"LICENSE"}}' >&3
echo '{"jsonrpc":"2.0","id":7,"method":"getUserStatus","params":{"recipient":"'"$NUMBER_1"'"}}' >&3
# Error expected:
echo '{"jsonrpc":"2.0","id":7,"method":"sendReceipt","params":{"recipient":5}}' >&3
exec 3>&-
wait
run_main -a "$NUMBER_1" setPin "$TEST_PIN_1"
run_main -a "$NUMBER_2" removePin
## Contacts
run_main -a "$NUMBER_2" updateContact "$NUMBER_1" -n NUMBER_1 -e 10
run_main -a "$NUMBER_2" block "$NUMBER_1"
run_main -a "$NUMBER_2" unblock "$NUMBER_1"
run_main -a "$NUMBER_2" listContacts
run_main -a "$NUMBER_1" send "$NUMBER_2" -m hi
run_main -a "$NUMBER_2" receive
run_main -a "$NUMBER_2" send "$NUMBER_1" -m hi
run_main -a "$NUMBER_1" receive
run_main -a "$NUMBER_2" receive
## Groups
GROUP_ID=$(run_main -a "$NUMBER_1" updateGroup -n GRUPPE -a LICENSE -m "$NUMBER_1" | grep -oP '(?<=").+(?=")')
run_main -a "$NUMBER_1" send "$NUMBER_2" -m first
run_main -a "$NUMBER_1" updateGroup -g "$GROUP_ID" -n GRUPPE_UMB -m "$NUMBER_2" --admin "$NUMBER_2" --description DESCRIPTION --link=enabled-with-approval --set-permission-add-member=only-admins --set-permission-edit-details=only-admins --set-permission-send-messages=only-admins -e 42
run_main -a "$NUMBER_1" updateGroup -g "$GROUP_ID" --remove-admin "$NUMBER_2" --reset-link --set-permission-send-messages=every-member
run_main -a "$NUMBER_1" updateGroup -g "$GROUP_ID" -r "$NUMBER_2"
run_main -a "$NUMBER_1" updateGroup -g "$GROUP_ID" -m "$NUMBER_2"
run_main -a "$NUMBER_1" listGroups -d
run_main -a "$NUMBER_1" --output=json listGroups -d
run_main -a "$NUMBER_2" --verbose receive
run_main -a "$NUMBER_2" quitGroup -g "$GROUP_ID"
run_main -a "$NUMBER_2" listGroups -d
run_main -a "$NUMBER_2" --output=json listGroups -d
run_main -a "$NUMBER_1" receive
run_main -a "$NUMBER_1" updateGroup -g "$GROUP_ID" -m "$NUMBER_2"
run_main -a "$NUMBER_1" --verbose block -g "$GROUP_ID"
run_main -a "$NUMBER_1" --verbose unblock -g "$GROUP_ID"
## Configuration
run_main -a "$NUMBER_1" updateConfiguration --read-receipts=true
## Identities
run_main -a "$NUMBER_1" listIdentities
run_main -a "$NUMBER_2" listIdentities
run_main -a "$NUMBER_2" trust "$NUMBER_1" -a
## Basic send/receive
for OUTPUT in "plain-text" "json"; do
run_main -a "$NUMBER_1" --output="$OUTPUT" getUserStatus "$NUMBER_1" "$NUMBER_2" "+111111111"
run_main -a "$NUMBER_1" send "$NUMBER_2" -m hi
run_main -a "$NUMBER_2" send "$NUMBER_1" -m hi
run_main -a "$NUMBER_1" send -g "$GROUP_ID" -m hi -a LICENSE --mention "1:1:$NUMBER_2"
TIMESTAMP=$(uname -a | run_main -a "$NUMBER_1" send "$NUMBER_2")
run_main -a "$NUMBER_2" sendReaction "$NUMBER_1" -e 🍀 -a "$NUMBER_1" -t "$TIMESTAMP"
run_main -a "$NUMBER_1" remoteDelete "$NUMBER_2" -t "$TIMESTAMP"
run_main -a "$NUMBER_2" --output="$OUTPUT" receive
run_main -a "$NUMBER_1" --output="$OUTPUT" receive
run_main -a "$NUMBER_1" send -e "$NUMBER_2"
run_main -a "$NUMBER_2" --output="$OUTPUT" receive
done
## Profile
run_main -a "$NUMBER_1" updateProfile --given-name=GIVEN --family-name=FAMILY --about=ABOUT --about-emoji=EMOJI --avatar=LICENSE
## Provisioning
link "$NUMBER_1"
link "$NUMBER_2"
run_main -a "$NUMBER_1" listDevices
run_linked -a "$NUMBER_1" sendSyncRequest
run_main -a "$NUMBER_1" sendContacts
for OUTPUT in "plain-text" "json"; do
run_main -a "$NUMBER_1" send "$NUMBER_2" -m hi
run_main -a "$NUMBER_2" send "$NUMBER_1" -m hi
run_main -a "$NUMBER_2" --output="$OUTPUT" receive
run_main -a "$NUMBER_1" --output="$OUTPUT" receive
run_linked -a "$NUMBER_1" --output="$OUTPUT" receive
done
run_main -a "$NUMBER_1" removeDevice -d 2
## Unregister
run_main -a "$NUMBER_1" unregister
run_main -a "$NUMBER_2" unregister --delete-account