Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL error handling in MUC Light #3881

Merged
merged 7 commits into from
Dec 6, 2022

Conversation

chrzaszcz
Copy link
Member

@chrzaszcz chrzaszcz commented Nov 30, 2022

The main goal is to handle the error cases:

  • Non-existent users shouldn't be room owners or message senders, and they shouldn't be able to have blocking lists.
  • 'Room not found' should be returned if the room does not exist.

Other functional changes:

  • Name and subject are not required, because they shouldn't be. They have defaults, and they can be removed by the used in a custom room config schema.
  • Only room owner should be able to kick room members.
  • Room JID is always bare in the schema. User JID's are not required to be bare if this doesn't break anything. The resources are mostly ignored.
  • Update required modules and protected domains in the schema.

Operations are broken into reusable steps, and a fold operation is used to iterate over them.

@mongoose-im

This comment was marked as outdated.

@codecov
Copy link

codecov bot commented Nov 30, 2022

Codecov Report

Base: 83.15% // Head: 83.15% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (9788b67) compared to base (29e8228).
Patch coverage: 99.38% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3881   +/-   ##
=======================================
  Coverage   83.15%   83.15%           
=======================================
  Files         535      535           
  Lines       34202    34220   +18     
=======================================
+ Hits        28440    28456   +16     
- Misses       5762     5764    +2     
Impacted Files Coverage Δ
src/muc_light/mod_muc_light_api.erl 98.63% <99.12%> (+1.45%) ⬆️
...dmin/mongoose_graphql_muc_light_admin_mutation.erl 100.00% <100.00%> (ø)
...l/admin/mongoose_graphql_muc_light_admin_query.erl 100.00% <100.00%> (ø)
src/graphql/mongoose_graphql_muc_light_helper.erl 100.00% <100.00%> (ø)
.../user/mongoose_graphql_muc_light_user_mutation.erl 100.00% <100.00%> (ø)
...hql/user/mongoose_graphql_muc_light_user_query.erl 100.00% <100.00%> (ø)
...ongoose_admin_api/mongoose_admin_api_muc_light.erl 100.00% <100.00%> (ø)
.../mongoose_client_api/mongoose_client_api_rooms.erl 98.50% <100.00%> (+0.02%) ⬆️
..._client_api/mongoose_client_api_rooms_messages.erl 100.00% <100.00%> (ø)
...ose_client_api/mongoose_client_api_rooms_users.erl 100.00% <100.00%> (ø)
... and 12 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@chrzaszcz chrzaszcz force-pushed the graphql-error-handling-muc-light branch from f2030b0 to b61863b Compare November 30, 2022 15:22
@mongoose-im

This comment was marked as outdated.

@chrzaszcz chrzaszcz force-pushed the graphql-error-handling-muc-light branch from b61863b to 0611c6f Compare November 30, 2022 16:08
@mongoose-im

This comment was marked as outdated.

@chrzaszcz chrzaszcz marked this pull request as ready for review December 1, 2022 06:38
@chrzaszcz chrzaszcz marked this pull request as draft December 1, 2022 06:38
@chrzaszcz chrzaszcz force-pushed the graphql-error-handling-muc-light branch from 0611c6f to e71240b Compare December 1, 2022 08:17
@mongoose-im

This comment was marked as outdated.

@chrzaszcz chrzaszcz force-pushed the graphql-error-handling-muc-light branch from e71240b to c9e6ba8 Compare December 1, 2022 09:23
@mongoose-im

This comment was marked as outdated.

The goal is to handle the error cases:
- Non-existing users shouldn't be room owners or message senders
- 'Room not found' should be returned if the room does not exist

Other functional changes:
- Name and subject are not required, because they shouldn't be.
  They have defaults, and they can be removed in a custom config schema.
- Only room owner should be able to kick room members.

Operations are broken into reusable steps, and a fold operation is
used to iterate over them.
- Handle the new error cases from the API module.
- Pass name and subject in the config map.
- Remove permission checking, which is done in mod_muc_light_api now.
- Update some operation names
- Pass room name and subject in a map
- Convert printed JIDs to binaries
- Protect 'mucDomain' on room creation.
  The reason is that a domain admin shouldn't be able to create a room
  at a different domain. The operation directly calls the MUC Light backend.
- Room JID is always bare
- Require 'mod_mam_muc' for message archive
- Make name and subject optional, as they should be.
  they have default values, and the user could even remove them from the
  config schema.
- Run the archive-related tests with and without MAM
- Test the new error conditions
Handle new error conditions.
@chrzaszcz chrzaszcz force-pushed the graphql-error-handling-muc-light branch from c9e6ba8 to 9788b67 Compare December 1, 2022 14:47
@mongoose-im
Copy link
Collaborator

