@@ -30,6 +30,7 @@ groups() ->
3030 decrypt_start_app_undefined ,
3131 decrypt_start_app_wrong_passphrase ,
3232 decrypt_config ,
33+ decrypt_config_map ,
3334 rabbitmqctl_encode
3435 ]}
3536 ].
@@ -105,6 +106,33 @@ do_decrypt_config(Algo = {C, H, I, P}) ->
105106 ok = application :unload (rabbit ),
106107 ok .
107108
109+ decrypt_config_map (_Config ) ->
110+ Hashes = rabbit_pbe :supported_hashes () -- ? SKIPPED_HASHES ,
111+ Ciphers = rabbit_pbe :supported_ciphers () -- ? SKIPPED_CIPHERS ,
112+ Iterations = [1 , 100 , 1000 ],
113+ _ = [begin
114+ PassPhrase = crypto :strong_rand_bytes (16 ),
115+ do_decrypt_config_map ({C , H , I , PassPhrase })
116+ end || H <- Hashes , C <- Ciphers , I <- Iterations ],
117+ ok .
118+
119+ % % Verifies that encrypted values nested inside maps are decrypted,
120+ % % as required by e.g. rabbitmq_management.oauth_resource_servers.
121+ do_decrypt_config_map ({C , H , I , P } = Algo ) ->
122+ case application :load (rabbit ) of
123+ ok -> ok ;
124+ {error , {already_loaded , rabbit }} -> ok
125+ end ,
126+ Secret = <<" test_oauth_secret" >>,
127+ {encrypted , EncSecret } = rabbit_pbe :encrypt_term (C , H , I , P , Secret ),
128+ application :set_env (rabbit , test_map_decrypt ,
129+ #{<<" server" >> => [{oauth_client_secret , {encrypted , EncSecret }}]}),
130+ rabbit_prelaunch_conf :decrypt_config ([rabbit ], Algo ),
131+ {ok , Decrypted } = application :get_env (rabbit , test_map_decrypt ),
132+ Secret = proplists :get_value (oauth_client_secret , maps :get (<<" server" >>, Decrypted )),
133+ application :unset_env (rabbit , test_map_decrypt ),
134+ ok .
135+
108136encrypt_value (Key , {C , H , I , P }) ->
109137 {ok , Value } = application :get_env (rabbit , Key ),
110138 {encrypted , EncValue } = rabbit_pbe :encrypt_term (C , H , I , P , Value ),
0 commit comments