-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show invitation link if email server not setup (#3519)
* return invite link to client if e-mail server is not set up * add a couple of tests to make sure invite links are only returned when neccessary * show invite link when e-mail is not configured * remove "an e-mail has been sent" when there's no e-mail configured * return invite_url in re-invites as well. Also refactor to reuse the code.
- Loading branch information
Omer Lachish
authored
Mar 3, 2019
1 parent
e7db5ca
commit e9603f5
Showing
3 changed files
with
50 additions
and
11 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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from redash import models | ||
from redash import models, settings | ||
from tests import BaseTestCase | ||
from mock import patch | ||
|
||
|
@@ -40,6 +40,34 @@ def test_creates_user(self): | |
self.assertEqual(rv.json['name'], test_user['name']) | ||
self.assertEqual(rv.json['email'], test_user['email']) | ||
|
||
def test_shows_invite_link_when_email_is_not_configured(self): | ||
previous = settings.MAIL_DEFAULT_SENDER | ||
settings.MAIL_DEFAULT_SENDER = None | ||
|
||
admin = self.factory.create_admin() | ||
|
||
test_user = {'name': 'User', 'email': '[email protected]'} | ||
rv = self.make_request('post', '/api/users', data=test_user, user=admin) | ||
|
||
self.assertEqual(rv.status_code, 200) | ||
self.assertTrue('invite_link' in rv.json) | ||
|
||
settings.MAIL_DEFAULT_SENDER = previous | ||
|
||
def test_does_not_show_invite_link_when_email_is_configured(self): | ||
previous = settings.MAIL_DEFAULT_SENDER | ||
settings.MAIL_DEFAULT_SENDER = "[email protected]" | ||
|
||
admin = self.factory.create_admin() | ||
|
||
test_user = {'name': 'User', 'email': '[email protected]'} | ||
rv = self.make_request('post', '/api/users', data=test_user, user=admin) | ||
|
||
self.assertEqual(rv.status_code, 200) | ||
self.assertFalse('invite_link' in rv.json) | ||
|
||
settings.MAIL_DEFAULT_SENDER = previous | ||
|
||
def test_creates_user_case_insensitive_email(self): | ||
admin = self.factory.create_admin() | ||
|
||
|