realm_aliases: Add a test for adding an alias which is already claimed.

Fixes: #3514.
This commit is contained in:
Harshit Bansal 2017-01-30 18:30:57 +00:00 committed by Tim Abbott
parent 85cee51c68
commit 9bbe0efd77
1 changed files with 7 additions and 0 deletions

View File

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import absolute_import from __future__ import absolute_import
from zerver.lib.actions import do_create_realm
from zerver.lib.test_classes import ZulipTestCase from zerver.lib.test_classes import ZulipTestCase
from zerver.models import get_realm, get_realm_by_email_domain, \ from zerver.models import get_realm, get_realm_by_email_domain, \
GetRealmByDomainException, RealmAlias GetRealmByDomainException, RealmAlias
@ -43,6 +44,12 @@ class RealmAliasTest(ZulipTestCase):
result = self.client_post("/json/realm/domains", info=data) result = self.client_post("/json/realm/domains", info=data)
self.assert_json_error(result, 'The domain zulip.org is already a part of your organization.') self.assert_json_error(result, 'The domain zulip.org is already a part of your organization.')
realm1, created = do_create_realm('testrealm', 'Test Realm')
RealmAlias.objects.create(realm=realm1, domain='testrealm.com')
data = {'domain': ujson.dumps('testrealm.com')}
result = self.client_post("/json/realm/domains", info=data)
self.assert_json_error(result, 'The domain testrealm.com belongs to another organization.')
def test_delete(self): def test_delete(self):
# type: () -> None # type: () -> None
self.login("iago@zulip.com") self.login("iago@zulip.com")