Skip to content

Commit dae92ab

Browse files
authored
Merge pull request #4452 from esl/feature/listeners
Feature/listeners
2 parents 5d1c011 + 4d894fb commit dae92ab

File tree

157 files changed

+5733
-6742
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+5733
-6742
lines changed

big_tests/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ else
2424
TLS_DIST_OPTS :=
2525
endif
2626

27+
REMSH_OPTS := -setcookie mongooseim \
28+
$(TLS_DIST_OPTS)
29+
2730
COMMON_OPTS := -sname test -setcookie mongooseim -hidden \
2831
$(TLS_DIST_OPTS) \
2932
-env REPO_DIR "$(ABS_REPO_DIR)" \
@@ -72,6 +75,11 @@ test: $(PREPARE)
7275
$(RUN) erl -noinput $(COMMON_OPTS) $(ADD_OPTS) \
7376
-s run_common_test main test=full spec=$(TESTSPEC)
7477

78+
# Open remote shell to the test node
79+
remsh:
80+
erl $(REMSH_OPTS) $(ADD_OPTS) \
81+
-remsh "test@$(shell hostname -s)" -sname remshnode
82+
7583
prepare: mim_ct_rest compile vm.dist.args
7684
erlc -I_build/default/lib/exml/include \
7785
run_common_test.erl

big_tests/default.spec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@
9999
{suites, "tests", xep_0352_csi_SUITE}.
100100
{suites, "tests", domain_isolation_SUITE}.
101101
{suites, "tests", domain_removal_SUITE}.
102-
{suites, "tests", tcp_listener_SUITE}.
103102
{suites, "tests", cets_disco_SUITE}.
104103
{suites, "tests", start_node_id_SUITE}.
105104
{suites, "tests", tr_util_SUITE}.

