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 package org.apache.hc.core5.http.ssl;
29
30 import static org.junit.jupiter.api.Assertions.assertNull;
31 import static org.junit.jupiter.api.Assertions.assertTrue;
32
33 import org.apache.hc.core5.http.ParseException;
34 import org.junit.jupiter.api.Assertions;
35 import org.junit.jupiter.api.Test;
36
37 class TLSTest {
38
39
40 @Test
41 void isSame() throws ParseException {
42 assertTrue(TLS.V_1_0.isSame(TLS.parse("TLSv1")));
43 }
44
45 @Test
46 void isComparable() throws ParseException {
47 assertTrue(TLS.V_1_0.isComparable(TLS.parse("TLSv1")));
48 }
49
50 @Test
51 void greaterEquals() throws ParseException {
52 assertTrue(TLS.V_1_3.greaterEquals(TLS.parse("TLSv1")));
53 }
54
55 @Test
56 void lessEquals() throws ParseException {
57 assertTrue(TLS.V_1_0.lessEquals(TLS.parse("TLSv1.3")));
58 }
59
60 @Test
61 void parse() throws ParseException {
62 assertTrue(TLS.V_1_0.lessEquals(TLS.parse("TLSv1.3")));
63 }
64
65 @Test
66 void parseNull() throws ParseException {
67 assertNull(TLS.parse(null));
68 }
69
70 @Test
71 void excludeWeakNull() {
72 assertNull((TLS.excludeWeak((String[]) null)));
73 }
74
75 @Test
76 void excludeWeak() {
77 final String[] mixProtocol = {
78 "SSL 2.0",
79 "TLS 1.3",
80 "SSL 3.0",
81 "TLS 1.2",
82 "TLS 1.1"
83 };
84 final String[] strongProtocols = TLS.excludeWeak(mixProtocol);
85 for (final String protocol : strongProtocols) {
86 Assertions.assertTrue(TLS.isSecure(protocol));
87 }
88 }
89 }