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 12, 2024
1 parent b643f35 commit 6fe0de9
Show file tree
Hide file tree
Showing 12 changed files with 167 additions and 153 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
52 changes: 27 additions & 25 deletions lib/ssl/test/openssl_server_cert_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ init_per_group(openssl_server, Config0) ->
[{client_type, erlang}, {server_type, openssl} | Config];
init_per_group(rsa = Group, Config0) ->
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 @@ -174,26 +174,26 @@ init_per_group(rsa = Group, Config0) ->
[_|_] ->
[{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))])];
[] ->
{skip, {no_sup, Group, Version}}
end;
init_per_group(rsa_1_3 = Group, Config0) ->
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(undefined, Version),
case Ciphers of
[_|_] ->
[{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 @@ -202,7 +202,7 @@ init_per_group(rsa_1_3 = Group, Config0) ->
init_per_group(Alg, Config) when Alg == rsa_pss_rsae;
Alg == rsa_pss_pss ->
Supports = crypto:supports(),
RSAOpts = proplists:get_value(rsa_opts, Supports),
RSAOpts = ssl_test_lib:ssl_options(rsa_opts, Supports),

case lists:member(rsa_pkcs1_pss_padding, RSAOpts)
andalso lists:member(rsa_pss_saltlen, RSAOpts)
Expand All @@ -214,8 +214,8 @@ init_per_group(Alg, Config) when Alg == rsa_pss_rsae;
server_config := SOpts} = ssl_test_lib:make_rsa_pss_pem(Alg, [], Config, ""),
[{cert_key_alg, Alg} |
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, Config))])];
false ->
Expand All @@ -229,8 +229,8 @@ init_per_group(ecdsa = Group, Config0) ->
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 @@ -244,8 +244,8 @@ init_per_group(ecdsa = Group, Config0) ->
[_|_] ->
[{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 All @@ -263,17 +263,17 @@ init_per_group(ecdsa_1_3 = Group, Config0) ->
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(undefined, Version),
case Ciphers of
[_|_] ->
[{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 @@ -301,8 +301,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 @@ -317,8 +317,8 @@ init_per_group(dsa = Group, Config0) ->
of
true ->
Config = ssl_test_lib:make_dsa_cert(Config0),
COpts = proplists:get_value(client_dsa_opts, Config),
SOpts = proplists:get_value(server_dsa_opts, Config),
COpts = ssl_test_lib:ssl_options(client_dsa_opts, Config),
SOpts = 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 @@ -332,8 +332,10 @@ init_per_group(dsa = Group, Config0) ->
[_|_] ->
[{cert_key_alg, dsa} |
lists:delete(cert_key_alg,
[{client_cert_opts, [{ciphers, Ciphers} | COpts] ++ ssl_test_lib:sig_algs(dsa, Version)},
{server_cert_opts, SOpts} |
[{client_cert_opts, fun() -> [{ciphers, Ciphers} | COpts] ++
ssl_test_lib:sig_algs(dsa, Version)
end},
{server_cert_opts, fun() -> SOpts end} |
lists:delete(server_cert_opts,
lists:delete(client_cert_opts, Config))])];
[] ->
Expand Down
Loading

0 comments on commit 6fe0de9

Please sign in to comment.