1
+ % % This Source Code Form is subject to the terms of the Mozilla Public
2
+ % % License, v. 2.0. If a copy of the MPL was not distributed with this
3
+ % % file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
+ % %
5
+ % % Copyright (c) 2007-2025 Broadcom. All Rights Reserved. The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.
6
+ % %
7
+
8
+ -module (unit_rabbit_ssl_SUITE ).
9
+
10
+ -include_lib (" eunit/include/eunit.hrl" ).
11
+
12
+ -compile (export_all ).
13
+
14
+ all () ->
15
+ [
16
+ {group , parallel_tests }
17
+ ].
18
+
19
+ groups () ->
20
+ [
21
+ {parallel_tests , [], [
22
+ wrap_tls_opts_with_binary_password ,
23
+ wrap_tls_opts_with_function_password
24
+ ]}
25
+ ].
26
+
27
+
28
+ wrap_tls_opts_with_binary_password (_Config ) ->
29
+ Path = " /tmp/path/to/private_key.pem" ,
30
+ Bin = <<" s3krE7" >>,
31
+ Opts0 = [
32
+ {keyfile , Path },
33
+ {password , Bin }
34
+ ],
35
+
36
+ Opts = rabbit_ssl :wrap_password_opt (Opts0 ),
37
+ M = maps :from_list (Opts ),
38
+
39
+ ? assertEqual (Path , maps :get (keyfile , M )),
40
+ ? assert (is_function (maps :get (password , M ))),
41
+
42
+ F = maps :get (password , M ),
43
+ ? assertEqual (Bin , F ()),
44
+
45
+ passed .
46
+
47
+ wrap_tls_opts_with_function_password (_Config ) ->
48
+ Path = " /tmp/path/to/private_key.pem" ,
49
+ Bin = <<" s3krE7" >>,
50
+ Fun = fun () -> Bin end ,
51
+ Opts0 = [
52
+ {keyfile , Path },
53
+ {password , Fun }
54
+ ],
55
+
56
+ Opts = rabbit_ssl :wrap_password_opt (Opts0 ),
57
+ M = maps :from_list (Opts ),
58
+
59
+ ? assertEqual (Path , maps :get (keyfile , M )),
60
+ ? assert (is_function (maps :get (password , M ))),
61
+ ? assertEqual (Fun , maps :get (password , M )),
62
+
63
+ F = maps :get (password , M ),
64
+ ? assertEqual (Bin , F ()),
65
+
66
+ passed .
0 commit comments