~ubuntu-branches/ubuntu/trusty/erlang/trusty

« back to all changes in this revision

Viewing changes to lib/ssl/test/old_ssl_protocol_SUITE.erl

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%%
 
2
%% %CopyrightBegin%
 
3
%%
 
4
%% Copyright Ericsson AB 2005-2011. All Rights Reserved.
 
5
%%
 
6
%% The contents of this file are subject to the Erlang Public License,
 
7
%% Version 1.1, (the "License"); you may not use this file except in
 
8
%% compliance with the License. You should have received a copy of the
 
9
%% Erlang Public License along with this software. If not, it can be
 
10
%% retrieved online at http://www.erlang.org/.
 
11
%%
 
12
%% Software distributed under the License is distributed on an "AS IS"
 
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 
14
%% the License for the specific language governing rights and limitations
 
15
%% under the License.
 
16
%%
 
17
%% %CopyrightEnd%
 
18
%%
 
19
 
 
20
%%
 
21
-module(old_ssl_protocol_SUITE).
 
22
 
 
23
-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1, 
 
24
         init_per_group/2,end_per_group/2, 
 
25
         init_per_testcase/2, end_per_testcase/2, 
 
26
         sslv2/1, sslv3/1, tlsv1/1, sslv2_sslv3/1,
 
27
         sslv2_tlsv1/1, sslv3_tlsv1/1, sslv2_sslv3_tlsv1/1]).
 
28
 
 
29
-import(ssl_test_MACHINE, [mk_ssl_cert_opts/1, test_one_listener/7,
 
30
                           test_server_only/6]).
 
31
-include_lib("test_server/include/test_server.hrl").
 
32
-include("ssl_test_MACHINE.hrl").
 
33
 
 
34
 
 
35
init_per_testcase(_Case, Config) ->
 
36
    WatchDog = test_server:timetrap(?DEFAULT_TIMEOUT),
 
37
    [{watchdog, WatchDog}| Config].
 
38
 
 
39
end_per_testcase(_Case, Config) ->
 
40
    WatchDog = ?config(watchdog, Config),
 
41
    test_server:timetrap_cancel(WatchDog).
 
42
 
 
43
suite() -> [{ct_hooks,[ts_install_cth]}].
 
44
 
 
45
all() -> 
 
46
    [sslv2, sslv3, tlsv1, sslv2_sslv3, sslv2_tlsv1,
 
47
     sslv3_tlsv1, sslv2_sslv3_tlsv1].
 
48
 
 
49
groups() -> 
 
50
    [].
 
51
 
 
52
init_per_group(_GroupName, Config) ->
 
53
    Config.
 
54
 
 
55
end_per_group(_GroupName, Config) ->
 
56
    Config.
 
57
 
 
58
 
 
59
init_per_suite(doc) ->
 
60
    "Want to se what Config contains.";
 
61
init_per_suite(suite) ->
 
62
    [];
 
63
init_per_suite(Config) ->
 
64
    io:format("Config: ~p~n", [Config]),
 
65
 
 
66
    %% Check if SSL exists. If this case fails, all other cases are skipped
 
67
    case catch crypto:start() of
 
68
        ok ->
 
69
            application:start(public_key),
 
70
            case ssl:start() of
 
71
                ok -> ssl:stop();
 
72
                {error, {already_started, _}} -> ssl:stop();
 
73
                Error -> ?t:fail({failed_starting_ssl,Error})
 
74
            end,
 
75
            Config;
 
76
        _Else ->
 
77
            {skip,"Could not start crypto"}
 
78
    end.
 
79
 
 
80
end_per_suite(doc) ->
 
81
    "This test case has no other purpose than closing the conf case.";
 
82
end_per_suite(suite) ->
 
83
    [];
 
84
end_per_suite(Config) ->
 
85
    crypto:stop(),
 
86
    Config.
 
87
 
 
88
%%%%%
 
89
 
 
90
sslv2(doc) ->
 
91
    "Client has no cert. Nor the client, nor the server is verifying its "
 
92
        "peer. Server closes, client waits for close. "
 
93
        "Client and server choose SSLv2."; 
 
94
sslv2(suite) ->
 
95
    [];
 
96
sslv2(Config) when list(Config) ->
 
97
    do_run_test(Config, [sslv2]).
 
