-
Notifications
You must be signed in to change notification settings - Fork 10
/
test.sh
executable file
·97 lines (72 loc) · 2.16 KB
/
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
TEST_CERT_ALGORITHM=(
"prime256v1 sha256"
"secp384r1 sha384"
)
TEST_CIPHER_SUITES=(
"TLS_AES_128_GCM_SHA256"
"TLS_AES_256_GCM_SHA384"
"TLS_CHACHA20_POLY1305_SHA256"
)
TEST_GROUPS=(
"X25519"
"P-256"
)
set -eux
TMP_FIFO="/tmp/tls13-zig"
rm -rf $TMP_FIFO
mkfifo $TMP_FIFO
cd $(dirname $0)
for CERT_ALGO in "${TEST_CERT_ALGORITHM[@]}"
do
# Generate testing certificate
set -- $CERT_ALGO
openssl req -x509 -nodes -days 365 -subj '/C=JP/ST=Kyoto/L=Kyoto/CN=localhost' -newkey ec:<(openssl ecparam -name $1) -nodes -$2 -keyout key.pem -out cert.pem
openssl x509 -text -noout -in cert.pem
for GROUP in "${TEST_GROUPS[@]}"
do
for SUITE in "${TEST_CIPHER_SUITES[@]}"
do
echo "Testing $GROUP-$SUITE(with cert $CERT_ALGO)."
# Run openssl server
openssl s_server -tls1_3 -accept 8443 -cert cert.pem -key key.pem -www -ciphersuites $SUITE -groups $GROUP &
set +e
# Let's test!
NUM_OF_OK=`zig test src/main_test.zig --test-filter 'e2e with early_data' 2>&1 | grep "HTTP/1.0 200 ok" | wc -l`
if [ $? -ne 0 ]; then
echo "failed."
pkill -SIGKILL openssl
exit 1
fi
if [ $NUM_OF_OK -ne 2 ]; then
echo "failed. NUM_OF_OK is not 2."
pkill -SIGKILL openssl
exit 1
fi
echo "OK."
set -e
pkill -SIGKILL openssl
sleep 1
done
done
# 0-RTT
for SUITE in "${TEST_CIPHER_SUITES[@]}"
do
echo "Testing 0-RTT Early Data $SUITE(with cert $CERT_ALGO)."
# Run openssl server
cat $TMP_FIFO | openssl s_server -tls1_3 -accept 8443 -cert cert.pem -key key.pem -early_data -ciphersuites $SUITE &
set +e
# Let's test!
zig test src/main_test_0rtt.zig --test-filter 'e2e with 0rtt'
if [ $? -ne 0 ]; then
echo "failed."
pkill -SIGKILL openssl
exit 1
fi
echo "OK."
set -e
pkill -SIGKILL openssl
sleep 1
done
done
rm -rf $TMP_FIFO