diff --git a/lib/SyTest/Homeserver/Synapse.pm b/lib/SyTest/Homeserver/Synapse.pm index 1b6696e8a..3861a6c92 100644 --- a/lib/SyTest/Homeserver/Synapse.pm +++ b/lib/SyTest/Homeserver/Synapse.pm @@ -1310,7 +1310,6 @@ sub generate_haproxy_map ^/_matrix/federation/v1/event_auth/ federation_reader ^/_matrix/federation/v1/exchange_third_party_invite/ federation_reader ^/_matrix/federation/v1/send/ federation_reader -^/_matrix/federation/v1/get_groups_publicised federation_reader ^/_matrix/federation/v1/user/devices/ federation_reader ^/_matrix/key/v2/query federation_reader @@ -1326,10 +1325,6 @@ sub generate_haproxy_map ^/_matrix/client/(r0|v3|unstable)/register$ client_reader ^/_matrix/client/(r0|v3|unstable)/auth/.*/fallback/web$ client_reader ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/messages$ client_reader -^/_matrix/client/(api/v1|r0|v3|unstable)/get_groups_publicised$ client_reader -^/_matrix/client/(api/v1|r0|v3|unstable)/joined_groups$ client_reader -^/_matrix/client/(api/v1|r0|v3|unstable)/publicised_groups$ client_reader -^/_matrix/client/(api/v1|r0|v3|unstable)/publicised_groups/ client_reader ^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/event client_reader ^/_matrix/client/(api/v1|r0|v3|unstable)/joined_rooms client_reader ^/_matrix/client/(api/v1|r0|v3|unstable/.*)/rooms/.*/aliases client_reader @@ -1377,11 +1372,8 @@ sub generate_haproxy_get_map return <<'EOCONFIG'; # pushrules should be here, but the tests seem to be racy. # ^/_matrix/client/(api/v1|r0|v3|unstable)/pushrules/ client_reader -^/_matrix/client/(api/v1|r0|v3|unstable)/groups/ client_reader ^/_matrix/client/(r0|v3)/user/[^/]*/account_data/ client_reader ^/_matrix/client/(r0|v3)/user/[^/]*/rooms/[^/]*/account_data/ client_reader - -^/_matrix/federation/v1/groups/ federation_reader EOCONFIG } diff --git a/tests/30rooms/60version_upgrade.pl b/tests/30rooms/60version_upgrade.pl index 224c30b1d..5b854719e 100644 --- a/tests/30rooms/60version_upgrade.pl +++ b/tests/30rooms/60version_upgrade.pl @@ -485,7 +485,6 @@ sub upgrade_room_synced { "m.room.history_visibility" => { history_visibility => "joined" }, "m.room.avatar" => { url => "http://something" }, "m.room.encryption" => { algorithm => "m.megolm.v1.aes-sha2" }, - "m.room.related_groups" => { groups => [ "+something:example.org" ] }, "m.room.server_acl" => { allow => [ "*" ], allow_ip_literals => "false", diff --git a/tests/53groups/01create.pl b/tests/53groups/01create.pl deleted file mode 100644 index 03585fd2d..000000000 --- a/tests/53groups/01create.pl +++ /dev/null @@ -1,158 +0,0 @@ -test "Create group", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ) ], - - do => sub { - my ( $user ) = @_; - - my $localpart = make_group_localpart(); - my $server_name = $user->http->server_name; - - do_request_json_for( $user, - method => "POST", - uri => "/v3/create_group", - content => { - localpart => $localpart, - profile => { - name => "Test Group", - }, - }, - )->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( group_id ) ); - assert_eq( $body->{group_id}, "+$localpart:$server_name"); - - Future->done( 1 ); - }); - }; - -test "Add group rooms", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ) ], - - do => sub { - my ( $user ) = @_; - - my ( $group_id, $room_id ); - - matrix_create_group( $user ) - ->then( sub { - ( $group_id ) = @_; - - matrix_create_room( $user ); - })->then( sub { - ( $room_id ) = @_; - - matrix_add_group_rooms( $user, $group_id, $room_id ); - }); - }; - - -test "Remove group rooms", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ) ], - - do => sub { - my ( $user ) = @_; - - my ( $group_id, $room_id ); - - matrix_create_group( $user ) - ->then( sub { - ( $group_id ) = @_; - - matrix_create_room( $user ); - })->then( sub { - ( $room_id ) = @_; - - matrix_add_group_rooms( $user, $group_id, $room_id ); - })->then( sub { - matrix_remove_group_rooms( $user, $group_id, $room_id ); - }); - }; - - -push our @EXPORT, qw( matrix_create_group matrix_add_group_rooms matrix_remove_group_rooms ); - - -=head2 matrix_create_group - - matrix_create_group( $user, %profile ) - -Creates a group as the given user, and optionally the given profile. -Returns a Future for the created group_id. - -For example: - - matrix_create_group( $creator, name => "My new group" ) - -=cut - -sub matrix_create_group -{ - my ( $user, %opts ) = @_; - - my $localpart = make_group_localpart(); - - do_request_json_for( $user, - method => "POST", - uri => "/v3/create_group", - content => { - localpart => $localpart, - profile => { %opts }, - }, - )->then( sub { - my ( $body ) = @_; - - Future->done( $body->{group_id} ); - }); -} - - -=head2 matrix_add_group_rooms - - matrix_add_group_rooms( $user, $group_id, $room_id ) - -Add room to group as given user. - -=cut - -sub matrix_add_group_rooms -{ - my ( $user, $group_id, $room_id ) = @_; - - do_request_json_for( $user, - method => "PUT", - uri => "/v3/groups/$group_id/admin/rooms/$room_id", - content => {}, - ); -} - - - -=head2 matrix_remove_group_rooms - - matrix_remove_group_rooms( $user, $group_id, $room_id ) - -Remove room from group as given user. - -=cut - -sub matrix_remove_group_rooms -{ - my ( $user, $group_id, $room_id ) = @_; - - do_request_json_for( $user, - method => "DELETE", - uri => "/v3/groups/$group_id/admin/rooms/$room_id", - ); -} - - -my $next_group_localpart = 0; - -sub make_group_localpart -{ - sprintf "__anon__-%s-%d", $TEST_RUN_ID, $next_group_localpart++; -} diff --git a/tests/53groups/02read.pl b/tests/53groups/02read.pl deleted file mode 100644 index 08d422f1e..000000000 --- a/tests/53groups/02read.pl +++ /dev/null @@ -1,200 +0,0 @@ -my $local_viewer_fixture = local_user_fixture( with_events => 0 ); -my $remote_viewer_fixture = remote_user_fixture( with_events => 0 ); - -foreach my $viewer_fixture ( $local_viewer_fixture, $remote_viewer_fixture) { - my $test_name = $viewer_fixture == $local_viewer_fixture ? "local" : "remote"; - - test "Get $test_name group profile", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), $viewer_fixture ], - - do => sub { - my ( $user, $viewer ) = @_; - - matrix_create_group( $user, - name => "Random Group", - avatar_url => "mxc://example.org/foooooo", - short_description => "A random topic for a random group", - long_description => "A longer desc\n\n for a random group", - )->then( sub { - my ( $group_id ) = @_; - - matrix_get_group_profile( $viewer, $group_id ); - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( name avatar_url short_description long_description ) ); - - assert_eq( $body->{name}, "Random Group" ); - assert_eq( $body->{avatar_url}, "mxc://example.org/foooooo" ); - assert_eq( $body->{short_description}, "A random topic for a random group" ); - assert_eq( $body->{long_description}, "A longer desc\n\n for a random group" ); - - Future->done( 1 ); - }); - }; - - test "Get $test_name group users", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), $viewer_fixture ], - - do => sub { - my ( $user, $viewer ) = @_; - - matrix_create_group( $user ) - ->then( sub { - my ( $group_id ) = @_; - - matrix_get_group_users( $viewer, $group_id ); - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( chunk ) ); - - Future->done( 1 ); - }); - }; - - test "Add/remove $test_name group rooms", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), $viewer_fixture ], - - do => sub { - my ( $user, $viewer ) = @_; - - my ( $group_id, $room_id ); - - matrix_create_group( $user ) - ->then( sub { - ( $group_id ) = @_; - - matrix_create_room( $user ); - })->then( sub { - ( $room_id ) = @_; - - matrix_add_group_rooms( $user, $group_id, $room_id ); - })->then( sub { - matrix_get_group_rooms( $viewer, $group_id ); - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( chunk ) ); - - any { $_->{room_id} eq $room_id } @{ $body->{chunk} } - or die "Room not in group rooms list"; - - matrix_remove_group_rooms( $user, $group_id, $room_id ); - })->then( sub { - matrix_get_group_rooms( $viewer, $group_id ); - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( chunk ) ); - - any { $_->{room_id} eq $room_id } @{ $body->{chunk} } - and die "Room still in group rooms list after deleted"; - - Future->done( 1 ); - }); - }; - - test "Get $test_name group summary", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), $viewer_fixture ], - - do => sub { - my ( $user, $viewer ) = @_; - - my ( $group_id, $room_id ); - - matrix_create_group( $user, - name => "Testing summaries", - ) - ->then( sub { - ( $group_id ) = @_; - - matrix_create_room( $user ); - })->then( sub { - ( $room_id ) = @_; - - matrix_add_group_rooms( $user, $group_id, $room_id ); - })->then( sub { - matrix_get_group_summary( $viewer, $group_id ); - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( profile users_section rooms_section ) ); - - assert_eq( $body->{profile}{name}, "Testing summaries" ); - - # TODO: Check summaries.... - - Future->done( 1 ); - }); - }; -} - -push our @EXPORT, qw( matrix_get_group_rooms matrix_get_group_summary ); - -sub matrix_get_group_profile -{ - my ( $user, $group_id ) = @_; - - do_request_json_for( $user, - method => "GET", - uri => "/v3/groups/$group_id/profile", - ); -} - -sub matrix_get_group_users -{ - my ( $user, $group_id ) = @_; - - do_request_json_for( $user, - method => "GET", - uri => "/v3/groups/$group_id/users", - ); -} - - -=head2 matrix_get_group_rooms - - matrix_get_group_rooms( $user, $group_id ) - -Get list of associated rooms for a group. - -The body of the response is returned, which is in the form: - - { chunk => [ { room_id => '!...' } ] } - -=cut - -sub matrix_get_group_rooms -{ - my ( $user, $group_id ) = @_; - - do_request_json_for( $user, - method => "GET", - uri => "/v3/groups/$group_id/rooms", - ); -} - - -=head2 matrix_get_group_summary - - matrix_get_group_summary( $user, $group_id ) - -Get the full group summary for a group. The body of the response -is returned. - -=cut - -sub matrix_get_group_summary -{ - my ( $user, $group_id ) = @_; - - do_request_json_for( $user, - method => "GET", - uri => "/v3/groups/$group_id/summary", - ); -} diff --git a/tests/53groups/03local.pl b/tests/53groups/03local.pl deleted file mode 100644 index b38546133..000000000 --- a/tests/53groups/03local.pl +++ /dev/null @@ -1,258 +0,0 @@ -test "Add local group users", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), local_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $creator, $user ) = @_; - - my $group_id; - - matrix_create_group( $creator ) - ->then( sub { - ( $group_id ) = @_; - - matrix_invite_group_user( $creator, $group_id, $user ); - })->then( sub { - matrix_accept_group_invite( $group_id, $user ); - })->then( sub { - matrix_get_joined_groups( $user ); - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( groups ) ); - assert_json_list( my $group_ids = $body->{groups} ); - - assert_deeply_eq( $group_ids, [ $group_id ] ); - - Future->done( 1 ); - }); - }; - -test "Remove self from local group", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), local_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $creator, $user ) = @_; - - my $group_id; - - matrix_create_group( $creator ) - ->then( sub { - ( $group_id ) = @_; - - matrix_invite_group_user( $creator, $group_id, $user ); - })->then( sub { - matrix_accept_group_invite( $group_id, $user ); - })->then( sub { - matrix_get_joined_groups( $user ); - })->then( sub { - my ( $body ) = @_; - - assert_deeply_eq( $body->{groups}, [ $group_id ] ); - - matrix_leave_group( $user, $group_id ); - })->then( sub { - matrix_get_joined_groups( $user ); - })->then( sub { - my ( $body ) = @_; - - assert_deeply_eq( $body->{groups}, [] ); - - Future->done( 1 ); - }); - }; - -test "Remove other from local group", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), local_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $creator, $user ) = @_; - - my $group_id; - - matrix_create_group( $creator ) - ->then( sub { - ( $group_id ) = @_; - - matrix_invite_group_user( $creator, $group_id, $user ); - })->then( sub { - matrix_accept_group_invite( $group_id, $user ); - })->then( sub { - matrix_get_joined_groups( $user ); - })->then( sub { - my ( $body ) = @_; - - assert_deeply_eq( $body->{groups}, [ $group_id ] ); - - matrix_remove_group_user( $creator, $group_id, $user ); - })->then( sub { - matrix_get_joined_groups( $user ); - })->then( sub { - my ( $body ) = @_; - - assert_deeply_eq( $body->{groups}, [] ); - - Future->done( 1 ); - }); - }; - - -push our @EXPORT, qw( matrix_invite_group_user matrix_accept_group_invite matrix_get_joined_groups matrix_leave_group matrix_join_group matrix_get_invited_group_users ); - - -=head2 matrix_invite_group_user - - matrix_invite_group_user( $inviter, $group_id, $invitee ) - -Invite user to group - -=cut - -sub matrix_invite_group_user -{ - my ( $inviter, $group_id, $invitee ) = @_; - - my $invitee_id = $invitee->user_id; - - do_request_json_for( $inviter, - method => "PUT", - uri => "/v3/groups/$group_id/admin/users/invite/$invitee_id", - content => {}, - ); -} - - -=head2 matrix_remove_group_user - - matrix_remove_group_user( $inviter, $group_id, $invitee ) - -Remove another user from group using admin api - -=cut - -sub matrix_remove_group_user -{ - my ( $inviter, $group_id, $invitee ) = @_; - - my $invitee_id = $invitee->user_id; - - do_request_json_for( $inviter, - method => "PUT", - uri => "/v3/groups/$group_id/admin/users/remove/$invitee_id", - content => {}, - ); -} - - -=head2 matrix_accept_group_invite - - matrix_accept_group_invite( $group_id, $user ) - -Accept a received invite - -=cut - -sub matrix_accept_group_invite -{ - my ( $group_id, $user ) = @_; - - do_request_json_for( $user, - method => "PUT", - uri => "/v3/groups/$group_id/self/accept_invite", - content => {}, - ); -} - - -=head2 matrix_join_group - - matrix_join_group( $group_id, $user ) - -Join a group - -=cut - -sub matrix_join_group -{ - my ( $group_id, $user ) = @_; - - do_request_json_for( $user, - method => "PUT", - uri => "/v3/groups/$group_id/self/join", - content => {}, - ); -} - - -=head2 matrix_leave_group - - matrix_leave_group( $user, $group_id ) - -Leave a group that user is in - -=cut - -sub matrix_leave_group -{ - my ( $user, $group_id ) = @_; - - do_request_json_for( $user, - method => "PUT", - uri => "/v3/groups/$group_id/self/leave", - content => {}, - ); -} - - -=head2 matrix_get_joined_groups - - matrix_get_joined_groups( $user ) - -Get list of groups the user is in. Returns the body of the response, -which is in the form: - - { groups => [ '+foo:bar.com' ] } - -=cut - -sub matrix_get_joined_groups -{ - my ( $user ) = @_; - - do_request_json_for( $user, - method => "GET", - uri => "/v3/joined_groups", - ); -} - -=head2 matrix_get_invited_group_users - - matrix_get_invited_group_users( $group_id, $user ) - -Get a list of invited group members. Returns the body of the response, which -is in the form: - - { - chunk => [ - { - user_id => '@someone:example.org', - avatar_url => 'mxc://example.org/something', - displayname => 'Example User' - } - ], - total_user_count_estimate => 1 - } - -=cut - -sub matrix_get_invited_group_users -{ - my ( $group_id, $user ) = @_; - - do_request_json_for( $user, - method => "GET", - uri => "/v3/groups/$group_id/invited_users" - ) -} diff --git a/tests/53groups/04remote-group.pl b/tests/53groups/04remote-group.pl deleted file mode 100644 index 1cd5171da..000000000 --- a/tests/53groups/04remote-group.pl +++ /dev/null @@ -1,81 +0,0 @@ -test "Add remote group users", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), remote_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $creator, $user ) = @_; - - my $group_id; - - matrix_create_group( $creator ) - ->then( sub { - ( $group_id ) = @_; - - matrix_invite_group_user( $creator, $group_id, $user ); - })->then( sub { - matrix_accept_group_invite( $group_id, $user ); - })->then( sub { - matrix_get_joined_groups( $user ); - })->then( sub { - my ( $body ) = @_; - - assert_deeply_eq( $body->{groups}, [ $group_id ] ); - - Future->done( 1 ); - }); - }; - -test "Remove self from remote group", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), remote_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $creator, $user ) = @_; - - my $group_id; - - matrix_create_group( $creator ) - ->then( sub { - ( $group_id ) = @_; - - matrix_invite_group_user( $creator, $group_id, $user ); - })->then( sub { - matrix_accept_group_invite( $group_id, $user ); - })->then( sub { - matrix_get_joined_groups( $user ); - })->then( sub { - my ( $body ) = @_; - - assert_deeply_eq( $body->{groups}, [ $group_id ] ); - - matrix_leave_group( $user, $group_id ); - })->then( sub { - matrix_get_joined_groups( $user ); - })->then( sub { - my ( $body ) = @_; - - assert_deeply_eq( $body->{groups}, [] ); - - Future->done( 1 ); - }); - }; - -test "Listing invited users of a remote group when not a member returns a 403", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), remote_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $creator, $user ) = @_; - - my $group_id; - - matrix_create_group( $creator ) - ->then( sub { - ( $group_id ) = @_; - - matrix_get_invited_group_users( $group_id, $user ) - -> main::expect_http_403; - }); - }; - -# TODO: Test kicks diff --git a/tests/53groups/05categories.pl b/tests/53groups/05categories.pl deleted file mode 100644 index 7e68855aa..000000000 --- a/tests/53groups/05categories.pl +++ /dev/null @@ -1,142 +0,0 @@ -test "Add group category", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ) ], - - do => sub { - my ( $user ) = @_; - - my $group_id; - - matrix_create_group( $user ) - ->then( sub { - ( $group_id ) = @_; - - matrix_add_category_to_group( $user, $group_id, "some_cat", - profile => { name => "Category Name" } - ); - })->then( sub { - matrix_get_group_category( $user, $group_id, "some_cat" ); - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw ( is_public profile ) ); - assert_deeply_eq( $body->{profile}, { name => "Category Name" } ); - - Future->done( 1 ); - }); - }; - -test "Remove group category", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ) ], - - do => sub { - my ( $user ) = @_; - - my $group_id; - - matrix_create_group( $user ) - ->then( sub { - ( $group_id ) = @_; - - matrix_add_category_to_group( $user, $group_id, "some_cat" ); - })->then( sub { - matrix_remove_category_from_group( $user, $group_id, "some_cat" ); - })->then( sub { - matrix_get_group_category( $user, $group_id, "some_cat" ); - })->main::expect_http_404; - }; - - -test "Get group categories", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ) ], - - do => sub { - my ( $user ) = @_; - - my $group_id; - - matrix_create_group( $user ) - ->then( sub { - ( $group_id ) = @_; - - matrix_add_category_to_group( $user, $group_id, "some_cat1", - profile => { name => "Category Name 1" } - ); - })->then( sub { - matrix_add_category_to_group( $user, $group_id, "some_cat2", - profile => { name => "Category Name 2" } - ); - })->then( sub { - matrix_get_group_categories( $user, $group_id ); - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw ( categories ) ); - assert_json_keys( $body->{categories}, qw( some_cat1 some_cat2 ) ); - - assert_deeply_eq( $body->{categories}{some_cat1}{profile}, { name => "Category Name 1" } ); - assert_deeply_eq( $body->{categories}{some_cat2}{profile}, { name => "Category Name 2" } ); - - Future->done( 1 ); - }); - }; - - -push our @EXPORT, qw( matrix_add_category_to_group ); - - -=head2 matrix_add_category_to_group - - matrix_add_category_to_group( $user, $group_id, $category_id, %opts ) - -Create a category for a group. Extra options are passed directly into the -content of the request. - - matrix_add_category_to_group( $user, $group_id, "some_cat1", - profile => { name => "Category Name 1" } - ); - -=cut - -sub matrix_add_category_to_group -{ - my ( $user, $group_id, $category_id, %opts ) = @_; - - do_request_json_for( $user, - method => "PUT", - uri => "/v3/groups/$group_id/categories/$category_id", - content => \%opts, - ); -} - -sub matrix_get_group_category -{ - my ( $user, $group_id, $category_id ) = @_; - - do_request_json_for( $user, - method => "GET", - uri => "/v3/groups/$group_id/categories/$category_id", - ); -} - -sub matrix_remove_category_from_group -{ - my ( $user, $group_id, $category_id ) = @_; - - do_request_json_for( $user, - method => "DELETE", - uri => "/v3/groups/$group_id/categories/$category_id", - ); -} - -sub matrix_get_group_categories -{ - my ( $user, $group_id ) = @_; - - do_request_json_for( $user, - method => "GET", - uri => "/v3/groups/$group_id/categories/", - ); -} diff --git a/tests/53groups/05roles.pl b/tests/53groups/05roles.pl deleted file mode 100644 index c154ef0f0..000000000 --- a/tests/53groups/05roles.pl +++ /dev/null @@ -1,142 +0,0 @@ -test "Add group role", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ) ], - - do => sub { - my ( $user ) = @_; - - my $group_id; - - matrix_create_group( $user ) - ->then( sub { - ( $group_id ) = @_; - - matrix_add_role_to_group( $user, $group_id, "some_role", - profile => { name => "Role Name" } - ); - })->then( sub { - matrix_get_group_role( $user, $group_id, "some_role" ); - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw ( is_public profile ) ); - assert_deeply_eq( $body->{profile}, { name => "Role Name" } ); - - Future->done( 1 ); - }); - }; - -test "Remove group role", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ) ], - - do => sub { - my ( $user ) = @_; - - my $group_id; - - matrix_create_group( $user ) - ->then( sub { - ( $group_id ) = @_; - - matrix_add_role_to_group( $user, $group_id, "some_role" ); - })->then( sub { - matrix_remove_role_from_group( $user, $group_id, "some_role" ); - })->then( sub { - matrix_get_group_role( $user, $group_id, "some_role" ); - })->main::expect_http_404; - }; - - -test "Get group roles", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ) ], - - do => sub { - my ( $user ) = @_; - - my $group_id; - - matrix_create_group( $user ) - ->then( sub { - ( $group_id ) = @_; - - matrix_add_role_to_group( $user, $group_id, "some_role1", - profile => { name => "Role Name 1" } - ); - })->then( sub { - matrix_add_role_to_group( $user, $group_id, "some_role2", - profile => { name => "Role Name 2" } - ); - })->then( sub { - matrix_get_group_roles( $user, $group_id ); - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw ( roles ) ); - assert_json_keys( $body->{roles}, qw( some_role1 some_role2 ) ); - - assert_deeply_eq( $body->{roles}{some_role1}{profile}, { name => "Role Name 1" } ); - assert_deeply_eq( $body->{roles}{some_role2}{profile}, { name => "Role Name 2" } ); - - Future->done( 1 ); - }); - }; - - -push our @EXPORT, qw( matrix_add_role_to_group ); - - -=head2 matrix_add_role_to_group - - matrix_add_role_to_group( $user, $group_id, $role_id, %opts ) - -Create a role for a group. Extra options are passed directly into the -content of the request. - - matrix_add_role_to_group( $user, $group_id, "some_role1", - profile => { name => "Role Name 1" } - ); - -=cut - -sub matrix_add_role_to_group -{ - my ( $user, $group_id, $role_id, %opts ) = @_; - - do_request_json_for( $user, - method => "PUT", - uri => "/v3/groups/$group_id/roles/$role_id", - content => \%opts, - ); -} - -sub matrix_get_group_role -{ - my ( $user, $group_id, $role_id ) = @_; - - do_request_json_for( $user, - method => "GET", - uri => "/v3/groups/$group_id/roles/$role_id", - ); -} - -sub matrix_remove_role_from_group -{ - my ( $user, $group_id, $role_id ) = @_; - - do_request_json_for( $user, - method => "DELETE", - uri => "/v3/groups/$group_id/roles/$role_id", - ); -} - -sub matrix_get_group_roles -{ - my ( $user, $group_id ) = @_; - - do_request_json_for( $user, - method => "GET", - uri => "/v3/groups/$group_id/roles/", - ); -} diff --git a/tests/53groups/06summaries.pl b/tests/53groups/06summaries.pl deleted file mode 100644 index 806246038..000000000 --- a/tests/53groups/06summaries.pl +++ /dev/null @@ -1,552 +0,0 @@ -test "Add room to group summary", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), local_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $user, $viewer ) = @_; - - my ( $group_id, $room_id ); - - matrix_create_group( $user, - name => "Testing summaries", - ) - ->then( sub { - ( $group_id ) = @_; - - matrix_create_room( $user ); - })->then( sub { - ( $room_id ) = @_; - - matrix_add_group_rooms( $user, $group_id, $room_id ); - })->then( sub { - matrix_add_room_to_group_summary( $user, $group_id, $room_id ); - })->then( sub { - matrix_get_group_summary( $viewer, $group_id ); - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( profile users_section rooms_section ) ); - assert_eq( $body->{profile}{name}, "Testing summaries" ); - - any { $room_id eq $_->{room_id} } @{ $body->{rooms_section}{rooms} } - or die "room not in sumary"; - - Future->done( 1 ); - }); - }; - -# Luke claims that adding room to group summary removes the room_id -# when fetching the rooms in a group -test "Adding room to group summary keeps room_id when fetching rooms in group", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), local_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $user, $viewer ) = @_; - - my ( $group_id, $room_id ); - - matrix_create_group( $user, - name => "Testing summaries", - ) - ->then( sub { - ( $group_id ) = @_; - - matrix_create_room( $user ); - })->then( sub { - ( $room_id ) = @_; - - matrix_add_group_rooms( $user, $group_id, $room_id ); - })->then( sub { - matrix_add_room_to_group_summary( $user, $group_id, $room_id ); - })->then( sub { - matrix_get_group_rooms( $viewer, $group_id ); - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( chunk ) ); - - any { $_->{room_id} eq $room_id } @{ $body->{chunk} } - or die "Room not in group rooms list"; - - Future->done( 1 ); - }); - }; - - -test "Adding multiple rooms to group summary have correct order", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), local_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $user, $viewer ) = @_; - - my ( $group_id, $room_id1, $room_id2 ); - - matrix_create_group( $user, - name => "Testing summaries", - ) - ->then( sub { - ( $group_id ) = @_; - - matrix_create_room( $user ); - })->then( sub { - ( $room_id1 ) = @_; - - matrix_add_group_rooms( $user, $group_id, $room_id1 ); - })->then( sub { - matrix_add_room_to_group_summary( $user, $group_id, $room_id1 ); - })->then( sub { - matrix_create_room( $user ); - })->then( sub { - ( $room_id2 ) = @_; - - matrix_add_group_rooms( $user, $group_id, $room_id2 ); - })->then( sub { - matrix_add_room_to_group_summary( $user, $group_id, $room_id2 ); - })->then( sub { - matrix_get_group_summary( $viewer, $group_id ); - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( profile users_section rooms_section ) ); - assert_eq( $body->{profile}{name}, "Testing summaries" ); - - my $rooms = $body->{rooms_section}{rooms}; - - my $room1 = first { $room_id1 eq $_->{room_id} } @{ $rooms }; - my $room2 = first { $room_id2 eq $_->{room_id} } @{ $rooms }; - - $room1->{order} < $room2->{order} or die "orders are incorrect"; - - Future->done( 1 ); - }); - }; - -test "Remove room from group summary", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), local_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $user, $viewer ) = @_; - - my ( $group_id, $room_id ); - - matrix_create_group( $user, - name => "Testing summaries", - ) - ->then( sub { - ( $group_id ) = @_; - - matrix_create_room( $user ); - })->then( sub { - ( $room_id ) = @_; - - matrix_add_group_rooms( $user, $group_id, $room_id ); - })->then( sub { - matrix_add_room_to_group_summary( $user, $group_id, $room_id ); - })->then( sub { - matrix_get_group_summary( $viewer, $group_id ); - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( profile users_section rooms_section ) ); - assert_eq( $body->{profile}{name}, "Testing summaries" ); - - any { $room_id eq $_->{room_id} } @{ $body->{rooms_section}{rooms} } - or die "room not in sumary"; - - matrix_remove_room_from_group_summary( $user, $group_id, $room_id ); - })->then( sub { - matrix_get_group_summary( $viewer, $group_id ); - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( profile users_section rooms_section ) ); - assert_eq( $body->{profile}{name}, "Testing summaries" ); - - any { $room_id eq $_->{room_id} } @{ $body->{rooms_section}{rooms} } - and die "room still in sumary"; - - Future->done( 1 ); - }); - }; - - -test "Add room to group summary with category", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), local_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $user, $viewer ) = @_; - - my ( $group_id, $room_id ); - - matrix_create_group( $user, - name => "Testing summaries", - ) - ->then( sub { - ( $group_id ) = @_; - - matrix_create_room( $user ); - })->then( sub { - ( $room_id ) = @_; - - matrix_add_group_rooms( $user, $group_id, $room_id ); - })->then( sub { - matrix_add_category_to_group( $user, $group_id, "some_cat", - profile => { name => "Category Name" } - ); - })->then( sub { - matrix_add_room_to_group_summary_category( $user, $group_id, "some_cat", $room_id ); - })->then( sub { - matrix_get_group_summary( $viewer, $group_id ); - })->then( sub { - my ( $body ) = @_; - - log_if_fail "Summary Body", $body; - - assert_json_keys( $body, qw( profile users_section rooms_section ) ); - assert_eq( $body->{profile}{name}, "Testing summaries" ); - - my $rooms = $body->{rooms_section}{rooms}; - my $room = first { $room_id eq $_->{room_id} } @{ $rooms }; - - assert_json_keys( $room, qw( profile is_public category_id ) ); - assert_eq( $room->{category_id}, "some_cat" ); - - assert_json_keys( $body->{rooms_section}{categories}, qw( some_cat ) ); - - Future->done( 1 ); - }); - }; - -test "Remove room from group summary with category", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), local_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $user, $viewer ) = @_; - - my ( $group_id, $room_id ); - - matrix_create_group( $user, - name => "Testing summaries", - ) - ->then( sub { - ( $group_id ) = @_; - - matrix_create_room( $user ); - })->then( sub { - ( $room_id ) = @_; - - matrix_add_group_rooms( $user, $group_id, $room_id ); - })->then( sub { - matrix_add_category_to_group( $user, $group_id, "some_cat", - profile => { name => "Category Name" } - ); - })->then( sub { - matrix_add_room_to_group_summary_category( $user, $group_id, "some_cat", $room_id ); - })->then( sub { - matrix_remove_room_from_group_summary_category( $user, $group_id, "some_cat", $room_id ); - })->then( sub { - matrix_get_group_summary( $viewer, $group_id ); - })->then( sub { - my ( $body ) = @_; - - log_if_fail "Summary Body", $body; - - assert_json_keys( $body, qw( profile users_section rooms_section ) ); - assert_eq( $body->{profile}{name}, "Testing summaries" ); - - any { $room_id eq $_->{room_id} } @{ $body->{rooms_section}{rooms} } - and die "room still in sumary"; - - Future->done( 1 ); - }); - }; - - - -test "Add user to group summary", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), local_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $user, $viewer ) = @_; - - my ( $group_id ); - - matrix_create_group( $user, - name => "Testing summaries", - ) - ->then( sub { - ( $group_id ) = @_; - - matrix_add_user_to_group_summary( $user, $group_id, $user->user_id ); - })->then( sub { - matrix_get_group_summary( $viewer, $group_id ); - })->then( sub { - my ( $body ) = @_; - - log_if_fail "Body", $body; - - assert_json_keys( $body, qw( profile users_section rooms_section ) ); - assert_eq( $body->{profile}{name}, "Testing summaries" ); - - any { $user->user_id eq $_->{user_id} } @{ $body->{users_section}{users} } - or die "user not in sumary"; - - Future->done( 1 ); - }); - }; - - -test "Adding multiple users to group summary have correct order", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), local_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $user, $viewer ) = @_; - - my ( $group_id ); - - matrix_create_group( $user ) - ->then( sub { - ( $group_id ) = @_; - - matrix_invite_group_user( $user, $group_id, $viewer ); - })->then( sub { - matrix_accept_group_invite( $group_id, $viewer ); - })->then( sub { - matrix_add_user_to_group_summary( $user, $group_id, $user->user_id ); - })->then( sub { - matrix_add_user_to_group_summary( $user, $group_id, $viewer->user_id ); - })->then( sub { - matrix_get_group_summary( $viewer, $group_id ); - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( profile users_section rooms_section ) ); - - log_if_fail "Summary Body", $body; - - my $users = $body->{users_section}{users}; - - my $user1 = first { $user->user_id eq $_->{user_id} } @{ $users }; - my $user2 = first { $viewer->user_id eq $_->{user_id} } @{ $users }; - - $user1->{order} < $user2->{order} or die "orders are incorrect"; - - Future->done( 1 ); - }); - }; - -test "Remove user from group summary", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), local_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $user, $viewer ) = @_; - - my ( $group_id ); - - matrix_create_group( $user, - name => "Testing summaries", - ) - ->then( sub { - ( $group_id ) = @_; - - matrix_add_user_to_group_summary( $user, $group_id, $user->user_id ); - })->then( sub { - matrix_get_group_summary( $viewer, $group_id ); - })->then( sub { - my ( $body ) = @_; - - any { $user->user_id eq $_->{user_id} } @{ $body->{users_section}{users} } - or die "user not in sumary"; - - matrix_remove_user_from_group_summary( $user, $group_id, $user->user_id ); - })->then( sub { - matrix_get_group_summary( $viewer, $group_id ); - })->then( sub { - my ( $body ) = @_; - - any { $user->user_id eq $_->{user_id} } @{ $body->{users_section}{users} } - and die "user still in sumary"; - - Future->done( 1 ); - }); - }; - - -test "Add user to group summary with role", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), local_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $user, $viewer ) = @_; - - my $group_id; - - matrix_create_group( $user, - name => "Testing summaries", - ) - ->then( sub { - ( $group_id ) = @_; - - matrix_add_role_to_group( $user, $group_id, "some_role", - profile => { name => "Category Name" } - ); - })->then( sub { - matrix_add_user_to_group_summary_role( $user, $group_id, "some_role", $user->user_id ); - })->then( sub { - matrix_get_group_summary( $viewer, $group_id ); - })->then( sub { - my ( $body ) = @_; - - log_if_fail "Summary Body", $body; - - assert_json_keys( $body, qw( profile users_section rooms_section ) ); - assert_eq( $body->{profile}{name}, "Testing summaries" ); - - my $users = $body->{users_section}{users}; - my $user = first { $user->user_id eq $_->{user_id} } @{ $users }; - - assert_json_keys( $user, qw( is_public role_id ) ); - assert_eq( $user->{role_id}, "some_role" ); - - assert_json_keys( $body->{users_section}{roles}, qw( some_role ) ); - - Future->done( 1 ); - }); - }; - -test "Remove user from group summary with role", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), local_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $user, $viewer ) = @_; - - my $group_id; - - matrix_create_group( $user, - name => "Testing summaries", - ) - ->then( sub { - ( $group_id ) = @_; - - matrix_add_role_to_group( $user, $group_id, "some_role", - profile => { name => "Category Name" } - ); - })->then( sub { - matrix_add_user_to_group_summary_role( $user, $group_id, "some_role", $user->user_id ); - })->then( sub { - matrix_remove_user_from_group_summary_role( $user, $group_id, "some_role", $user->user_id ); - })->then( sub { - matrix_get_group_summary( $viewer, $group_id ); - })->then( sub { - my ( $body ) = @_; - - log_if_fail "Summary Body", $body; - - assert_json_keys( $body, qw( profile users_section rooms_section ) ); - assert_eq( $body->{profile}{name}, "Testing summaries" ); - - any { $user->user_id eq $_->{user_id} } @{ $body->{users_section}{users} } - and die "user still in sumary"; - - Future->done( 1 ); - }); - }; - - - -sub matrix_add_room_to_group_summary -{ - my ( $user, $group_id, $room_id, %opts ) = @_; - - do_request_json_for( $user, - method => "PUT", - uri => "/v3/groups/$group_id/summary/rooms/$room_id", - content => \%opts, - ); -} - -sub matrix_add_room_to_group_summary_category -{ - my ( $user, $group_id, $category_id, $room_id, %opts ) = @_; - - do_request_json_for( $user, - method => "PUT", - uri => "/v3/groups/$group_id/summary/categories/$category_id/rooms/$room_id", - content => \%opts, - ); -} - -sub matrix_remove_room_from_group_summary_category -{ - my ( $user, $group_id, $category_id, $room_id, %opts ) = @_; - - do_request_json_for( $user, - method => "DELETE", - uri => "/v3/groups/$group_id/summary/categories/$category_id/rooms/$room_id", - ); -} - - -sub matrix_remove_room_from_group_summary -{ - my ( $user, $group_id, $room_id ) = @_; - - do_request_json_for( $user, - method => "DELETE", - uri => "/v3/groups/$group_id/summary/rooms/$room_id", - ); -} - - - -sub matrix_add_user_to_group_summary -{ - my ( $user, $group_id, $user_id, %opts ) = @_; - - do_request_json_for( $user, - method => "PUT", - uri => "/v3/groups/$group_id/summary/users/$user_id", - content => \%opts, - ); -} - -sub matrix_add_user_to_group_summary_role -{ - my ( $user, $group_id, $role_id, $user_id, %opts ) = @_; - - do_request_json_for( $user, - method => "PUT", - uri => "/v3/groups/$group_id/summary/roles/$role_id/users/$user_id", - content => \%opts, - ); -} - -sub matrix_remove_user_from_group_summary_role -{ - my ( $user, $group_id, $role_id, $user_id ) = @_; - - do_request_json_for( $user, - method => "DELETE", - uri => "/v3/groups/$group_id/summary/roles/$role_id/users/$user_id", - ); -} - - -sub matrix_remove_user_from_group_summary -{ - my ( $user, $group_id, $user_id ) = @_; - - do_request_json_for( $user, - method => "DELETE", - uri => "/v3/groups/$group_id/summary/users/$user_id", - ); -} diff --git a/tests/53groups/10sync.pl b/tests/53groups/10sync.pl deleted file mode 100644 index 6d4d8bcf1..000000000 --- a/tests/53groups/10sync.pl +++ /dev/null @@ -1,139 +0,0 @@ -use Future::Utils qw( try_repeat_until_success ); - - -test "Local group invites come down sync", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), local_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $creator, $user ) = @_; - - my $group_id; - - my $group_name = "Test Group"; - - matrix_create_group( $creator, - name => $group_name, - ) - ->then( sub { - ( $group_id ) = @_; - - matrix_sync( $user ); - })->then( sub { - matrix_sync_again( $user ) - })->then( sub { - matrix_invite_group_user( $creator, $group_id, $user ); - })->then( sub { - try_repeat_until_success( sub { - matrix_sync_again( $user ) - ->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( groups ) ); - assert_json_keys( $body->{groups}, qw( invite ) ); - - assert_json_keys( $body->{groups}{invite}, $group_id ); - - Future->done( $body->{groups}{invite}{$group_id} ); - }); - }) - })->then( sub { - my ( $invite ) = @_; - - assert_json_keys( $invite, qw( profile ) ); - assert_json_keys( $invite->{profile}, qw( name ) ); - assert_eq( $invite->{profile}{name}, $group_name ); - - Future->done( 1 ); - }); - }; - - -test "Group creator sees group in sync", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ) ], - - do => sub { - my ( $creator ) = @_; - - my $group_id; - - my $group_name = "Test Group"; - - matrix_sync( $creator ) - ->then( sub { - matrix_create_group( $creator, - name => $group_name, - ) - })->then( sub { - ( $group_id ) = @_; - - try_repeat_until_success( sub { - matrix_sync_again( $creator ) - ->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( groups ) ); - assert_json_keys( $body->{groups}, qw( join ) ); - - assert_json_keys( $body->{groups}{join}, $group_id ); - - Future->done( $body->{groups}{join}{$group_id} ); - }); - }) - })->then( sub { - my ( $join ) = @_; - - log_if_fail "Group Join", $join; - - # TODO: Add check that profile comes down - # assert_json_keys( $join, qw( profile ) ); - # assert_json_keys( $join->{profile}, qw( name ) ); - # assert_eq( $join->{profile}{name}, $group_name ); - - Future->done( 1 ); - }); - }; - -test "Group creator sees group in initial sync", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ) ], - - do => sub { - my ( $creator ) = @_; - - my $group_id; - - my $group_name = "Test Group"; - - matrix_create_group( $creator, - name => $group_name, - )->then( sub { - ( $group_id ) = @_; - - try_repeat_until_success( sub { - matrix_sync( $creator ) - ->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( groups ) ); - assert_json_keys( $body->{groups}, qw( join ) ); - - assert_json_keys( $body->{groups}{join}, $group_id ); - - Future->done( $body->{groups}{join}{$group_id} ); - }); - }) - })->then( sub { - my ( $join ) = @_; - - log_if_fail "Group Join", $join; - - # TODO: Add check that profile comes down - # assert_json_keys( $join, qw( profile ) ); - # assert_json_keys( $join->{profile}, qw( name ) ); - # assert_eq( $join->{profile}{name}, $group_name ); - - Future->done( 1 ); - }); - }; diff --git a/tests/53groups/11publicise.pl b/tests/53groups/11publicise.pl deleted file mode 100644 index e8f4a83c9..000000000 --- a/tests/53groups/11publicise.pl +++ /dev/null @@ -1,112 +0,0 @@ -test "Get/set local group publicity", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), local_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $creator, $user ) = @_; - - my $group_id; - - matrix_create_group( $creator ) - ->then( sub { - ( $group_id ) = @_; - - matrix_invite_group_user( $creator, $group_id, $user ); - })->then( sub { - matrix_accept_group_invite( $group_id, $user ); - })->then( sub { - matrix_update_group_publicity( $group_id, $user, 1 ); - })->then( sub { - matrix_get_group_publicity( $creator, $user ) - })->then( sub { - my ( $body ) = @_; - - log_if_fail "Body", $body; - - assert_json_keys( $body, qw( groups ) ); - assert_deeply_eq( $body->{groups}, [ $group_id ] ); - - Future->done( 1 ); - }); - }; - -test "Bulk get group publicity", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), local_user_fixture( with_events => 0 ), remote_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $creator, $local_user, $remote_user ) = @_; - - my $group_id; - - matrix_create_group( $creator ) - ->then( sub { - ( $group_id ) = @_; - - matrix_invite_group_user( $creator, $group_id, $local_user ); - })->then( sub { - matrix_accept_group_invite( $group_id, $local_user ); - })->then( sub { - matrix_invite_group_user( $creator, $group_id, $remote_user ); - })->then( sub { - matrix_accept_group_invite( $group_id, $remote_user ); - })->then( sub { - matrix_update_group_publicity( $group_id, $local_user, 1 ); - })->then( sub { - matrix_update_group_publicity( $group_id, $remote_user, 1 ); - })->then( sub { - matrix_bulk_get_group_publicity( $creator, $local_user, $remote_user ) - })->then( sub { - my ( $body ) = @_; - - log_if_fail "Body", $body; - - assert_deeply_eq( $body, { - users => { - $local_user->user_id => [ $group_id ], - $remote_user->user_id => [ $group_id ], - } - } ); - - Future->done( 1 ); - }); - }; - - -sub matrix_update_group_publicity -{ - my ( $group_id, $user, $publicise ) = @_; - - do_request_json_for( $user, - method => "PUT", - uri => "/v3/groups/$group_id/self/update_publicity", - content => { - publicise => $publicise ? JSON::true : JSON::false, - }, - ); -} - -sub matrix_get_group_publicity -{ - my ( $user, $other_user ) = @_; - - my $other_user_id = $other_user->user_id; - - do_request_json_for( $user, - method => "GET", - uri => "/v3/publicised_groups/$other_user_id", - ); -} - -sub matrix_bulk_get_group_publicity -{ - my ( $user, @users ) = @_; - - do_request_json_for( $user, - method => "POST", - uri => "/v3/publicised_groups", - content => { - user_ids => [ map { $_->user_id } @users ], - } - ); -} diff --git a/tests/53groups/12joinable.pl b/tests/53groups/12joinable.pl deleted file mode 100644 index e3ccb0f94..000000000 --- a/tests/53groups/12joinable.pl +++ /dev/null @@ -1,130 +0,0 @@ -test "Joinability comes down summary", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ) ], - - do => sub { - my ( $creator ) = @_; - - my $group_id; - - matrix_create_group( $creator ) - ->then( sub { - ( $group_id ) = @_; - - matrix_set_group_join_policy( $group_id, $creator, "open" ); - })->then( sub { - matrix_get_group_summary( $creator, $group_id ); - })->then( sub { - my ( $body ) = @_; - - log_if_fail "Summary Body", $body; - - assert_json_keys( $body, qw( profile ) ); - assert_eq( $body->{profile}->{is_openly_joinable}, JSON::true ); - - matrix_set_group_join_policy( $group_id, $creator, "invite" ); - })->then( sub { - matrix_get_group_summary( $creator, $group_id ); - })->then( sub { - my ( $body ) = @_; - - log_if_fail "Summary Body", $body; - - assert_json_keys( $body, qw( profile ) ); - assert_eq( $body->{profile}->{is_openly_joinable}, JSON::false ); - - Future->done( 1 ); - }); - }; - -test "Set group joinable and join it", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), local_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $creator, $user ) = @_; - - my $group_id; - - matrix_create_group( $creator ) - ->then( sub { - ( $group_id ) = @_; - - matrix_set_group_join_policy( $group_id, $creator, "open" ); - })->then( sub { - matrix_join_group( $group_id, $user ); - })->then( sub { - matrix_get_joined_groups( $user ); - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( groups ) ); - assert_json_list( my $group_ids = $body->{groups} ); - - assert_deeply_eq( $group_ids, [ $group_id ] ); - - Future->done( 1 ); - }); - }; - -test "Group is not joinable by default", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), local_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $creator, $user ) = @_; - - my $group_id; - - matrix_create_group( $creator ) - ->then( sub { - ( $group_id ) = @_; - - matrix_join_group( $group_id, $user ); - })->main::expect_http_403; - }; - -test "Group is joinable over federation", - deprecated_endpoints => 1, - requires => [ local_admin_fixture( with_events => 0 ), remote_user_fixture( with_events => 0 ) ], - - do => sub { - my ( $creator, $user ) = @_; - - my $group_id; - - matrix_create_group( $creator ) - ->then( sub { - ( $group_id ) = @_; - - matrix_set_group_join_policy( $group_id, $creator, "open" ); - })->then( sub { - matrix_join_group( $group_id, $user ); - })->then( sub { - matrix_get_joined_groups( $user ); - })->then( sub { - my ( $body ) = @_; - - assert_json_keys( $body, qw( groups ) ); - assert_json_list( my $group_ids = $body->{groups} ); - - assert_deeply_eq( $group_ids, [ $group_id ] ); - - Future->done( 1 ); - }); - }; - -sub matrix_set_group_join_policy -{ - my ( $group_id, $user, $join_policy ) = @_; - - do_request_json_for( $user, - method => "PUT", - uri => "/v3/groups/$group_id/settings/m.join_policy", - content => { - "m.join_policy" => { - "type" => $join_policy, - }, - }, - ); -} diff --git a/tests/53groups/20room-upgrade.pl b/tests/53groups/20room-upgrade.pl deleted file mode 100644 index fe456d738..000000000 --- a/tests/53groups/20room-upgrade.pl +++ /dev/null @@ -1,111 +0,0 @@ -# Copyright 2018 New Vector Ltd -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -use Future::Utils qw( repeat ); -use List::Util qw( all first none ); - -test "Room is transitioned on local and remote groups upon room upgrade", - deprecated_endpoints => 1, - requires => [ - local_admin_fixture(), - remote_admin_fixture(), - qw( can_upgrade_room_version ) - ], - - do => sub { - my ( $local_user, $remote_user ) = @_; - my ( $room_id, $new_room_id, $local_group_id, $remote_group_id ); - - # Create a to-be-upgraded room - matrix_create_room_synced( - $local_user, - )->then( sub { - ( $room_id, ) = @_; - - matrix_invite_user_to_room_synced( - $local_user, $remote_user, $room_id - ); - })->then( sub { - matrix_join_room_synced( - $remote_user, $room_id, ( server_name => $local_user->server_name, ) - ); - })->then( sub { - # Create groups - matrix_create_group( - $local_user, name => "Local Test Group" - ); - })->then( sub { - ( $local_group_id, ) = @_; - - matrix_create_group( - $remote_user, name => "Remote Test Group", - ); - })->then( sub { - ( $remote_group_id, ) = @_; - - # Add the to-be-upgraded room to groups - matrix_add_group_rooms( - $local_user, $local_group_id, $room_id - ); - })->then( sub { - matrix_add_group_rooms( $remote_user, $remote_group_id, $room_id ); - })->then( sub { - # Upgrade the room - upgrade_room_synced( - $local_user, $room_id, - new_version => $main::TEST_NEW_VERSION, - ); - })->then( sub { - ( $new_room_id, ) = @_; - - matrix_invite_user_to_room_synced( - $local_user, $remote_user, $new_room_id - ); - })->then( sub { - matrix_join_room_synced( - $remote_user, $new_room_id, ( server_name => $local_user->server_name, ) - ); - })->then( sub{ - # Check whether the old and new room exist on each group - matrix_get_group_rooms( $local_user, $local_group_id ); - })->then( sub { - my ( $body, ) = @_; - - log_if_fail "Old room ID: $room_id, New room ID: $new_room_id"; - log_if_fail "Rooms on local group", $body; - - assert_json_keys( $body, qw( chunk ) ); - any { $_->{room_id} eq $new_room_id } @{ $body->{chunk} } - or die "Upgraded room not in local group rooms list"; - - none { $_->{room_id} eq $room_id } @{ $body->{chunk} } - or die "Old room still present in local group rooms list"; - - matrix_get_group_rooms( $remote_user, $remote_group_id ); - })->then( sub { - my ( $body, ) = @_; - - log_if_fail "Old room ID: $room_id, New room ID: $new_room_id"; - log_if_fail "Rooms on remote group", $body; - - assert_json_keys( $body, qw( chunk ) ); - any { $_->{room_id} eq $new_room_id } @{ $body->{chunk} } - or die "Upgraded room not in remote group rooms list"; - - none { $_->{room_id} eq $room_id } @{ $body->{chunk} } - or die "Old room still present in remote group rooms list"; - - Future->done( 1 ); - }); - };