MIM-2647 Entity Capabilities 2.0 (XEP-0390)#4666
Conversation
|
CircleCI results for 9ffe0d4 elasticsearch_and_cassandra_latest / elasticsearch_and_cassandra_mnesia / fca7f70 small_tests_legacy / small_tests / fca7f70 small_tests_latest / small_tests / fca7f70 small_tests_latest_arm64 / small_tests / fca7f70 ldap_mnesia_legacy / ldap_mnesia / fca7f70 ldap_mnesia_latest / ldap_mnesia / fca7f70 dynamic_domains_pgsql_mnesia_legacy / pgsql_mnesia / fca7f70 dynamic_domains_pgsql_mnesia_latest / pgsql_mnesia / fca7f70 dynamic_domains_mysql_redis_latest / mysql_redis / 1fdb216 internal_mnesia_latest / internal_mnesia / fca7f70 pgsql_cets_latest / pgsql_cets / fca7f70 pgsql_mnesia_legacy / pgsql_mnesia / 1fdb216 connect_SUITE:session_replacement:replaced_session_cannot_terminate_different_nodes{skip,
{failed,
{connect_SUITE,init_per_testcase,
{{verify_result,[],
[{times,20,
[{#{node => mongooseim2@localhost},
[mongooseim@localhost],
true},
{#{node => mongooseim@localhost},
[mongooseim2@localhost],
true}]}],
undefined},
[{wait_helper,do_wait_until,1,
[{file,
"/home/circleci/project/big_tests/_build/default/lib/wait_helper/src/wait_helper.erl"},
{line,127}]},
{distributed_helper,verify_result,2,
[{file,
"/home/circleci/project/big_tests/../test/common/distributed_helper.erl"},
{line,75}]},
{distributed_helper,add_node_to_cluster,2,
[{file,
"/home/circleci/project/big_tests/../test/common/distributed_helper.erl"},
{line,39}]},
{connect_SUITE,init_per_testcase,2,
[{file,
"/home/circleci/project/big_tests/tests/connect_SUITE.erl"},
{line,216}]},
{test_server,do_init_per_testcase,2,
[{file,"test_server.erl"},{line,1564}]},
{test_server,run_test_case_eval1,6,
[{file,"test_server.erl"},{line,1265}]},
{test_server,run_test_case_eval,9,
[{file,"test_server.erl"},{line,1235}]}]}}}}cockroachdb_cets_latest / cockroachdb_cets / fca7f70 pgsql_mnesia_latest / pgsql_mnesia / fca7f70 mysql_redis_latest / mysql_redis / fca7f70 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feature/caps #4666 +/- ##
================================================
+ Coverage 85.40% 85.73% +0.33%
================================================
Files 555 549 -6
Lines 33232 33189 -43
================================================
+ Hits 28382 28455 +73
+ Misses 4850 4734 -116 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
9a81f68 to
e0f902b
Compare
There was a problem hiding this comment.
Pull request overview
Adds support for XEP-0390 (Entity Capabilities 2.0) alongside existing XEP-0115 caps handling, including new hashing/encoding logic, configurable protocol versions, and updated unit/big tests.
Changes:
- Extend
mod_capsto advertise/process both caps v1 (XEP-0115) and caps v2 (XEP-0390), withversionsconfig to control accepted/advertised versions. - Rework
mod_caps_hashto support versioned encoding rules and additional hash algorithms (SHA3, SHAKE, BLAKE2b, etc.). - Update CT suites and big tests (including test data XML) to cover v1/v2 behavior and error cases; switch big-tests’
escalusdependency to a git branch.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/caps/mod_caps.erl |
Add v2 caps extraction/advertising, versioned server hash generation, and versioned hash verification. |
src/caps/mod_caps_hash.erl |
Implement versioned caps encoding and broaden supported hash algorithms. |
include/mongoose_ns.hrl |
Add namespaces for XEP-0390 caps (NS_CAPS_2) and XEP-0300 hashes (NS_HASH). |
doc/modules/mod_caps.md |
Document XEP-0390 support and new modules.mod_caps.versions option. |
test/mod_caps_SUITE.erl |
Expand hashing tests across v1/v2, add special-case validation tests, and refactor fixtures. |
test/mod_caps_SUITE_data/simple_response.xml |
Adjust XML fixture root to be <query/> only. |
test/mod_caps_SUITE_data/simple_response_2.xml |
Add XEP-0390 “simple” example fixture. |
test/mod_caps_SUITE_data/complex_response.xml |
Adjust XML fixture root to be <query/> only and reorder elements for sorting coverage. |
test/mod_caps_SUITE_data/complex_response_2.xml |
Add XEP-0390 “complex” example fixture. |
test/config_parser_SUITE.erl |
Add parsing coverage for modules.mod_caps.versions and reject invalid versions. |
test/config_parser_SUITE_data/modules.toml |
Add versions = ["v2"] example for mod_caps. |
test/common/config_parser_helper.erl |
Extend default/all-modules mod_caps configs with versions. |
big_tests/tests/pep_SUITE.erl |
Update caps helper calls to pass explicit caps version (v1). |
big_tests/tests/disco_and_caps_SUITE.erl |
Split big tests into caps v1/v2 groups and add new server/client error-path scenarios. |
big_tests/tests/caps_helper.erl |
Add caps version support for generated caps stanzas and hashing RPC. |
big_tests/rebar.config |
Switch escalus dependency from hex version to a git branch. |
big_tests/rebar.lock |
Remove escalus pkg lock entry (currently leaving the lock inconsistent with rebar.config). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Introduce a new 'versions' option with a list of supported versions. XEP-0115 becomes v1, and XEP-0390 becomes v2. - Add the corresponding caps features to disco responses. - Fix the issue, where a query to an invalid node would still return the caps namespace. - Advertise the corresponding server capabilities in stream features. - Consume and verify the corresponding client capabilities. - Attempt to request caps from the client in the order of configured versions. - Pass the version to the hash generating API.
- Rework encoding to implement the common part only once.
- Add detailed description and comments on all protocol details.
- Try to support both XEPs whenever possible:
v1: becomes more strict than before, but all within XEP-0115.
v2: in line with XEP-0390 except some cases listed in 'moduledoc'.
- Support more hashing functions. Skip ones not supported in Erlang.
- Make the check for supported algorithms more robust,
because some hashing algorithms are not supported e.g. in older
LibreSSL versions.
- Add examples from XEP-0390; adjust the XEP-0115 ones for consistency - Shuffle the complex responses more thoroughly to check sorting - Perform hashing tests for both v1 and v2 - Test all supported hashing algorithms. - Check the corner cases for v1 and v2, and document the tested behaviour with sources.
- Extract reusable helpers to escalus. - Run caps tests in disco_and_caps_SUITE for v1 and v2. Both versions are enabled on the server (as by default), and the client decides which one to use. - Check some previously missed corner cases: 1) Ask for the server capabilities with a malformed/incorrect node 2) Respond to the disco#info request with invalid elements
|
Nice and clean. Just a couple of cosmetic issues, feel free to ignore. |
This PR adds support for XEP-0390: Entity Capabilities 2.0 while updating the support for XEP-0115.
The following
mod_capsversion notation is now used in the code, tests and docs:v1implements XEP-0115.v2implements XEP-0390.Changes
v2support inmod_capsandmod_caps_hash, and protocol document details and deviations.modules.mod_caps.versionsconfig option with docs and tests.mod_caps_SUITEto testv1andv2hashing, and add tests for special cases with detailed docs.v1/v2, and add tests for corner cases.More details in commit messages and comments/docs in the code.
Notes:
escalusis temporarily used from Add utilities for XEP-0115 and XEP-0390 escalus#287, and this commit needs updating after releasing the new version ofescalus. This is why this PR is still a draft.mongoose_data_formscould provide more validation, e.g. for duplicate fields (currently, last one wins) or for ensuringFORM_TYPEis hidden. We could think of such extensions later.