@@ -128,45 +128,38 @@ suite() ->
128128
129129init_per_suite (Config ) ->
130130 Config0 = escalus :init_per_suite ([{escalus_user_db , {module , escalus_ejabberd , []}} | Config ]),
131- Config1 = ejabberd_node_utils :init (Config0 ),
132- ejabberd_node_utils :backup_config_file (Config1 ),
131+ C2SPort = ct :get_config ({hosts , mim , c2s_port }),
132+ [{_ , ejabberd_c2s , _ } = C2SListener ] = mongoose_helper :get_listener_opts (mim (), C2SPort ),
133+ Config1 = [{c2s_listener , C2SListener } | Config0 ],
133134 assert_cert_file_exists (),
134135 escalus :create_users (Config1 , escalus :get_users ([? SECURE_USER , alice ])).
135136
136137end_per_suite (Config ) ->
137138 escalus_fresh :clean (),
138139 escalus :delete_users (Config , escalus :get_users ([? SECURE_USER , alice ])),
139- restore_ejabberd_node (Config ),
140+ restore_c2s_listener (Config ),
140141 escalus :end_per_suite (Config ).
141142
142143init_per_group (c2s_noproc , Config ) ->
143- config_ejabberd_node_tls (Config ,
144- fun mk_value_for_starttls_config_pattern /0 ),
145- ejabberd_node_utils :restart_application (mongooseim ),
144+ config_ejabberd_node_c2s (Config , [starttls ]),
146145 Config ;
147146init_per_group (session_replacement , Config ) ->
148- config_ejabberd_node_tls (Config ,
149- fun mk_value_for_starttls_config_pattern /0 ),
150- ejabberd_node_utils :restart_application (mongooseim ),
147+ config_ejabberd_node_c2s (Config , [starttls ]),
151148 lager_ct_backend :start (),
152149 Config ;
153150init_per_group (starttls , Config ) ->
154- config_ejabberd_node_tls (Config ,
155- fun mk_value_for_starttls_required_config_pattern /0 ),
156- ejabberd_node_utils :restart_application (mongooseim ),
151+ config_ejabberd_node_c2s (Config , [starttls_required ]),
157152 Config ;
158153init_per_group (tls , Config ) ->
159- config_ejabberd_node_tls (Config , fun mk_value_for_tls_config_pattern /0 ),
160- ejabberd_node_utils :restart_application (mongooseim ),
154+ config_ejabberd_node_c2s (Config , [tls ]),
161155 Users = proplists :get_value (escalus_users , Config , []),
162156 JoeSpec = lists :keydelete (starttls , 1 , proplists :get_value (? SECURE_USER , Users )),
163157 JoeSpec2 = {? SECURE_USER , lists :keystore (ssl , 1 , JoeSpec , {ssl , true })},
164158 NewUsers = lists :keystore (? SECURE_USER , 1 , Users , JoeSpec2 ),
165159 Config2 = lists :keystore (escalus_users , 1 , Config , {escalus_users , NewUsers }),
166160 [{c2s_port , ct :get_config ({hosts , mim , c2s_port })} | Config2 ];
167161init_per_group (feature_order , Config ) ->
168- config_ejabberd_node_tls (Config , fun mk_value_for_compression_config_pattern /0 ),
169- ejabberd_node_utils :restart_application (mongooseim ),
162+ config_ejabberd_node_c2s (Config , [starttls_required , {zlib , 10000 }]),
170163 Config ;
171164init_per_group (just_tls ,Config )->
172165 [{tls_module , just_tls } | Config ];
@@ -175,9 +168,7 @@ init_per_group(fast_tls,Config)->
175168init_per_group (session_replacement , Config ) ->
176169 Config ;
177170init_per_group (proxy_protocol , Config ) ->
178- % % Use 'tls_config' to add the listener option for the proxy protocol
179- ejabberd_node_utils :modify_config_file ([{tls_config , " {proxy_protocol, true}," }], Config ),
180- ejabberd_node_utils :restart_application (mongooseim ),
171+ config_ejabberd_node_c2s (Config , [{proxy_protocol , true }]),
181172 Config ;
182173init_per_group (_ , Config ) ->
183174 Config .
@@ -331,7 +322,6 @@ clients_can_connect_with_advertised_ciphers(Config) ->
331322 ? assert (length (ciphers_working_with_ssl_clients (Config )) > 0 ).
332323
333324'clients_can_connect_with_ECDHE-RSA-AES256-GCM-SHA384' (Config ) ->
334-
335325 ? assert (lists :member (" ECDHE-RSA-AES256-GCM-SHA384" ,
336326 ciphers_working_with_ssl_clients (Config ))).
337327
@@ -763,31 +753,29 @@ openssl_client_can_use_cipher(Cipher, Port) ->
763753 {done , ReturnCode , _Result } = erlsh :oneliner (Cmd ),
764754 0 == ReturnCode .
765755
766- restore_ejabberd_node (Config ) ->
767- ejabberd_node_utils : restore_config_file ( Config ),
768- ejabberd_node_utils : restart_application ( mongooseim ).
756+ restore_c2s_listener (Config ) ->
757+ { _ , _ , Opts } = C2SListener = ? config ( c2s_listener , Config ),
758+ mongoose_helper : restart_listener_with_opts ( mim (), C2SListener , Opts ).
769759
770760assert_cert_file_exists () ->
771761 ejabberd_node_utils :file_exists (? CERT_FILE ) orelse
772762 ct :fail (" cert file ~s not exists" , [? CERT_FILE ]).
773763
774- config_ejabberd_node_tls (Config , Fun ) ->
775- TLSModConf = " {tls_module," ++ atom_to_list (? config (tls_module , Config )) ++ " }," ,
776- ejabberd_node_utils :modify_config_file ([Fun (), {tls_module , TLSModConf }], Config ).
777-
778- mk_value_for_starttls_config_pattern () ->
779- {tls_config , " {certfile, \" " ++ ? CERT_FILE ++ " \" }, starttls," }.
780-
781- mk_value_for_tls_config_pattern () ->
782- {tls_config , " {certfile, \" " ++ ? CERT_FILE ++ " \" }, tls," }.
783-
784- mk_value_for_compression_config_pattern () ->
785- {tls_config , " {certfile, \" " ++ ? CERT_FILE ++ " \" }, " ++
786- " starttls_required, {zlib, 10000}," }.
787-
788- mk_value_for_starttls_required_config_pattern () ->
789- {tls_config , " {certfile, \" " ++ ? CERT_FILE ++ " \" }, " ++
790- " starttls_required, {dhfile, \" " ++ ? DH_FILE ++ " \" }," }.
764+ config_ejabberd_node_c2s (Config , ExtraC2SOpts ) ->
765+ Opts = ExtraC2SOpts ++ common_c2s_opts (Config ),
766+ C2SListener = ? config (c2s_listener , Config ),
767+ mongoose_helper :restart_listener_with_opts (mim (), C2SListener , Opts ).
768+
769+ common_c2s_opts (Config ) ->
770+ TLSModule = ? config (tls_module , Config ),
771+ [{tls_module , TLSModule },
772+ {certfile , ? CERT_FILE },
773+ % starttls,
774+ % {zlib, 10000},
775+ {access , c2s },
776+ {shaper , c2s_shaper },
777+ {max_stanza_size , 65536 },
778+ {dhfile , " priv/ssl/fake_dh_server.pem" }].
791779
792780set_secure_connection_protocol (UserSpec , Version ) ->
793781 [{ssl_opts , [{versions , [Version ]}]} | UserSpec ].
0 commit comments