SSL test framework: port SNI tests
[openssl.git] / test / ssl-tests / 06-sni-ticket.conf.in
1 # -*- mode: perl; -*-
2 # Copyright 2016-2016 The OpenSSL Project Authors. All Rights Reserved.
3 #
4 # Licensed under the OpenSSL license (the "License").  You may not use
5 # this file except in compliance with the License.  You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
8
9
10 ## Test version negotiation
11
12 use strict;
13 use warnings;
14
15 package ssltests;
16
17
18 our @tests = ();
19
20 sub generate_tests() {
21     foreach my $c ("SessionTicket", "-SessionTicket") {
22         foreach my $s1 ("SessionTicket", "-SessionTicket") {
23             foreach my $s2 ("SessionTicket", "-SessionTicket") {
24                 foreach my $n ("server1", "server2") {
25                     my $result = expected_result($c, $s1, $s2, $n);
26                     push @tests, {
27                         "name" => "sni-session-ticket",
28                         "client" => {
29                             "Options" => $c,
30                         },
31                         "server" => {
32                             "Options" => $s1,
33                         },
34                         "server2" => {
35                             "Options" => $s2,
36                         },
37                         "test" => {
38                             "ServerName" => $n,
39                             "ExpectedServerName" => $n,
40                             # We don't test mismatch here.
41                             "ServerNameCallback" => "IgnoreMismatch",
42                             "ExpectedResult" => "Success",
43                             "SessionTicketExpected" => $result,
44                         }
45                     };
46                 }
47             }
48         }
49     }
50 }
51
52 # If the client has session tickets disabled, then No support
53 # If the server initial_ctx has session tickets disabled, then No support
54 # If SNI is in use, then if the "switched-to" context has session tickets disabled,
55 #    then No support
56 sub expected_result {
57     my ($c, $s1, $s2, $n) = @_;
58
59     return "No" if $c eq "-SessionTicket";
60     return "No" if $s1 eq "-SessionTicket";
61     return "No" if ($s2 eq "-SessionTicket" && $n eq "server2");
62
63     return "Yes";
64
65 }
66
67 # Add a "Broken" case.
68 push @tests, {
69     "name" => "sni-session-ticket",
70     "client" => {
71         "Options" => "SessionTicket",
72     },
73     "server" => {
74         "Options" => "SessionTicket",
75     },
76     "server2" => {
77         "Options" => "SessionTicket",
78     },
79     "test" => {
80         "ServerName" => "server1",
81         "ExpectedResult" => "Success",
82         "SessionTicketExpected" => "Broken",
83     }
84 };
85
86 generate_tests();