2019-04-04 18:25:47 +02:00
|
|
|
# Copyright 2019 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.
|
|
|
|
|
|
|
|
import json
|
|
|
|
|
2019-05-01 16:32:38 +02:00
|
|
|
import synapse.rest.admin
|
2021-08-17 13:57:58 +02:00
|
|
|
from synapse.rest.client import login, room
|
2019-04-04 18:25:47 +02:00
|
|
|
|
|
|
|
from tests import unittest
|
|
|
|
|
|
|
|
|
|
|
|
class IdentityTestCase(unittest.HomeserverTestCase):
|
|
|
|
|
|
|
|
servlets = [
|
2019-05-02 12:59:16 +02:00
|
|
|
synapse.rest.admin.register_servlets_for_client_rest_resource,
|
2019-04-04 18:25:47 +02:00
|
|
|
room.register_servlets,
|
|
|
|
login.register_servlets,
|
|
|
|
]
|
|
|
|
|
|
|
|
def make_homeserver(self, reactor, clock):
|
|
|
|
|
|
|
|
config = self.default_config()
|
2019-05-13 22:01:14 +02:00
|
|
|
config["enable_3pid_lookup"] = False
|
2019-04-04 18:25:47 +02:00
|
|
|
self.hs = self.setup_test_homeserver(config=config)
|
|
|
|
|
|
|
|
return self.hs
|
|
|
|
|
|
|
|
def test_3pid_lookup_disabled(self):
|
2021-10-04 13:18:54 +02:00
|
|
|
self.hs.config.registration.enable_3pid_lookup = False
|
2019-04-04 18:25:47 +02:00
|
|
|
|
|
|
|
self.register_user("kermit", "monkey")
|
|
|
|
tok = self.login("kermit", "monkey")
|
|
|
|
|
2020-12-15 15:44:04 +01:00
|
|
|
channel = self.make_request(b"POST", "/createRoom", b"{}", access_token=tok)
|
2019-04-04 18:25:47 +02:00
|
|
|
self.assertEquals(channel.result["code"], b"200", channel.result)
|
|
|
|
room_id = channel.json_body["room_id"]
|
|
|
|
|
|
|
|
params = {
|
|
|
|
"id_server": "testis",
|
|
|
|
"medium": "email",
|
|
|
|
"address": "test@example.com",
|
|
|
|
}
|
|
|
|
request_data = json.dumps(params)
|
2019-06-20 11:32:02 +02:00
|
|
|
request_url = ("/rooms/%s/invite" % (room_id)).encode("ascii")
|
2020-12-15 15:44:04 +01:00
|
|
|
channel = self.make_request(
|
2019-05-10 07:12:11 +02:00
|
|
|
b"POST", request_url, request_data, access_token=tok
|
2019-04-04 18:25:47 +02:00
|
|
|
)
|
|
|
|
self.assertEquals(channel.result["code"], b"403", channel.result)
|