summaryrefslogtreecommitdiffstats
path: root/tests/howsmyssl.sh
blob: d9ee89ee1882eb52ae17b344387ee5a8179bd072 (plain)
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
# Tests using Jeff Hodges's How's My SSL? Web service
#
# Copyright (C) 2019  Libiquity LLC
#
# This file is part of wolfutil.
#
# wolfutil is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# wolfutil is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with wolfutil.  If not, see <http://www.gnu.org/licenses/>.

set -eu

. "${TOP_SRCDIR}/tests/aux/tap-functions.sh"
JSON_SEPARATOR='/' JSON_DEBUG='' . "${TOP_SRCDIR}/tests/aux/json.sh"

test_grep()
{
	printf '%s\n' "${members}" | grep "${@}"
}

plan_ 7

json="$(printf 'GET /a/check HTTP/1.1\r\n'$(: \
	)'Host: www.howsmyssl.com:443\r\nConnection: close\r\n\r\n' | \
	"${TOP_BUILDDIR}/wolfutil" s_client \
		-connect www.howsmyssl.com:443 \
		-servername www.howsmyssl.com | \
	sed -n 's/\r$//; /^{/,$p')"
printf '%s\n'

IFS='
'
printf '# JSON:\n'
printf '#   %s\n' ${json}
unset IFS

members="$(printf '%s\n' "${json}" | json)"

IFS='
'
printf '# Parsed members:\n'
printf '#   %s\n' ${members}
unset IFS

command_ok_ 'Ephemeral keys supported' -- \
	test_grep -q '^/ephemeral_keys_supported boolean true$'
command_ok_ 'No TLS compression supported' -- \
	test_grep -q '^/tls_compression_supported boolean false$'
command_ok_ 'No unknown cipher suites supported' -- \
	test_grep -q '^/unknown_cipher_suite_supported boolean false$'
command_ok_ 'No BEAST vulnerability' -- \
	test_grep -q '^/beast_vuln boolean false$'
command_ok_ 'No weak cipher suites supported' -- \
	test_grep -vq '^/insecure_cipher_suites/'
command_ok_ 'TLS 1.2' -- \
	test_grep -q '^/tls_version string TLS 1.2$'
command_ok_ 'Probably OK' -- \
	test_grep -q '^/rating string Probably Okay$'