@@ -680,36 +680,6 @@ def test_room_list_sort_order(self):
680
680
reversing the order, etc.
681
681
"""
682
682
683
- def _set_canonical_alias (room_id : str , test_alias : str , admin_user_tok : str ):
684
- # Create a new alias to this room
685
- url = "/_matrix/client/r0/directory/room/%s" % (
686
- urllib .parse .quote (test_alias ),
687
- )
688
- channel = self .make_request (
689
- "PUT" ,
690
- url .encode ("ascii" ),
691
- {"room_id" : room_id },
692
- access_token = admin_user_tok ,
693
- )
694
- self .assertEqual (
695
- 200 , int (channel .result ["code" ]), msg = channel .result ["body" ]
696
- )
697
-
698
- # Set this new alias as the canonical alias for this room
699
- self .helper .send_state (
700
- room_id ,
701
- "m.room.aliases" ,
702
- {"aliases" : [test_alias ]},
703
- tok = admin_user_tok ,
704
- state_key = "test" ,
705
- )
706
- self .helper .send_state (
707
- room_id ,
708
- "m.room.canonical_alias" ,
709
- {"alias" : test_alias },
710
- tok = admin_user_tok ,
711
- )
712
-
713
683
def _order_test (
714
684
order_type : str ,
715
685
expected_room_list : List [str ],
@@ -781,9 +751,9 @@ def _order_test(
781
751
)
782
752
783
753
# Set room canonical room aliases
784
- _set_canonical_alias (room_id_1 , "#A_alias:test" , self .admin_user_tok )
785
- _set_canonical_alias (room_id_2 , "#B_alias:test" , self .admin_user_tok )
786
- _set_canonical_alias (room_id_3 , "#C_alias:test" , self .admin_user_tok )
754
+ self . _set_canonical_alias (room_id_1 , "#A_alias:test" , self .admin_user_tok )
755
+ self . _set_canonical_alias (room_id_2 , "#B_alias:test" , self .admin_user_tok )
756
+ self . _set_canonical_alias (room_id_3 , "#C_alias:test" , self .admin_user_tok )
787
757
788
758
# Set room member size in the reverse order. room 1 -> 1 member, 2 -> 2, 3 -> 3
789
759
user_1 = self .register_user ("bob1" , "pass" )
@@ -850,7 +820,7 @@ def test_search_term(self):
850
820
room_id_2 = self .helper .create_room_as (self .admin_user , tok = self .admin_user_tok )
851
821
852
822
room_name_1 = "something"
853
- room_name_2 = "else "
823
+ room_name_2 = "LoremIpsum "
854
824
855
825
# Set the name for each room
856
826
self .helper .send_state (
@@ -866,6 +836,8 @@ def test_search_term(self):
866
836
tok = self .admin_user_tok ,
867
837
)
868
838
839
+ self ._set_canonical_alias (room_id_1 , "#Room_Alias1:test" , self .admin_user_tok )
840
+
869
841
def _search_test (
870
842
expected_room_id : Optional [str ],
871
843
search_term : str ,
@@ -914,24 +886,36 @@ def _search_test(
914
886
r = rooms [0 ]
915
887
self .assertEqual (expected_room_id , r ["room_id" ])
916
888
917
- # Perform search tests
889
+ # Test searching by room name
918
890
_search_test (room_id_1 , "something" )
919
891
_search_test (room_id_1 , "thing" )
920
892
921
- _search_test (room_id_2 , "else " )
922
- _search_test (room_id_2 , "se " )
893
+ _search_test (room_id_2 , "LoremIpsum " )
894
+ _search_test (room_id_2 , "lorem " )
923
895
924
896
# Test case insensitive
925
897
_search_test (room_id_1 , "SOMETHING" )
926
898
_search_test (room_id_1 , "THING" )
927
899
928
- _search_test (room_id_2 , "ELSE " )
929
- _search_test (room_id_2 , "SE " )
900
+ _search_test (room_id_2 , "LOREMIPSUM " )
901
+ _search_test (room_id_2 , "LOREM " )
930
902
931
903
_search_test (None , "foo" )
932
904
_search_test (None , "bar" )
933
905
_search_test (None , "" , expected_http_code = 400 )
934
906
907
+ # Test that the whole room id returns the room
908
+ _search_test (room_id_1 , room_id_1 )
909
+ # Test that the search by room_id is case sensitive
910
+ _search_test (None , room_id_1 .lower ())
911
+ # Test search part of local part of room id do not match
912
+ _search_test (None , room_id_1 [1 :10 ])
913
+
914
+ # Test that whole room alias return no result, because of domain
915
+ _search_test (None , "#Room_Alias1:test" )
916
+ # Test search local part of alias
917
+ _search_test (room_id_1 , "alias1" )
918
+
935
919
def test_search_term_non_ascii (self ):
936
920
"""Test that searching for a room with non-ASCII characters works correctly"""
937
921
@@ -1114,6 +1098,32 @@ def test_room_state(self):
1114
1098
# the create_room already does the right thing, so no need to verify that we got
1115
1099
# the state events it created.
1116
1100
1101
+ def _set_canonical_alias (self , room_id : str , test_alias : str , admin_user_tok : str ):
1102
+ # Create a new alias to this room
1103
+ url = "/_matrix/client/r0/directory/room/%s" % (urllib .parse .quote (test_alias ),)
1104
+ channel = self .make_request (
1105
+ "PUT" ,
1106
+ url .encode ("ascii" ),
1107
+ {"room_id" : room_id },
1108
+ access_token = admin_user_tok ,
1109
+ )
1110
+ self .assertEqual (200 , int (channel .result ["code" ]), msg = channel .result ["body" ])
1111
+
1112
+ # Set this new alias as the canonical alias for this room
1113
+ self .helper .send_state (
1114
+ room_id ,
1115
+ "m.room.aliases" ,
1116
+ {"aliases" : [test_alias ]},
1117
+ tok = admin_user_tok ,
1118
+ state_key = "test" ,
1119
+ )
1120
+ self .helper .send_state (
1121
+ room_id ,
1122
+ "m.room.canonical_alias" ,
1123
+ {"alias" : test_alias },
1124
+ tok = admin_user_tok ,
1125
+ )
1126
+
1117
1127
1118
1128
class JoinAliasRoomTestCase (unittest .HomeserverTestCase ):
1119
1129
0 commit comments