-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into chore/baseimage
- Loading branch information
Showing
13 changed files
with
92 additions
and
33 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
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
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 |
---|---|---|
|
@@ -7,19 +7,25 @@ | |
def test_login_user_already_in_db(db_session): | ||
""" | ||
Test that if a user is already in the database and logs in, the session will contain | ||
the user's information. | ||
the user's information (including additional information that may have been provided | ||
during the login like email and id_from_idp) | ||
""" | ||
email = "[email protected]" | ||
provider = "Test Provider" | ||
id_from_idp = "Provider_ID_0001" | ||
|
||
test_user = User(username=email, is_admin=False) | ||
db_session.add(test_user) | ||
db_session.commit() | ||
user_id = str(test_user.id) | ||
assert not test_user.email | ||
assert not test_user.id_from_idp | ||
|
||
login_user(email, provider) | ||
login_user(email, provider, email=email, id_from_idp=id_from_idp) | ||
|
||
assert test_user.identity_provider.name == provider | ||
assert test_user.id_from_idp == id_from_idp | ||
assert test_user.email == email | ||
assert flask.session["username"] == email | ||
assert flask.session["provider"] == provider | ||
assert flask.session["user_id"] == user_id | ||
|
@@ -33,18 +39,23 @@ def test_login_user_with_idp_already_in_db(db_session): | |
""" | ||
email = "[email protected]" | ||
provider = "Test Provider" | ||
id_from_idp = "Provider_ID_0001" | ||
|
||
test_user = User(username=email, is_admin=False) | ||
test_user = User( | ||
username=email, email=email, id_from_idp=id_from_idp, is_admin=False | ||
) | ||
test_idp = IdentityProvider(name=provider) | ||
test_user.identity_provider = test_idp | ||
|
||
db_session.add(test_user) | ||
db_session.commit() | ||
user_id = str(test_user.id) | ||
|
||
login_user(email, provider) | ||
login_user(email, provider, email=email, id_from_idp=id_from_idp) | ||
|
||
assert test_user.identity_provider.name == provider | ||
assert test_user.id_from_idp == id_from_idp | ||
assert test_user.email == email | ||
assert flask.session["username"] == email | ||
assert flask.session["provider"] == provider | ||
assert flask.session["user_id"] == user_id | ||
|
@@ -58,12 +69,15 @@ def test_login_new_user(db_session): | |
""" | ||
email = "[email protected]" | ||
provider = "Test Provider" | ||
id_from_idp = "Provider_ID_0001" | ||
|
||
login_user(email, provider) | ||
login_user(email, provider, email=email, id_from_idp=id_from_idp) | ||
|
||
test_user = db_session.query(User).filter(User.username == email.lower()).first() | ||
|
||
assert test_user.identity_provider.name == provider | ||
assert test_user.id_from_idp == id_from_idp | ||
assert test_user.email == email | ||
assert flask.session["username"] == email | ||
assert flask.session["provider"] == provider | ||
assert flask.session["user_id"] == str(test_user.id) | ||
|
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