big_tests/dynamic_domains.config

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
{cowboy_port, 5280},
2424
{cowboy_secure_port, 5285},
2525
{http_api_client_endpoint_port, 8089},
26-
{service_port, 8888},
27-
{kicking_service_port, 8666},
28-
{hidden_service_port, 8189},
26+
{component_port, 8888},
27+
{kicking_component_port, 8666},
28+
{hidden_component_port, 8189},
29+
{tls_component_port, 8190},
2930
{gd_endpoint_port, 5555},
3031
{http_notifications_port, 8000}]},
3132
{mim2, [{node, mongooseim2@localhost},
@@ -38,7 +39,7 @@
3839
{c2s_tls_port, 5233},
3940
{metrics_rest_port, 5289},
4041
{gd_endpoint_port, 6666},
41-
{service_port, 8899}]},
42+
{component_port, 8899}]},
4243
{mim3, [{node, mongooseim3@localhost},
4344
{domain, <<"domain.example.com">>},
4445
{host_type, <<"test type">>},
@@ -110,6 +111,11 @@
110111
{server, <<"domain.example.com">>},
111112
{host, <<"localhost">>},
112113
{password, <<"nicniema">>}]},
114+
{astrid, [
115+
{username, <<"astrid">>},
116+
{server, <<"sogndal">>},
117+
{host, <<"localhost">>},
118+
{password, <<"doctor">>}]},
113119
{geralt, [
114120
{username, <<"geralt">>},
115121
{server, <<"domain.example.com">>},
@@ -162,8 +168,7 @@
162168
{server, <<"domain.example.com">>},
163169
{host, <<"localhost">>},
164170
{password, <<"scramshaplus">>},
165-
{starttls, required},
166-
{tls_module, fast_tls}]},
171+
{starttls, required}]},
167172
{hacker, [
168173
{username, <<"hacker">>},
169174
{server, <<"domain.example.com">>},

big_tests/dynamic_domains.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@
9999
{suites, "tests", xep_0352_csi_SUITE}.
100100
{suites, "tests", domain_removal_SUITE}.
101101
{suites, "tests", local_iq_SUITE}.
102-
{suites, "tests", tcp_listener_SUITE}.
103102
{suites, "tests", cets_disco_SUITE}.
104103
{suites, "tests", start_node_id_SUITE}.
105104
{suites, "tests", tr_util_SUITE}.
@@ -108,6 +107,7 @@
108107
%% to minimise impact on other tests
109108
{suites, "tests", auth_methods_for_c2s_SUITE}.
110109
{suites, "tests", cluster_commands_SUITE}.
110+
{suites, "tests", component_SUITE}.
111111
{suites, "tests", dynamic_domains_SUITE}.
112112
{suites, "tests", graphql_server_SUITE}.
113113
{suites, "tests", last_SUITE}.

big_tests/rebar.config

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@
1414
{proper, "1.4.0"},
1515
{gun, "2.1.0"},
1616
{fusco, "0.1.1"},
17-
{escalus, "4.3.0"},
18-
%% We need to override `escalus` scram version, because 4.4 removes `fast_tls`, which is not
19-
%% supported in master yet. When we can upgrade escalus, we can remove the explicit
20-
%% `fast_scram` declaration from here.
21-
{fast_scram, "0.7.0"},
17+
{escalus, "4.4.1"},
2218
{cowboy, "2.12.0"},
2319
{csv, "3.0.3", {pkg, csve}},
2420
{amqp_client, "4.0.3"},

big_tests/rebar.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
{<<"ct_groups_summary_hook">>,
1111
{pkg,<<"ct_groups_summary_hook">>,<<"0.1.1">>},
1212
0},
13-
{<<"escalus">>,{pkg,<<"escalus">>,<<"4.3.0">>},0},
13+
{<<"escalus">>,{pkg,<<"escalus">>,<<"4.4.1">>},0},
1414
{<<"esip">>,{pkg,<<"esip">>,<<"1.0.56">>},0},
1515
{<<"exml">>,{pkg,<<"hexml">>,<<"4.1.1">>},0},
1616
{<<"fast_pbkdf2">>,{pkg,<<"fast_pbkdf2">>,<<"2.0.0">>},1},
1717
{<<"fast_scram">>,{pkg,<<"fast_scram">>,<<"0.7.0">>},0},
18-
{<<"fast_tls">>,{pkg,<<"fast_tls">>,<<"1.1.21">>},1},
18+
{<<"fast_tls">>,{pkg,<<"fast_tls">>,<<"1.1.22">>},1},
1919
{<<"fusco">>,{pkg,<<"fusco">>,<<"0.1.1">>},0},
2020
{<<"gun">>,{pkg,<<"gun">>,<<"2.1.0">>},0},
2121
{<<"jid">>,{pkg,<<"mongoose_jid">>,<<"2.2.0">>},0},
@@ -42,12 +42,12 @@
4242
{<<"credentials_obfuscation">>, <<"34E18B126B3AEFD6E8143776FBE1CECEEA6792307C99AC5EE8687911F048CFD7">>},
4343
{<<"csv">>, <<"69E7D9B3FDC72016644368762C6A3E6CBFEB85BCCADBF1BD99AB6C827E360E04">>},
4444
{<<"ct_groups_summary_hook">>, <<"21B94902B6CF2D345F4D790D34B49654E71CB8E570DCCC9C1C3616DAE720A7AA">>},
45-
{<<"escalus">>, <<"80301D57F4C863FA95F09AE148524508F18D7389B5070E2A5FFB7A38B51527C5">>},
45+
{<<"escalus">>, <<"B32CC182F2246BA7B8B2853FF3A5A28F0F822540965053A7D3EF2894E0B17B5A">>},
4646
{<<"esip">>, <<"63C0FDC667BE751714E1E5C14621A9334F21B60AC1BB68BE889454CA9CA021B7">>},
4747
{<<"exml">>, <<"D46272177F3B779D75058005C744997034823AB3A237F9B30B56A583B063FDE3">>},
4848
{<<"fast_pbkdf2">>, <<"72CDEE3C10C6B9B40E31194DE946A883CEEF6CF1F37D7FC9FD1A9D87502723F5">>},
4949
{<<"fast_scram">>, <<"FAD4DD185E0DEFA34B0E30654AB0CC4048E9324BCF65BB261E0A86BF3C604F9F">>},
50-
{<<"fast_tls">>, <<"65D7D547A09EEFB37A1C0D04D8601FAC4F3E6E2C1EDE859A7787081670F9648D">>},
50+
{<<"fast_tls">>, <<"44356B256AFAD4399C2FC5059A3066669DAFD8BD4E4E796C9C1CF8910DDD265E">>},
5151
{<<"fusco">>, <<"3DD6A90151DFEF30EA1937CC44E9A59177C0094918388D9BCAA2F2DC5E2AE4AA">>},
5252
{<<"gun">>, <<"B4E4CBBF3026D21981C447E9E7CA856766046EFF693720BA43114D7F5DE36E87">>},
5353
{<<"jid">>, <<"3761535829A0DBA5A6BBDF2EE6EA7BCD9A8F1ADA201EDB4D79E1E2B47D5FD3D6">>},
@@ -73,12 +73,12 @@
7373
{<<"credentials_obfuscation">>, <<"738ACE0ED5545D2710D3F7383906FC6F6B582D019036E5269C4DBD85DBCED566">>},
7474
{<<"csv">>, <<"741D1A55AABADAA3E0FE13051050101A73E90C4570B9F9403A939D9546813521">>},
7575
{<<"ct_groups_summary_hook">>, <<"997CDE48FEB0C398989E4091A341D4FFF43CFA06CDB8FB2E80CC4A0E0362691C">>},
76-
{<<"escalus">>, <<"8C4D39677D55C48B04EDE4EAC0FD0AD2A574BEDE7180761E6E3D3877900C7708">>},
76+
{<<"escalus">>, <<"3389CF597E87F6C48314C4445B4B25A2678983B11C87A5C2308191A3BDA2F85A">>},
7777
{<<"esip">>, <<"9EF3660CEF93B623F7368DCD5C79F4E704358631909E6DD464E335378815DA1F">>},
7878
{<<"exml">>, <<"86C154396A9B21EEB0EDB9636D0E2D493FE0F59EAAF40FCFE795210F31119D8F">>},
7979
{<<"fast_pbkdf2">>, <<"74159FD09FB8BF5E97D25137C6C83C28E2CF7E97D7C127D83310DFD0904BD732">>},
8080
{<<"fast_scram">>, <<"39CB1D4C91C99E637E000A3864D274D8A9CB43D86EEC2495FE9546798DBFA015">>},
81-
{<<"fast_tls">>, <<"131542913937025E48CD80AA81F00359686D5501B75621E72026A87B5229505B">>},
81+
{<<"fast_tls">>, <<"E65779AEFB7AB15C4755230FEF8077E687D20CC5A3984A5974F9F657E8E2485B">>},
8282
{<<"fusco">>, <<"6343551BD1E824F2A6CA85E1158C5B37C320FD449FBFEC7450A73F192AAF9022">>},
8383
{<<"gun">>, <<"52FC7FC246BFC3B00E01AEA1C2854C70A366348574AB50C57DFE796D24A0101D">>},
8484
{<<"jid">>, <<"0F2C69E4C142E21E7D87E6D70AC62ECF6EB00E97C86CF8CBF6BAD4B3BE8B0545">>},

big_tests/test.config

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@
3535
{cowboy_port, 5280},
3636
{cowboy_secure_port, 5285},
3737
{http_api_client_endpoint_port, 8089},
38-
{service_port, 8888},
39-
{kicking_service_port, 8666},
40-
{hidden_service_port, 8189},
38+
{component_port, 8888},
39+
{kicking_component_port, 8666},
40+
{hidden_component_port, 8189},
41+
{tls_component_port, 8190},
4142
{gd_endpoint_port, 5555},
4243
{http_notifications_port, 8000},
4344
{blocks_hosts, [reg]}]},
@@ -48,7 +49,7 @@
4849
{cluster, mim},
4950
{c2s_tls_port, 5233},
5051
{gd_endpoint_port, 6666},
51-
{service_port, 8899}]},
52+
{component_port, 8899}]},
5253
{mim3, [{node, mongooseim3@localhost},
5354
{domain, <<"localhost">>},
5455
{host_type, <<"localhost">>},
@@ -69,7 +70,7 @@
6970
{domain, <<"reg1">>},
7071
{host_type, <<"red1">>},
7172
{vars, "reg1"},
72-
{service_port, 9990},
73+
{component_port, 9990},
7374
{c2s_port, 5252},
7475
{gd_endpoint_port, 7777},
7576
{gd_extra_endpoint_port, 10000},
@@ -210,8 +211,7 @@
210211
{server, <<"localhost">>},
211212
{host, <<"localhost">>},
212213
{password, <<"scramshaplus">>},
213-
{starttls, required},
214-
{tls_module, fast_tls}
214+
{starttls, required}
215215
]},
216216
{alice3, [ %% used in dynamic_domains_SUITE
217217
{username, <<"alice">>},

big_tests/tests/bosh_SUITE.erl

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ acks_test_cases() ->
107107
%%--------------------------------------------------------------------
108108

109109
init_per_suite(Config) ->
110-
instrument_helper:start(instrumentation_events(), negative_instrumentation_events()),
110+
instrument_helper:start(instrumentation_events()),
111111
Config1 = dynamic_modules:save_modules(host_type(), Config),
112112
escalus:init_per_suite([{escalus_user_db, {module, escalus_ejabberd}} | Config1]).
113113

@@ -195,9 +195,6 @@ create_and_terminate_session(Config) ->
195195
[instrument_helper:assert(Event, Label, fun(#{byte_size := BS}) -> BS > 0 end)
196196
|| {Event, Label} <- instrumentation_events(), Event =/= c2s_message_processed],
197197

198-
%% Verify C2S listener is not used
199-
instrument_helper:assert_not_emitted(negative_instrumentation_events()),
200-
201198
%% Assert the session was terminated.
202199
wait_for_zero_bosh_sessions().
203200

@@ -952,14 +949,6 @@ wait_for_zero_bosh_sessions() ->
952949

953950
instrumentation_events() ->
954951
instrument_helper:declared_events(mod_bosh, [])
955-
++ instrument_helper:declared_events(mongoose_c2s, [global])
956-
++ [{c2s_message_processed, #{host_type => host_type()}}].
957-
958-
negative_instrumentation_events() ->
959-
[{Name, #{}} || Name <- negative_instrumentation_events_names()].
960-
961-
negative_instrumentation_events_names() ->
962-
[c2s_tcp_data_out,
963-
c2s_tcp_data_in,
964-
c2s_tls_data_out,
965-
c2s_tls_data_in].
952+
++ [{c2s_message_processed, #{host_type => domain_helper:host_type()}},
953+
{xmpp_element_size_out, #{connection_type => c2s}, #{metrics => #{byte_size => histogram}}},
954+
{xmpp_element_size_in, #{connection_type => c2s}, #{metrics => #{byte_size => histogram}}}].

big_tests/tests/ca_certificate_helper.erl

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,12 @@ generate_cert(Config, #{cn := User} = CertSpec, BasicTemplateValues) ->
1414
ct:log("OpenSSL config: ~ts~n~ts", [UserConfig, OpenSSLConfig]),
1515
file:write_file(UserConfig, OpenSSLConfig),
1616
UserKey = filename:join(?config(priv_dir, Config), User ++ "_key.pem"),
17+
MaybeCritical = maps:get(with_critical_extension, CertSpec, false),
1718
case maps:get(signed, CertSpec, ca) of
18-
ca -> generate_ca_signed_cert(Config, User, UserConfig, UserKey);
19-
self -> generate_self_signed_cert(Config, User, UserConfig, UserKey)
19+
ca ->
20+
generate_ca_signed_cert(Config, User, UserConfig, UserKey, MaybeCritical);
21+
self ->
22+
generate_self_signed_cert(Config, User, UserConfig, UserKey, MaybeCritical)
2023
end.
2124

2225
prepare_template_values(User, XMPPAddrsIn) ->
@@ -35,11 +38,12 @@ make_xmpp_addr_entry(I, Addr) ->
3538
"otherName." ++ integer_to_list(I) ++ " = id-on-xmppAddr;UTF8:" ++ Addr.
3639

3740

38-
generate_ca_signed_cert(Config, Filename, ConfigCfg, KeyFilename) ->
41+
generate_ca_signed_cert(Config, Filename, ConfigCfg, KeyFilename, MaybeCritical) ->
3942
Csr = filename:join(?config(priv_dir, Config), Filename ++ ".csr"),
4043
Cmd = ["openssl req -config ", ConfigCfg, " -newkey rsa:2048 -sha256 -nodes -out ",
41-
Csr, " -keyout ", KeyFilename, " -outform PEM"],
42-
Out = os:cmd(Cmd),
44+
Csr, " -keyout ", KeyFilename, " -outform PEM" | extensions(ca_signed, MaybeCritical)],
45+
Out = os:cmd(Cmd ++ " && echo CREATED"),
46+
verify_created(Cmd, Out),
4347
ct:log("generate_ca_signed_cert 1:~nCmd ~p~nOut ~ts", [Cmd, Out]),
4448
Cert = filename:join(?config(priv_dir, Config), Filename ++ "_cert.pem"),
4549
SignCmd = filename:join(?config(mim_data_dir, Config), "sign_cert.sh"),
@@ -50,11 +54,29 @@ generate_ca_signed_cert(Config, Filename, ConfigCfg, KeyFilename) ->
5054
#{key => KeyFilename,
5155
cert => Cert}.
5256

53-
generate_self_signed_cert(Config, Filename, ConfigCfg, KeyFilename) ->
57+
generate_self_signed_cert(Config, Filename, ConfigCfg, KeyFilename, MaybeCritical) ->
5458
Cert = filename:join(?config(priv_dir, Config), Filename ++ "_self_signed_cert.pem"),
5559
Cmd = ["openssl req -config ", ConfigCfg, " -newkey rsa:2048 -sha256 -nodes -out ",
56-
Cert, " -keyout ", KeyFilename, " -x509 -outform PEM -extensions client_req_extensions"],
57-
OutLog = os:cmd(Cmd),
60+
Cert, " -keyout ", KeyFilename, " -x509 -outform PEM", extensions(self_signed, MaybeCritical)],
61+
OutLog = os:cmd(Cmd ++ " && echo CREATED"),
62+
verify_created(Cmd, OutLog),
5863
ct:log("generate_self_signed_cert:~nCmd ~p~nOut ~ts", [Cmd, OutLog]),
5964
#{key => KeyFilename,
6065
cert => Cert}.
66+
67+
verify_created(Cmd, Output) ->
68+
case lists:suffix("CREATED\n", Output) of
69+
true ->
70+
ok;
71+
false ->
72+
ct:fail({failed_to_create_certificate, Cmd, Output})
73+
end.
74+
75+
extensions(ca_signed, false) ->
76+
[];
77+
extensions(ca_signed, true) ->
78+
" -extensions critical_extensions";
79+
extensions(self_signed, false) ->
80+
" -extensions client_req_extensions";
81+
extensions(self_signed, true) ->
82+
" -extensions self_signed_critical_extensions".

0 commit comments

Comments
 (0)