You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docker/integtest/1-register-client.sh
+22-12Lines changed: 22 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,25 @@ mkdir -p "${out_dir}"
7
7
# shellcheck disable=SC1090
8
8
."${scriptdir}/utils.sh"
9
9
10
+
readonly polling_interval_seconds=2
11
+
readonly max_retries=150
12
+
13
+
wait_for_client() {
14
+
local client="$1"
15
+
local i
16
+
17
+
foriin$(seq 1 "${max_retries}");do
18
+
if curl -fs -u "${REGISTRATION_CREDENTIALS}""http://nginx:8888/api/email/register/developer${client}.lokole.ca"| tee "${out_dir}/register${client}.json";then
19
+
log "Client ${client} is registered"
20
+
return
21
+
fi
22
+
log "Waiting for client ${client} registration (${i}/${max_retries})"
23
+
sleep "${polling_interval_seconds}"
24
+
done
25
+
26
+
exit 1
27
+
}
28
+
10
29
# workflow 3: register a new client called "developer"
11
30
# normally this endpoint would be called during a new lokole device setup
12
31
curl -fs \
@@ -15,10 +34,7 @@ curl -fs \
15
34
-d '{"domain":"developer1.lokole.ca"}' \
16
35
"http://nginx:8888/api/email/register/"
17
36
18
-
while! curl -fs -u "${REGISTRATION_CREDENTIALS}""http://nginx:8888/api/email/register/developer1.lokole.ca"| tee "${out_dir}/register1.json";do
19
-
log "Waiting for client 1 registration"
20
-
sleep 1s
21
-
done
37
+
wait_for_client 1
22
38
23
39
# registering a client with bad credentials should fail
24
40
if curl -fs \
@@ -35,10 +51,7 @@ curl -fs \
35
51
-d '{"domain":"developer2.lokole.ca"}' \
36
52
"http://nginx:8888/api/email/register/"
37
53
38
-
while! curl -fs -u "${REGISTRATION_CREDENTIALS}""http://nginx:8888/api/email/register/developer2.lokole.ca"| tee "${out_dir}/register2.json";do
39
-
log "Waiting for client 2 registration"
40
-
sleep 1s
41
-
done
54
+
wait_for_client 2
42
55
43
56
# after creating a client, creating the same one again should fail but we should be able to delete it
0 commit comments