mongoose-im commented Dec 1, 2022

small_tests_24 / small_tests / 9788b67
Reports root / small


small_tests_25 / small_tests / 9788b67
Reports root / small


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 9788b67
Reports root/ big
OK: 4124 / Failed: 0 / User-skipped: 88 / Auto-skipped: 0


ldap_mnesia_24 / ldap_mnesia / 9788b67
Reports root/ big
OK: 2172 / Failed: 0 / User-skipped: 821 / Auto-skipped: 0


dynamic_domains_mysql_redis_25 / mysql_redis / 9788b67
Reports root/ big
OK: 4098 / Failed: 0 / User-skipped: 114 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / 9788b67
Reports root/ big
OK: 4124 / Failed: 0 / User-skipped: 88 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_25 / odbc_mssql_mnesia / 9788b67
Reports root/ big
OK: 4124 / Failed: 0 / User-skipped: 88 / Auto-skipped: 0


internal_mnesia_25 / internal_mnesia / 9788b67
Reports root/ big
OK: 2314 / Failed: 0 / User-skipped: 679 / Auto-skipped: 0


ldap_mnesia_25 / ldap_mnesia / 9788b67
Reports root/ big
OK: 2172 / Failed: 0 / User-skipped: 821 / Auto-skipped: 0


elasticsearch_and_cassandra_25 / elasticsearch_and_cassandra_mnesia / 9788b67
Reports root/ big
OK: 2672 / Failed: 0 / User-skipped: 660 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 9788b67
Reports root/ big
OK: 4498 / Failed: 0 / User-skipped: 97 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / 9788b67
Reports root/ big
OK: 2510 / Failed: 0 / User-skipped: 652 / Auto-skipped: 0


pgsql_mnesia_25 / pgsql_mnesia / 9788b67
Reports root/ big
OK: 4498 / Failed: 0 / User-skipped: 97 / Auto-skipped: 0


mysql_redis_25 / mysql_redis / 9788b67
Reports root/ big
OK: 4484 / Failed: 0 / User-skipped: 111 / Auto-skipped: 0


mssql_mnesia_25 / odbc_mssql_mnesia / 9788b67
Reports root/ big
OK: 4509 / Failed: 1 / User-skipped: 97 / Auto-skipped: 0

pep_SUITE:pep_tests:unsubscribe_after_presence_unsubscription
{error,
  {{badmatch,
     [{xmlel,<<"message">>,
        [{<<"from">>,
        <<"alice_unsubscribe_after_presence_unsubscription_2689@localhost">>},
         {<<"to">>,
        <<"bob_unsubscribe_after_presence_unsubscription_2689@localhost/res1">>},
         {<<"type">>,<<"headline">>}],
        [{xmlel,<<"event">>,
           [{<<"xmlns">>,
           <<"http://jabber.org/protocol/pubsub#event">>}],
           [{xmlel,<<"items">>,
            [{<<"node">>,<<"se0m0Ht6TC3DYzDnzrmKSQ==">>}],
            [{xmlel,<<"item">>,
               [{<<"id">>,<<"salmon">>}],
               [{xmlel,<<"entry">>,
                  [{<<"xmlns">>,
                  <<"http://www.w3.org/2005/Atom">>}],
                  []}]}]}]},
         {xmlel,<<"headers">>,
           [{<<"xmlns">>,<<"http://jabber.org/protocol/shim">>}],
           []}]}]},
   [{pep_SUITE,'-unsubscribe_after_presence_unsubscription/1-fun-0-',2,
      [{file,"/home/circleci/project/big_tests/tests/pep_SUITE.erl"},
       {line,384}]},
    {escalus_story,story,4,
      [{file,
         "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
       {line,72}]},
    {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1782}]},
    {test_server,run_test_case_eval1,6,
      [{file,"test_server.erl"},{line,1291}]},
    {test_server,run_test_case_eval,9,
      [{file,"test_server.erl"},{line,1223}]}]}}

Report log

@chrzaszcz chrzaszcz marked this pull request as ready for review December 1, 2022 15:27
Copy link
Contributor

@JanuszJakubiec JanuszJakubiec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Copy link
Contributor

@jacekwegr jacekwegr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! 👍

@JanuszJakubiec JanuszJakubiec merged commit 557e265 into master Dec 6, 2022
@JanuszJakubiec JanuszJakubiec deleted the graphql-error-handling-muc-light branch December 6, 2022 06:34
@chrzaszcz chrzaszcz added this to the 6.0.0 milestone Dec 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants