summary refs log tree commit diff
path: root/tests/handlers
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/handlers/test_admin.py1
-rw-r--r--tests/handlers/test_appservice.py1
-rw-r--r--tests/handlers/test_auth.py1
-rw-r--r--tests/handlers/test_cas.py1
-rw-r--r--tests/handlers/test_deactivate_account.py1
-rw-r--r--tests/handlers/test_device.py2
-rw-r--r--tests/handlers/test_directory.py53
-rw-r--r--tests/handlers/test_e2e_keys.py2
-rw-r--r--tests/handlers/test_e2e_room_keys.py2
-rw-r--r--tests/handlers/test_federation.py1
-rw-r--r--tests/handlers/test_federation_event.py1
-rw-r--r--tests/handlers/test_message.py1
-rw-r--r--tests/handlers/test_oauth_delegation.py1
-rw-r--r--tests/handlers/test_oidc.py1
-rw-r--r--tests/handlers/test_password_providers.py1
-rw-r--r--tests/handlers/test_presence.py1
-rw-r--r--tests/handlers/test_profile.py1
-rw-r--r--tests/handlers/test_receipts.py1
-rw-r--r--tests/handlers/test_register.py1
-rw-r--r--tests/handlers/test_room_summary.py1
-rw-r--r--tests/handlers/test_saml.py1
-rw-r--r--tests/handlers/test_send_email.py1
-rw-r--r--tests/handlers/test_typing.py1
-rw-r--r--tests/handlers/test_worker_lock.py1
24 files changed, 51 insertions, 28 deletions
diff --git a/tests/handlers/test_admin.py b/tests/handlers/test_admin.py

