-
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.
- Fixed typo - Added unit tests cases
- Loading branch information
Showing
3 changed files
with
31 additions
and
4 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 |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
get_login_url, | ||
hmac_load_user_from_request, | ||
jwt_auth, | ||
oidc, | ||
org_settings, | ||
sign, | ||
) | ||
|
@@ -177,6 +178,32 @@ def test_prefers_api_key_over_session_user_id(self): | |
self.assertEqual(rv.status_code, 200) | ||
|
||
|
||
class TestCreateAndLoginUserOIDC(BaseTestCase): | ||
def test_logins_valid_user(self): | ||
user = self.factory.create_user(email="[email protected]") | ||
with patch("redash.authentication.login_user") as login_user_mock: | ||
oidc.create_and_login_user(self.factory.org, user.name, user.email) | ||
login_user_mock.assert_called_once_with(user, remember=True) | ||
|
||
def test_creates_vaild_new_user(self): | ||
email = "[email protected]" | ||
name = "Test User" | ||
|
||
with patch("redash.authentication.login_user") as login_user_mock: | ||
oidc.create_and_login_user(self.factory.org, name, email) | ||
|
||
self.assertTrue(login_user_mock.called) | ||
user = models.User.query.filter(models.User.email == email).one() | ||
self.assertEqual(user.email, email) | ||
|
||
def test_updates_user_name(self): | ||
user = self.factory.create_user(email="[email protected]") | ||
|
||
with patch("redash.authentication.login_user") as login_user_mock: | ||
create_and_login_user(self.factory.org, "New Name", user.email) | ||
login_user_mock.assert_called_once_with(user, remember=True) | ||
|
||
|
||
class TestCreateAndLoginUser(BaseTestCase): | ||
def test_logins_valid_user(self): | ||
user = self.factory.create_user(email="[email protected]") | ||
|