Skip to content

Commit

Permalink
Store test config certs in funs
Browse files Browse the repository at this point in the history
Reduce the output of (almost) every testcase output, by putting
some settings in fun().

This is just done to reduce the printing of
`=== Config value: ....`
That is printed in each testcase and could be up to 2000 lines.
  • Loading branch information
dgud committed Nov 20, 2024
1 parent a74b9f5 commit 2c05db7
Show file tree
Hide file tree
Showing 14 changed files with 186 additions and 172 deletions.
22 changes: 11 additions & 11 deletions lib/ssl/test/openssl_alpn_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ end_per_testcase(_, Config) ->
%%--------------------------------------------------------------------

erlang_client_alpn_openssl_server_alpn(Config) when is_list(Config) ->
ServerOpts = proplists:get_value(server_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),
AlpnProtocol = <<"spdy/2">>,

{Server, OpenSSLPort} =
Expand All @@ -193,7 +193,7 @@ erlang_client_alpn_openssl_server_alpn(Config) when is_list(Config) ->
%%--------------------------------------------------------------------

erlang_server_alpn_openssl_client_alpn(Config) when is_list(Config) ->
ClientOpts = proplists:get_value(client_rsa_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_opts, Config),
Protocol = <<"spdy/2">>,
Server = ssl_test_lib:start_server(erlang, [{from, self()}],
Expand Down Expand Up @@ -222,7 +222,7 @@ erlang_server_alpn_openssl_client_alpn(Config) when is_list(Config) ->
%%--------------------------------------------------------------------------

erlang_client_alpn_openssl_server(Config) when is_list(Config) ->
ServerOpts = proplists:get_value(server_rsa_verify_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),
Protocol = <<"spdy/2">>,

Expand All @@ -248,7 +248,7 @@ erlang_client_alpn_openssl_server(Config) when is_list(Config) ->
%%--------------------------------------------------------------------------

erlang_client_openssl_server_alpn(Config) when is_list(Config) ->
ServerOpts = proplists:get_value(server_rsa_verify_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),

{Server, OpenSSLPort} = ssl_test_lib:start_server(openssl, [{alpn,"spdy/2"}, return_port],
Expand All @@ -269,7 +269,7 @@ erlang_client_openssl_server_alpn(Config) when is_list(Config) ->

%%--------------------------------------------------------------------------
erlang_server_alpn_openssl_client(Config) when is_list(Config) ->
ClientOpts = proplists:get_value(client_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_verify_opts, Config),
Server = ssl_test_lib:start_server(erlang, [{from, self()}],
[{server_opts, [{alpn_preferred_protocols,
Expand All @@ -296,7 +296,7 @@ erlang_server_alpn_openssl_client(Config) when is_list(Config) ->
%%--------------------------------------------------------------------------

erlang_server_openssl_client_alpn(Config) when is_list(Config) ->
ClientOpts = proplists:get_value(client_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_verify_opts, Config),
Server = ssl_test_lib:start_server(erlang, [{from, self()}],
[{server_opts, [ServerOpts]} | Config]),
Expand Down Expand Up @@ -324,7 +324,7 @@ erlang_server_openssl_client_alpn(Config) when is_list(Config) ->

erlang_client_alpn_openssl_server_alpn_renegotiate(Config) when is_list(Config) ->

ServerOpts = proplists:get_value(server_rsa_verify_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),
AlpnProtocol = <<"spdy/2">>,

Expand Down Expand Up @@ -361,7 +361,7 @@ erlang_client_alpn_openssl_server_alpn_renegotiate(Config) when is_list(Config)
%%--------------------------------------------------------------------

erlang_server_alpn_openssl_client_alpn_renegotiate(Config) when is_list(Config) ->
ClientOpts = proplists:get_value(client_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_verify_opts, Config),
AlpnProtocol = <<"spdy/2">>,
Server = ssl_test_lib:start_server(erlang, [{from, self()}],
Expand Down Expand Up @@ -398,7 +398,7 @@ erlang_server_alpn_openssl_client_alpn_renegotiate(Config) when is_list(Config)
%%--------------------------------------------------------------------

erlang_client_alpn_npn_openssl_server_alpn_npn(Config) when is_list(Config) ->
ServerOpts = proplists:get_value(server_rsa_verify_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),
AlpnProtocol = <<"spdy/2">>,

Expand Down Expand Up @@ -426,7 +426,7 @@ erlang_client_alpn_npn_openssl_server_alpn_npn(Config) when is_list(Config) ->
%%--------------------------------------------------------------------

erlang_server_alpn_npn_openssl_client_alpn_npn(Config) when is_list(Config) ->
ClientOpts = proplists:get_value(client_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_verify_opts, Config),
AlpnProtocol = <<"spdy/2">>,
Server = ssl_test_lib:start_server(erlang,
Expand Down
32 changes: 16 additions & 16 deletions lib/ssl/test/openssl_client_cert_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ init_per_group(openssl_client, Config) ->
init_per_group(Group, Config0) when Group == rsa;
Group == rsa_1_3 ->
Config = ssl_test_lib:make_rsa_cert(Config0),
COpts = proplists:get_value(client_rsa_opts, Config),
SOpts = proplists:get_value(server_rsa_opts, Config),
COpts = ssl_test_lib:ssl_options(client_rsa_opts, Config),
SOpts = ssl_test_lib:ssl_options(server_rsa_opts, Config),
%% Make sure _rsa* suite is chosen by ssl_test_lib:start_server
Version = ssl_test_lib:protocol_version(Config),
Ciphers = ssl_cert_tests:test_ciphers(fun(dhe_rsa) ->
Expand All @@ -179,8 +179,8 @@ init_per_group(Group, Config0) when Group == rsa;
[_|_] ->
[{cert_key_alg, rsa} |
lists:delete(cert_key_alg,
[{client_cert_opts, [{ciphers, Ciphers} | COpts]},
{server_cert_opts, SOpts} |
[{client_cert_opts, fun() -> [{ciphers, Ciphers} | COpts] end},
{server_cert_opts, fun() -> SOpts end} |
lists:delete(server_cert_opts,
lists:delete(client_cert_opts, Config))])];
[] ->
Expand All @@ -205,8 +205,8 @@ init_per_group(Alg, Config) when
server_config := SOpts} = ssl_test_lib:make_rsa_pss_pem(rsa_alg(Alg), [], Config, ""),
[{cert_key_alg, rsa_alg(Alg)} |
lists:delete(cert_key_alg,
[{client_cert_opts, openssl_sig_algs(rsa_alg(Alg)) ++ COpts},
{server_cert_opts, ssl_test_lib:sig_algs(Alg, Version) ++ SOpts} |
[{client_cert_opts, fun() -> openssl_sig_algs(rsa_alg(Alg)) ++ COpts end},
{server_cert_opts, fun() -> ssl_test_lib:sig_algs(Alg, Version) ++ SOpts end} |
lists:delete(server_cert_opts,
lists:delete(client_cert_opts, Config))])];
false ->
Expand All @@ -221,8 +221,8 @@ init_per_group(Group, Config0) when Group == ecdsa;
of
true ->
Config = ssl_test_lib:make_ecdsa_cert(Config0),
COpts = proplists:get_value(client_ecdsa_opts, Config),
SOpts = proplists:get_value(server_ecdsa_opts, Config),
COpts = ssl_test_lib:ssl_options(client_ecdsa_opts, Config),
SOpts = ssl_test_lib:ssl_options(server_ecdsa_opts, Config),
%% Make sure ecdh* suite is chosen by ssl_test_lib:start_server
Version = ssl_test_lib:protocol_version(Config),
Ciphers = ssl_cert_tests:test_ciphers(fun(ecdh_ecdsa) ->
Expand All @@ -236,8 +236,8 @@ init_per_group(Group, Config0) when Group == ecdsa;
[_|_] ->
[{cert_key_alg, ecdsa} |
lists:delete(cert_key_alg,
[{client_cert_opts, [{ciphers, Ciphers} | COpts]},
{server_cert_opts, SOpts} |
[{client_cert_opts, fun() -> [{ciphers, Ciphers} | COpts] end},
{server_cert_opts, fun() -> SOpts end} |
lists:delete(server_cert_opts,
lists:delete(client_cert_opts, Config))]
)];
Expand Down Expand Up @@ -268,8 +268,8 @@ init_per_group(eddsa_1_3, Config0) ->

[{cert_key_alg, eddsa} |
lists:delete(cert_key_alg,
[{client_cert_opts, COpts},
{server_cert_opts, SOpts} |
[{client_cert_opts, fun() -> COpts end},
{server_cert_opts, fun() -> SOpts end} |
lists:delete(server_cert_opts,
lists:delete(client_cert_opts, Config0))]
)];
Expand All @@ -286,8 +286,8 @@ init_per_group(Group, Config0) when Group == dsa ->
of
true ->
Config = ssl_test_lib:make_dsa_cert(Config0),
COpts = SigAlgs ++ proplists:get_value(client_dsa_opts, Config),
SOpts = SigAlgs ++ proplists:get_value(server_dsa_opts, Config),
COpts = SigAlgs ++ ssl_test_lib:ssl_options(client_dsa_opts, Config),
SOpts = SigAlgs ++ ssl_test_lib:ssl_options(server_dsa_opts, Config),
%% Make sure dhe_dss* suite is chosen by ssl_test_lib:start_server
Version = ssl_test_lib:protocol_version(Config),
Ciphers = ssl_cert_tests:test_ciphers(fun(dh_dss) ->
Expand All @@ -301,8 +301,8 @@ init_per_group(Group, Config0) when Group == dsa ->
[_|_] ->
[{cert_key_alg, dsa} |
lists:delete(cert_key_alg,
[{client_cert_opts, [{ciphers, Ciphers} | COpts]},
{server_cert_opts, [{ciphers, Ciphers} | SOpts]} |
[{client_cert_opts, fun() -> [{ciphers, Ciphers} | COpts] end},
{server_cert_opts, fun() -> [{ciphers, Ciphers} | SOpts] end} |
lists:delete(server_cert_opts,
lists:delete(client_cert_opts, Config))])];
[] ->
Expand Down
8 changes: 4 additions & 4 deletions lib/ssl/test/openssl_mfl_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ openssl_client(Config) when is_list(Config) ->
%--------------------------------------------------------------------------------
reuse_session_erlang_server(Config) when is_list(Config) ->
ServerOpts = ssl_test_lib:ssl_options(server_rsa_opts, Config),
ClientOpts = proplists:get_value(client_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),
Protocol = proplists:get_value(protocol, ServerOpts, tls),
{_, ServerNode, _} = ssl_test_lib:run_where(Config),
MFL = 512,
Expand All @@ -136,7 +136,7 @@ reuse_session_erlang_server(Config) when is_list(Config) ->
reuse_session_erlang_client(Config) when is_list(Config) ->
process_flag(trap_exit, true),
ClientOpts0 = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),
ServerOpts = proplists:get_value(server_rsa_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_opts, Config),
{ClientNode, _, Hostname} = ssl_test_lib:run_where(Config),
Protocol = proplists:get_value(protocol, ClientOpts0, tls),
MFL = 512,
Expand Down Expand Up @@ -180,7 +180,7 @@ reuse_session_erlang_client(Config) when is_list(Config) ->

openssl_client(MFL, Config) ->
ServerOpts = ssl_test_lib:ssl_options(server_rsa_opts, Config),
ClientOpts = proplists:get_value(client_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),
Protocol = proplists:get_value(protocol, ServerOpts, tls),
{_, ServerNode, _} = ssl_test_lib:run_where(Config),

Expand All @@ -205,7 +205,7 @@ openssl_client(MFL, Config) ->

openssl_server(MFL, Config) ->
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),
ServerOpts = proplists:get_value(server_rsa_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_opts, Config),
Protocol = proplists:get_value(protocol, ClientOpts, tls),
{ClientNode, _, Hostname} = ssl_test_lib:run_where(Config),

Expand Down
30 changes: 15 additions & 15 deletions lib/ssl/test/openssl_npn_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ erlang_client_openssl_server_npn() ->
[{doc,"Test erlang client with openssl server doing npn negotiation"}].

erlang_client_openssl_server_npn(Config) when is_list(Config) ->
ServerOpts = proplists:get_value(server_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),
NpnProtocol = <<"spdy/2">>,

{Server, OpenSSLPort} =
Expand Down Expand Up @@ -161,8 +161,8 @@ erlang_client_openssl_server_npn_renegotiate() ->

erlang_client_openssl_server_npn_renegotiate(Config) when is_list(Config) ->

ServerOpts = proplists:get_value(server_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),
NpnProtocol = <<"spdy/2">>,

Server = ssl_test_lib:start_server(openssl, [{np,"http/1.1,spdy/2"}],
Expand Down Expand Up @@ -197,8 +197,8 @@ erlang_server_openssl_client_npn() ->
[{doc,"Test erlang server with openssl client and npn negotiation"}].

erlang_server_openssl_client_npn(Config) when is_list(Config) ->
ClientOpts = proplists:get_value(client_rsa_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_verify_opts, Config),
Protocol = <<"spdy/2">>,
Server = ssl_test_lib:start_server(erlang, [{from, self()}],
[{server_opts, [{next_protocols_advertised,
Expand Down Expand Up @@ -230,8 +230,8 @@ erlang_server_openssl_client_npn(Config) when is_list(Config) ->
%% [{doc,"Test erlang server with openssl client and npn negotiation with renegotiation"}].

erlang_server_openssl_client_npn_renegotiate(Config) when is_list(Config) ->
ClientOpts = proplists:get_value(client_rsa_verify_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_verify_opts, Config),
NpnProtocol = <<"spdy/2">>,
Server =
ssl_test_lib:start_server(erlang, [{from, self()}],
Expand Down Expand Up @@ -266,8 +266,8 @@ erlang_server_openssl_client_npn_renegotiate(Config) when is_list(Config) ->
ssl:close(SSocket).
%%--------------------------------------------------------------------------
erlang_client_openssl_server_npn_only_client(Config) when is_list(Config) ->
ServerOpts = proplists:get_value(server_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),

{Server, OpenSSLPort} =
ssl_test_lib:start_server(openssl, [{np,"spdy/2"}, return_port],
Expand All @@ -290,8 +290,8 @@ erlang_client_openssl_server_npn_only_client(Config) when is_list(Config) ->

%%--------------------------------------------------------------------------
erlang_client_openssl_server_npn_only_server(Config) when is_list(Config) ->
ServerOpts = proplists:get_value(server_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),

{Server, OpenSSLPort} =
ssl_test_lib:start_server(openssl, [{np,"spdy/2"}, return_port],
Expand All @@ -314,7 +314,7 @@ erlang_client_openssl_server_npn_only_server(Config) when is_list(Config) ->

%%--------------------------------------------------------------------------
erlang_server_openssl_client_npn_only_server(Config) when is_list(Config) ->
ClientOpts = proplists:get_value(client_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_verify_opts, Config),
Server =
ssl_test_lib:start_server(erlang, [{from, self()}],
Expand Down Expand Up @@ -344,8 +344,8 @@ erlang_server_openssl_client_npn_only_server(Config) when is_list(Config) ->

%%--------------------------------------------------------------------------
erlang_server_openssl_client_npn_only_client(Config) when is_list(Config) ->
ClientOpts = proplists:get_value(client_rsa_verify_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_verify_opts, Config),
ClientOpts = ssl_test_lib:ssl_options(client_rsa_verify_opts, Config),
ServerOpts = ssl_test_lib:ssl_options(server_rsa_verify_opts, Config),
Server = ssl_test_lib:start_server(erlang, [{from, self()}],
[{server_opts, [ServerOpts]} | Config]),
Port = ssl_test_lib:inet_port(Server),
Expand Down
Loading

0 comments on commit 2c05db7

Please sign in to comment.