-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove legacy sign in method migration for office 365 and smartschool
- Loading branch information
Showing
2 changed files
with
1 addition
and
252 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 |
---|---|---|
|
@@ -449,224 +449,6 @@ def omniauth_path(provider) | |
end | ||
end | ||
|
||
test 'Office 365 identifier should be updated upon login if the identifier still used the old format' do | ||
# Setup. | ||
provider = create :office365_provider | ||
user = create :user, institution: provider.institution | ||
identity = create :identity, provider: provider, user: user, identifier: 'Foo.Bar', identifier_based_on_email: true | ||
omniauth_mock_identity identity, | ||
info: { | ||
email: '[email protected]' | ||
}, | ||
uid: 'NEW-UID' | ||
|
||
post omniauth_url(provider) | ||
follow_redirect! | ||
|
||
assert_equal @controller.current_user, user | ||
identity.reload | ||
|
||
assert_equal('NEW-UID', identity.identifier) | ||
|
||
# Cleanup. | ||
sign_out user | ||
|
||
# sign in should still work with changed identifier | ||
omniauth_mock_identity identity, | ||
info: { | ||
email: '[email protected]' | ||
}, | ||
uid: 'NEW-UID' | ||
|
||
post omniauth_url(provider) | ||
follow_redirect! | ||
|
||
# Assert successful authentication. | ||
assert_redirected_to root_path | ||
assert_equal @controller.current_user, user | ||
|
||
# Cleanup. | ||
sign_out user | ||
|
||
# Should not be able to change it again | ||
omniauth_mock_identity identity, | ||
info: { | ||
email: '[email protected]' | ||
}, | ||
uid: 'NEWER-UID' | ||
|
||
post omniauth_url(provider) | ||
follow_redirect! | ||
|
||
# Assert successful authentication. | ||
assert_redirected_to root_path | ||
assert_not_equal @controller.current_user, user | ||
identity.reload | ||
|
||
assert_equal('NEW-UID', identity.identifier) | ||
|
||
# Cleanup. | ||
sign_out user | ||
end | ||
|
||
test 'Office 365 legacy sign in works with prefered username' do | ||
# Setup. | ||
provider = create :office365_provider | ||
user = create :user, institution: provider.institution | ||
identity = create :identity, provider: provider, user: user, identifier: 'Foo.Bar', identifier_based_on_email: true | ||
omniauth_mock_identity identity, | ||
info: { | ||
email: '[email protected]' | ||
}, | ||
extra: { | ||
preferred_username: '[email protected]' | ||
}, | ||
uid: 'NEW-UID' | ||
|
||
post omniauth_url(provider) | ||
follow_redirect! | ||
|
||
assert_equal @controller.current_user, user | ||
identity.reload | ||
|
||
assert_equal('NEW-UID', identity.identifier) | ||
|
||
# Cleanup. | ||
sign_out user | ||
end | ||
|
||
test 'Office 365 legacy sign in works with name' do | ||
# Setup. | ||
provider = create :office365_provider | ||
user = create :user, institution: provider.institution, first_name: 'Foo', last_name: 'Bar' | ||
identity = create :identity, provider: provider, user: user, identifier: 'X.Y', identifier_based_on_email: true | ||
omniauth_mock_identity identity, | ||
info: { | ||
email: '[email protected]' | ||
}, | ||
uid: 'NEW-UID' | ||
|
||
post omniauth_url(provider) | ||
follow_redirect! | ||
|
||
assert_equal @controller.current_user, user | ||
identity.reload | ||
|
||
assert_equal('NEW-UID', identity.identifier) | ||
|
||
# Cleanup. | ||
sign_out user | ||
end | ||
|
||
test 'Smartschool identifier should be updated upon login if the identifier still used the old format' do | ||
# Setup. | ||
provider = create :smartschool_provider | ||
user = create :user, institution: provider.institution | ||
identity = create :identity, provider: provider, user: user, identifier: 'OLD-UID', identifier_based_on_username: true | ||
omniauth_mock_identity identity, | ||
info: { | ||
username: 'OLD-UID' | ||
}, | ||
uid: 'NEW-UID' | ||
|
||
post omniauth_url(provider) | ||
follow_redirect! | ||
|
||
assert_equal @controller.current_user, user | ||
identity.reload | ||
|
||
assert_equal('NEW-UID', identity.identifier) | ||
|
||
# Cleanup. | ||
sign_out user | ||
|
||
# sign in should still work with changed identifier | ||
omniauth_mock_identity identity, | ||
info: { | ||
username: 'OLD-UID' | ||
}, | ||
uid: 'NEW-UID' | ||
|
||
post omniauth_url(provider) | ||
follow_redirect! | ||
|
||
# Assert successful authentication. | ||
assert_redirected_to root_path | ||
assert_equal @controller.current_user, user | ||
|
||
# Cleanup. | ||
sign_out user | ||
|
||
# Should not be able to change it again | ||
omniauth_mock_identity identity, | ||
info: { | ||
username: 'NEW-UID' | ||
}, | ||
uid: 'NEWER-UID' | ||
|
||
post omniauth_url(provider) | ||
follow_redirect! | ||
|
||
# Assert successful authentication. | ||
assert_redirected_to root_path | ||
assert_not_equal @controller.current_user, user | ||
identity.reload | ||
|
||
assert_equal('NEW-UID', identity.identifier) | ||
|
||
# Cleanup. | ||
sign_out user | ||
end | ||
|
||
test 'Smartschool legacy sign in works with email' do | ||
# Setup. | ||
provider = create :smartschool_provider | ||
user = create :user, institution: provider.institution, email: '[email protected]' | ||
identity = create :identity, provider: provider, user: user, identifier: 'OLD-UID', identifier_based_on_username: true | ||
omniauth_mock_identity identity, | ||
info: { | ||
email: '[email protected]', | ||
username: 'NEW-USERNAME' | ||
}, | ||
uid: 'NEW-UID' | ||
|
||
post omniauth_url(provider) | ||
follow_redirect! | ||
|
||
assert_equal @controller.current_user, user | ||
identity.reload | ||
|
||
assert_equal('NEW-UID', identity.identifier) | ||
|
||
# Cleanup. | ||
sign_out user | ||
end | ||
|
||
test 'Smartschool legacy sign in works with name' do | ||
# Setup. | ||
provider = create :smartschool_provider | ||
user = create :user, institution: provider.institution, first_name: 'Foo', last_name: 'Bar' | ||
identity = create :identity, provider: provider, user: user, identifier: 'OLD-UID', identifier_based_on_username: true | ||
omniauth_mock_identity identity, | ||
info: { | ||
first_name: 'Foo', | ||
last_name: 'Bar', | ||
username: 'NEW-USERNAME' | ||
}, | ||
uid: 'NEW-UID' | ||
|
||
post omniauth_url(provider) | ||
follow_redirect! | ||
|
||
assert_equal @controller.current_user, user | ||
identity.reload | ||
|
||
assert_equal('NEW-UID', identity.identifier) | ||
|
||
# Cleanup. | ||
sign_out user | ||
end | ||
|
||
test 'Smartschool co-accounts should be blocked' do | ||
# Setup. | ||
provider = create :smartschool_provider | ||
|