-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2450 from onaio/multiple-domains-update
Ensure onadata can work in a multi-domain setup
- Loading branch information
Showing
23 changed files
with
309 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2841,7 +2841,13 @@ def test_only_admins_allowed(self, mock_send_mail): | |
else: | ||
self.assertEqual(response.status_code, 403) | ||
|
||
@override_settings(PROJECT_INVITATION_URL="https://example.com/register") | ||
@override_settings( | ||
PROJECT_INVITATION_URL={ | ||
"*": "https://example.com/register", | ||
"onadata.com": "https://onadata.com/register", | ||
} | ||
) | ||
@override_settings(ALLOWED_HOSTS=["*"]) | ||
def test_create_invitation(self, mock_send_mail): | ||
"""Project invitation can be created""" | ||
post_data = { | ||
|
@@ -2882,6 +2888,35 @@ def test_create_invitation(self, mock_send_mail): | |
response = self.view(request, pk=self.project.pk) | ||
self.assertEqual(response.status_code, 400) | ||
|
||
# Project invitations are created for non-default host | ||
post_data = { | ||
"email": "[email protected]", | ||
"role": "editor", | ||
} | ||
request = self.factory.post( | ||
"/", | ||
data=json.dumps(post_data), | ||
content_type="application/json", | ||
**self.extra, | ||
) | ||
request.META["HTTP_HOST"] = "onadata.com" | ||
response = self.view(request, pk=self.project.pk) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(self.project.invitations.count(), 2) | ||
invitation = self.project.invitations.last() | ||
self.assertEqual( | ||
response.data, | ||
{ | ||
"id": invitation.pk, | ||
"email": "[email protected]", | ||
"role": "editor", | ||
"status": 1, | ||
}, | ||
) | ||
mock_send_mail.assert_called_with( | ||
invitation.pk, "https://onadata.com/register" | ||
) | ||
|
||
def test_email_required(self, mock_send_mail): | ||
"""email is required""" | ||
# blank string | ||
|
@@ -3073,7 +3108,7 @@ def test_only_admins_allowed(self, mock_send_mail): | |
else: | ||
self.assertEqual(response.status_code, 403) | ||
|
||
@override_settings(PROJECT_INVITATION_URL="https://example.com/register") | ||
@override_settings(PROJECT_INVITATION_URL={"*": "https://example.com/register"}) | ||
def test_update(self, mock_send_mail): | ||
"""We can update an invitation""" | ||
payload = { | ||
|
@@ -3133,7 +3168,7 @@ def test_update_role_only(self, mock_send_mail): | |
) | ||
mock_send_mail.assert_not_called() | ||
|
||
@override_settings(PROJECT_INVITATION_URL="https://example.com/register") | ||
@override_settings(PROJECT_INVITATION_URL={"*": "https://example.com/register"}) | ||
def test_update_email_only(self, mock_send_mail): | ||
"""We can update email only""" | ||
payload = { | ||
|
@@ -3351,7 +3386,7 @@ def test_only_admins_allowed(self, mock_send_mail): | |
|
||
mock_send_mail.assert_not_called() | ||
|
||
@override_settings(PROJECT_INVITATION_URL="https://example.com/register") | ||
@override_settings(PROJECT_INVITATION_URL={"*": "https://example.com/register"}) | ||
def test_resend_invite(self, mock_send_mail): | ||
"""Invitation is revoked""" | ||
invitation = self.project.invitations.create( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.