index 09793c56a9..9ff853a83d 100644 --- a/tests/handlers/test_admin.py +++ b/tests/handlers/test_admin.py
@@ -1,6 +1,7 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2019 The Matrix.org Foundation C.I.C. # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify diff --git a/tests/handlers/test_appservice.py b/tests/handlers/test_appservice.py
index 2bce5afbd4..1eec0d43b7 100644 --- a/tests/handlers/test_appservice.py +++ b/tests/handlers/test_appservice.py
@@ -1,6 +1,7 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2015-2021 The Matrix.org Foundation C.I.C. # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify diff --git a/tests/handlers/test_auth.py b/tests/handlers/test_auth.py
index af6e5a8a77..c417431e85 100644 --- a/tests/handlers/test_auth.py +++ b/tests/handlers/test_auth.py
@@ -1,6 +1,7 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2015, 2016 OpenMarket Ltd # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify diff --git a/tests/handlers/test_cas.py b/tests/handlers/test_cas.py
index 36acbd790d..f41f7d36ad 100644 --- a/tests/handlers/test_cas.py +++ b/tests/handlers/test_cas.py
@@ -1,6 +1,7 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2020 The Matrix.org Foundation C.I.C. # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify diff --git a/tests/handlers/test_deactivate_account.py b/tests/handlers/test_deactivate_account.py
index 1adc6d8854..25ac68e6c5 100644 --- a/tests/handlers/test_deactivate_account.py +++ b/tests/handlers/test_deactivate_account.py
@@ -1,6 +1,7 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2021 The Matrix.org Foundation C.I.C. # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify diff --git a/tests/handlers/test_device.py b/tests/handlers/test_device.py
index 4369a50281..080e6a7028 100644 --- a/tests/handlers/test_device.py +++ b/tests/handlers/test_device.py
@@ -1,6 +1,8 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2020 The Matrix.org Foundation C.I.C. +# Copyright 2016 OpenMarket Ltd # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify diff --git a/tests/handlers/test_directory.py b/tests/handlers/test_directory.py
index 03c360cca6..4a3e36ffde 100644 --- a/tests/handlers/test_directory.py +++ b/tests/handlers/test_directory.py
@@ -1,6 +1,8 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2021 Matrix.org Foundation C.I.C. +# Copyright 2014-2016 OpenMarket Ltd # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify @@ -496,19 +498,27 @@ class TestCreatePublishedRoomACL(unittest.HomeserverTestCase): self.denied_user_id = self.register_user("denied", "pass") self.denied_access_token = self.login("denied", "pass") + self.store = hs.get_datastores().main + def test_denied_without_publication_permission(self) -> None: """ - Try to create a room, register an alias for it, and publish it, + Try to create a room, register a valid alias for it, and publish it, as a user without permission to publish rooms. - (This is used as both a standalone test & as a helper function.) + The room should be created but not published. """ - self.helper.create_room_as( + room_id = self.helper.create_room_as( self.denied_user_id, tok=self.denied_access_token, extra_content=self.data, is_public=True, - expect_code=403, + expect_code=200, ) + res = self.get_success(self.store.get_room(room_id)) + assert res is not None + is_public, _ = res + + # room creation completes but room is not published to directory + self.assertEqual(is_public, False) def test_allowed_when_creating_private_room(self) -> None: """ @@ -526,9 +536,8 @@ class TestCreatePublishedRoomACL(unittest.HomeserverTestCase): def test_allowed_with_publication_permission(self) -> None: """ - Try to create a room, register an alias for it, and publish it, + Try to create a room, register a valid alias for it, and publish it, as a user WITH permission to publish rooms. - (This is used as both a standalone test & as a helper function.) """ self.helper.create_room_as( self.allowed_user_id, @@ -540,38 +549,26 @@ class TestCreatePublishedRoomACL(unittest.HomeserverTestCase): def test_denied_publication_with_invalid_alias(self) -> None: """ - Try to create a room, register an alias for it, and publish it, + Try to create a room, register an invalid alias for it, and publish it, as a user WITH permission to publish rooms. """ - self.helper.create_room_as( + room_id = self.helper.create_room_as( self.allowed_user_id, tok=self.allowed_access_token, extra_content={"room_alias_name": "foo"}, is_public=True, - expect_code=403, + expect_code=200, ) - def test_can_create_as_private_room_after_rejection(self) -> None: - """ - After failing to publish a room with an alias as a user without publish permission, - retry as the same user, but without publishing the room. + # the room is created with the requested alias, but the room is not published + res = self.get_success(self.store.get_room(room_id)) + assert res is not None + is_public, _ = res - This should pass, but used to fail because the alias was registered by the first - request, even though the room creation was denied. - """ - self.test_denied_without_publication_permission() - self.test_allowed_when_creating_private_room() - - def test_can_create_with_permission_after_rejection(self) -> None: - """ - After failing to publish a room with an alias as a user without publish permission, - retry as someone with permission, using the same alias. + self.assertFalse(is_public) - This also used to fail because of the alias having been registered by the first - request, leaving it unavailable for any other user's new rooms. - """ - self.test_denied_without_publication_permission() - self.test_allowed_with_publication_permission() + aliases = self.get_success(self.store.get_aliases_for_room(room_id)) + self.assertEqual(aliases[0], "#foo:test") class TestRoomListSearchDisabled(unittest.HomeserverTestCase): diff --git a/tests/handlers/test_e2e_keys.py b/tests/handlers/test_e2e_keys.py
index aa375fa218..3d931abb06 100644 --- a/tests/handlers/test_e2e_keys.py +++ b/tests/handlers/test_e2e_keys.py
@@ -1,6 +1,8 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2019 The Matrix.org Foundation C.I.C. +# Copyright 2016 OpenMarket Ltd # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify diff --git a/tests/handlers/test_e2e_room_keys.py b/tests/handlers/test_e2e_room_keys.py
index 3217639176..3ec46402b7 100644 --- a/tests/handlers/test_e2e_room_keys.py +++ b/tests/handlers/test_e2e_room_keys.py
@@ -1,6 +1,8 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2019 Matrix.org Foundation C.I.C. +# Copyright 2016 OpenMarket Ltd # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify diff --git a/tests/handlers/test_federation.py b/tests/handlers/test_federation.py
index 8e2ad42ab8..b819b60c5d 100644 --- a/tests/handlers/test_federation.py +++ b/tests/handlers/test_federation.py
@@ -1,6 +1,7 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2019 The Matrix.org Foundation C.I.C. # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify diff --git a/tests/handlers/test_federation_event.py b/tests/handlers/test_federation_event.py
index 938c5dec60..1b83aea579 100644 --- a/tests/handlers/test_federation_event.py +++ b/tests/handlers/test_federation_event.py
@@ -1,6 +1,7 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2022 The Matrix.org Foundation C.I.C. # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify diff --git a/tests/handlers/test_message.py b/tests/handlers/test_message.py
index 802f96ed48..0ee5eee385 100644 --- a/tests/handlers/test_message.py +++ b/tests/handlers/test_message.py
@@ -1,6 +1,7 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2020 The Matrix.org Foundation C.I.C. # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify diff --git a/tests/handlers/test_oauth_delegation.py b/tests/handlers/test_oauth_delegation.py
index b9761d806d..9387d07de8 100644 --- a/tests/handlers/test_oauth_delegation.py +++ b/tests/handlers/test_oauth_delegation.py
@@ -1,6 +1,7 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2022 Matrix.org Foundation C.I.C. # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify diff --git a/tests/handlers/test_oidc.py b/tests/handlers/test_oidc.py
index df30a80734..a81501979d 100644 --- a/tests/handlers/test_oidc.py +++ b/tests/handlers/test_oidc.py
@@ -1,6 +1,7 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2020 Quentin Gliech # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify diff --git a/tests/handlers/test_password_providers.py b/tests/handlers/test_password_providers.py
index b3248fa491..ed203eb299 100644 --- a/tests/handlers/test_password_providers.py +++ b/tests/handlers/test_password_providers.py
@@ -1,6 +1,7 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2020 The Matrix.org Foundation C.I.C. # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify diff --git a/tests/handlers/test_presence.py b/tests/handlers/test_presence.py
index c68e8c6631..cc630d606c 100644 --- a/tests/handlers/test_presence.py +++ b/tests/handlers/test_presence.py
@@ -1,6 +1,7 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2016 OpenMarket Ltd # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify diff --git a/tests/handlers/test_profile.py b/tests/handlers/test_profile.py
index d70026c31e..cb1c6fbb80 100644 --- a/tests/handlers/test_profile.py +++ b/tests/handlers/test_profile.py
@@ -1,6 +1,7 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2014-2016 OpenMarket Ltd # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify diff --git a/tests/handlers/test_receipts.py b/tests/handlers/test_receipts.py
index 3c14dfa0a8..7c5bec2b76 100644 --- a/tests/handlers/test_receipts.py +++ b/tests/handlers/test_receipts.py
@@ -1,6 +1,7 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2021 Šimon Brandner <simon.bra.ag@gmail.com> # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify diff --git a/tests/handlers/test_register.py b/tests/handlers/test_register.py
index 36255270ed..92487692db 100644 --- a/tests/handlers/test_register.py +++ b/tests/handlers/test_register.py
@@ -1,6 +1,7 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2015, 2016 OpenMarket Ltd # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify diff --git a/tests/handlers/test_room_summary.py b/tests/handlers/test_room_summary.py
index 929772c412..244a4e7689 100644 --- a/tests/handlers/test_room_summary.py +++ b/tests/handlers/test_room_summary.py
@@ -1,6 +1,7 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2021 The Matrix.org Foundation C.I.C. # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify diff --git a/tests/handlers/test_saml.py b/tests/handlers/test_saml.py
index 9d7cd4ee6f..6ab8fda6e7 100644 --- a/tests/handlers/test_saml.py +++ b/tests/handlers/test_saml.py
@@ -1,6 +1,7 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2020 The Matrix.org Foundation C.I.C. # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify diff --git a/tests/handlers/test_send_email.py b/tests/handlers/test_send_email.py
index 73ea7fc346..cedcea27d9 100644 --- a/tests/handlers/test_send_email.py +++ b/tests/handlers/test_send_email.py
@@ -1,6 +1,7 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2021 The Matrix.org Foundation C.I.C. # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify diff --git a/tests/handlers/test_typing.py b/tests/handlers/test_typing.py
index c410fe7cc4..c754083967 100644 --- a/tests/handlers/test_typing.py +++ b/tests/handlers/test_typing.py
@@ -1,6 +1,7 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2014-2016 OpenMarket Ltd # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify diff --git a/tests/handlers/test_worker_lock.py b/tests/handlers/test_worker_lock.py
index 8fec3d6bb7..3a4cf82094 100644 --- a/tests/handlers/test_worker_lock.py +++ b/tests/handlers/test_worker_lock.py
@@ -1,6 +1,7 @@ # # This file is licensed under the Affero General Public License (AGPL) version 3. # +# Copyright 2023 The Matrix.org Foundation C.I.C. # Copyright (C) 2023 New Vector, Ltd # # This program is free software: you can redistribute it and/or modify