Skip to content

Commit

Permalink
Add test for email shown in SAML authorization confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
vrajmohan committed Dec 19, 2024
1 parent cd04e19 commit 4571446
Showing 1 changed file with 37 additions and 8 deletions.
45 changes: 37 additions & 8 deletions spec/features/saml/authorization_confirmation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,45 @@ def create_user_and_remember_device
user1
end

it 'confirms the user wants to continue to SP with signin email after signing in again' do
second_email = create(:email_address, user: user1)
sign_in_user(user1, second_email.email)
context 'when the user is already signed in with an email different from the one shared' do
context 'when email sharing feature is enabled' do
before do
allow(IdentityConfig.store)
.to receive(:feature_select_email_to_share_enabled).and_return(true)
end

it 'confirms the user wants to continue to SP with the shared email' do
shared_email = user1.identities.first.email_address.email
second_email = create(:email_address, user: user1)
sign_in_user(user1, second_email.email)

visit request_url
expect(current_url).to match(user_authorization_confirmation_path)
expect(page).to have_content shared_email

continue_as(shared_email)
expect(current_url).to eq(complete_saml_url)
end
end

visit request_url
expect(current_url).to match(user_authorization_confirmation_path)
expect(page).to have_content second_email.email
context 'when email sharing feature is disabled' do
before do
allow(IdentityConfig.store)
.to receive(:feature_select_email_to_share_enabled).and_return(false)
end

continue_as(second_email.email)
expect(current_url).to eq(complete_saml_url)
it 'confirms the user wants to continue to SP with the signed in email' do
second_email = create(:email_address, user: user1)
sign_in_user(user1, second_email.email)

visit request_url
expect(current_url).to match(user_authorization_confirmation_path)
expect(page).to have_content second_email.email

continue_as(second_email.email)
expect(current_url).to eq(complete_saml_url)
end
end
end

it 'allows the user to switch accounts prior to continuing to the SP' do
Expand Down

0 comments on commit 4571446

Please sign in to comment.