Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Add some basic tests for deleting aliases.
Browse files Browse the repository at this point in the history
  • Loading branch information
clokep committed Feb 13, 2020
1 parent c6b0ba9 commit ecc0a5a
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion tests/handlers/test_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@

from twisted.internet import defer

import synapse.api.errors
from synapse.config.room_directory import RoomDirectoryConfig
from synapse.handlers.directory import DirectoryHandler
from synapse.rest.client.v1 import directory, room
from synapse.types import RoomAlias
from synapse.types import RoomAlias, create_requester

from tests import unittest
from tests.utils import setup_test_homeserver
Expand Down Expand Up @@ -93,6 +94,33 @@ def test_get_remote_association(self):
ignore_backoff=True,
)

@defer.inlineCallbacks
def test_delete_alias_not_allowed(self):
room_id = "!8765qwer:test"
yield self.store.create_room_alias_association(self.my_room, room_id, ["test"])

with self.assertRaises(synapse.api.errors.AuthError):
yield self.handler.delete_association(
create_requester("@user:test"), self.my_room
)

@defer.inlineCallbacks
def test_delete_alias(self):
room_id = "!8765qwer:test"
user_id = "@user:test"
yield self.store.create_room_alias_association(
self.my_room, room_id, ["test"], user_id
)

result = yield self.handler.delete_association(
create_requester(user_id), self.my_room
)
self.assertEquals(room_id, result)

# The alias should not be found.
with self.assertRaises(synapse.api.errors.SynapseError):
yield self.handler.get_association(self.my_room)

@defer.inlineCallbacks
def test_incoming_fed_query(self):
yield self.store.create_room_alias_association(
Expand Down

0 comments on commit ecc0a5a

Please sign in to comment.