Skip to content

Commit

Permalink
test: add tests about idp_id ✅
Browse files Browse the repository at this point in the history
  • Loading branch information
ad2ien committed Jun 4, 2024
1 parent 61ef6b6 commit fbc41ef
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/test_white_list_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import aiounittest
from synapse.api.room_versions import RoomVersions
from synapse.events import EventBase, make_event_from_dict
from synapse.spam_checker_api import RegistrationBehaviour

from tests import MockModuleApi
from white_list_module import EimisWhiteList
Expand Down Expand Up @@ -141,3 +142,36 @@ async def test_get_whitelist_from_content_several_events(self):
self.assertTrue("yvonne" in result)
self.assertTrue("potiron" in result)
self.assertTrue("glandine" in result)

async def test_check_registration_whitelist_other_idp(self):

result = await self.module.check_registration_whitelist(
None, "yvonne", [], "not_idp"
)
self.assertEqual(result, RegistrationBehaviour.ALLOW)

async def test_check_registration_whitelist_no_idp(self):
config = EimisWhiteList.parse_config(
{
"idp_id": "",
"room_id": "room_id",
}
)
module = EimisWhiteList(config, MockModuleApi())

result = await module.check_registration_whitelist(
None, "yvonne", [], "not_idp"
)
self.assertEqual(result, RegistrationBehaviour.ALLOW)


def test_parse_config():
config = EimisWhiteList.parse_config(
{
"idp_id": "idp_id",
"room_id": "room_id",
}
)

assert config.idp_id == "oidc-idp_id"
assert config.room_id == "room_id"

0 comments on commit fbc41ef

Please sign in to comment.