98
 
 
99
sslv3(doc) ->
 
100
    "Client has no cert. Nor the client, nor the server is verifying its "
 
101
        "peer. Server closes, client waits for close. "
 
102
        "Client and server choose SSLv3."; 
 
103
sslv3(suite) ->
 
104
    [];
 
105
sslv3(Config) when list(Config) ->
 
106
    do_run_test(Config, [sslv3]).
 
107
 
 
108
tlsv1(doc) ->
 
109
    "Client has no cert. Nor the client, nor the server is verifying its "
 
110
        "peer. Server closes, client waits for close. "
 
111
        "Client and server choose TLSv1."; 
 
112
tlsv1(suite) ->
 
113
    [];
 
114
tlsv1(Config) when list(Config) ->
 
115
    do_run_test(Config, [tlsv1]).
 
116
 
 
117
sslv2_sslv3(doc) ->
 
118
    "Client has no cert. Nor the client, nor the server is verifying its "
 
119
        "peer. Server closes, client waits for close. "
 
120
        "Client and server choose between SSLv2 and SSLv3."; 
 
121
sslv2_sslv3(suite) ->
 
122
    [];
 
123
sslv2_sslv3(Config) when list(Config) ->
 
124
    do_run_test(Config, [sslv2, sslv3]).
 
125
 
 
126
sslv2_tlsv1(doc) ->
 
127
    "Client has no cert. Nor the client, nor the server is verifying its "
 
128
        "peer. Server closes, client waits for close. "
 
129
        "Client and server choose between SSLv2 and TLSv1."; 
 
130
sslv2_tlsv1(suite) ->
 
131
    [];
 
132
sslv2_tlsv1(Config) when list(Config) ->
 
133
    do_run_test(Config, [sslv2, tlsv1]).
 
134
 
 
135
sslv3_tlsv1(doc) ->
 
136
    "Client has no cert. Nor the client, nor the server is verifying its "
 
137
        "peer. Server closes, client waits for close. "
 
138
        "Client and server choose between SSLv3 and TLSv1."; 
 
139
sslv3_tlsv1(suite) ->
 
140
    [];
 
141
sslv3_tlsv1(Config) when list(Config) ->
 
142
    do_run_test(Config, [sslv3, tlsv1]).
 
143
 
 
144
sslv2_sslv3_tlsv1(doc) ->
 
145
    "Client has no cert. Nor the client, nor the server is verifying its "
 
146
        "peer. Server closes, client waits for close. "
 
147
        "Client and server choose between SSLv2, SSLv3, and TLSv1."; 
 
148
sslv2_sslv3_tlsv1(suite) ->
 
149
    [];
 
150
sslv2_sslv3_tlsv1(Config) when list(Config) ->
 
151
    do_run_test(Config, [sslv2, sslv3, tlsv1]).
 
152
 
 
153
%%%%
 
154
 
 
155
do_run_test(Config0, Protocols) ->
 
156
    process_flag(trap_exit, true),
 
157
    LPort = 3456,
 
158
    Timeout = 40000, NConns = 1,
 
159
    DataSize = 10,
 
160
 
 
161
    ?line {ok, {_, SsslOpts0}} = mk_ssl_cert_opts(Config0),
 
162
    ?line SsslOpts = [{verify, 0}, {depth, 2} | SsslOpts0],
 
163
 
 
164
    ?line {ok, Host} = inet:gethostname(),
 
165
 
 
166
    LCmds = [{sockopts, [{backlog, NConns}]},
 
167
             {sslopts, SsslOpts},
 
168
             {listen, LPort}, 
 
169
             wait_sync,
 
170
             lclose],
 
171
    ACmds = [{timeout, Timeout}, 
 
172
             accept,
 
173
             connection_info,
 
174
             {recv, DataSize},
 
175
             close],
 
176
    CCmds = [{timeout, Timeout}, 
 
177
             {connect, {Host, LPort}},
 
178
             connection_info,
 
179
             {send, DataSize},
 
180
             await_close],
 
181
    Config1 = [{env, [{protocol_version, Protocols}]} | Config0],
 
182
    ?line test_one_listener(NConns, LCmds, ACmds, CCmds, Timeout,
 
183
                            ?MODULE, Config1).
 
184
 
 
185