Improve rabbit_ssl:wrap_password_opt/1 tests
This commit is contained in:
parent
9931386f05
commit
67ee867a7c
|
@ -27,9 +27,10 @@ groups() ->
|
||||||
|
|
||||||
wrap_tls_opts_with_binary_password(_Config) ->
|
wrap_tls_opts_with_binary_password(_Config) ->
|
||||||
Path = "/tmp/path/to/private_key.pem",
|
Path = "/tmp/path/to/private_key.pem",
|
||||||
|
Bin = <<"s3krE7">>,
|
||||||
Opts0 = [
|
Opts0 = [
|
||||||
{keyfile, Path},
|
{keyfile, Path},
|
||||||
{password, <<"s3krE7">>}
|
{password, Bin}
|
||||||
],
|
],
|
||||||
|
|
||||||
Opts = rabbit_ssl:wrap_password_opt(Opts0),
|
Opts = rabbit_ssl:wrap_password_opt(Opts0),
|
||||||
|
@ -38,11 +39,15 @@ wrap_tls_opts_with_binary_password(_Config) ->
|
||||||
?assertEqual(Path, maps:get(keyfile, M)),
|
?assertEqual(Path, maps:get(keyfile, M)),
|
||||||
?assert(is_function(maps:get(password, M))),
|
?assert(is_function(maps:get(password, M))),
|
||||||
|
|
||||||
|
F = maps:get(password, M),
|
||||||
|
?assertEqual(Bin, F()),
|
||||||
|
|
||||||
passed.
|
passed.
|
||||||
|
|
||||||
wrap_tls_opts_with_function_password(_Config) ->
|
wrap_tls_opts_with_function_password(_Config) ->
|
||||||
Path = "/tmp/path/to/private_key.pem",
|
Path = "/tmp/path/to/private_key.pem",
|
||||||
Fun = fun() -> <<"s3krE7">> end,
|
Bin = <<"s3krE7">>,
|
||||||
|
Fun = fun() -> Bin end,
|
||||||
Opts0 = [
|
Opts0 = [
|
||||||
{keyfile, Path},
|
{keyfile, Path},
|
||||||
{password, Fun}
|
{password, Fun}
|
||||||
|
@ -55,4 +60,7 @@ wrap_tls_opts_with_function_password(_Config) ->
|
||||||
?assert(is_function(maps:get(password, M))),
|
?assert(is_function(maps:get(password, M))),
|
||||||
?assertEqual(Fun, maps:get(password, M)),
|
?assertEqual(Fun, maps:get(password, M)),
|
||||||
|
|
||||||
|
F = maps:get(password, M),
|
||||||
|
?assertEqual(Bin, F()),
|
||||||
|
|
||||||
passed.
|
passed.
|
Loading…
Reference in New Issue