Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions spec/features/idv/account_creation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@
it_behaves_like 'idv account creation', :saml
it_behaves_like 'idv account creation', :oidc
end

context 'choosing USPS address verification' do
it_behaves_like 'selecting usps address verification method', :saml
it_behaves_like 'selecting usps address verification method', :oidc
end
end
36 changes: 0 additions & 36 deletions spec/features/saml/loa3_sso_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,42 +35,6 @@ def sign_out_user
@saml_authn_request = auth_request.create(loa3_with_bundle_saml_settings)
end

it 'allows the user to select verification via USPS letter', email: true do
visit @saml_authn_request

register_user(email)

click_idv_begin

fill_out_idv_form_ok
click_idv_continue
fill_out_financial_form_ok
click_idv_continue

click_idv_address_choose_usps

click_on t('idv.buttons.mail.send')

expect(current_path).to eq verify_review_path
expect(page).to_not have_content t('idv.messages.phone.phone_of_record')

fill_in :user_password, with: user_password

expect { click_submit_default }.
to change { UspsConfirmation.count }.from(0).to(1)

expect(current_url).to eq verify_confirmations_url
click_acknowledge_personal_key

expect(User.find_with_email(email).events.account_verified.size).to be(0)
expect(current_url).to eq(account_url)
expect(page).to have_content(t('account.index.verification.reactivate_button'))

usps_confirmation_entry = UspsConfirmation.last.decrypted_entry
expect(usps_confirmation_entry.issuer).
to eq('https://rp1.serviceprovider.com/auth/saml/metadata')
end

it 'shows user the start page with accordion' do
saml_authn_request = auth_request.create(loa3_with_bundle_saml_settings)
sp_content = [
Expand Down
6 changes: 4 additions & 2 deletions spec/support/features/session_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -351,13 +351,15 @@ def set_up_2fa_with_valid_phone
click_send_security_code
end

def register_user(email)
def register_user(email = 'test@test.com')
allow(FeatureManagement).to receive(:prefill_otp_codes?).and_return(true)
click_link t('sign_up.registrations.create_account')
submit_form_with_valid_email
submit_form_with_valid_email(email)
click_confirmation_link_in_email(email)
submit_form_with_valid_password
set_up_2fa_with_valid_phone
enter_2fa_code
User.find_with_email(email)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this so I could do the following in the tests:

user = register_user

...instead of...

email = 'asdf@test.com'
register_user(email)
user = User.find_with_email(email)

end

def sign_in_via_branded_page(user)
Expand Down
1 change: 0 additions & 1 deletion spec/support/idv_examples/account_creation.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
shared_examples 'idv account creation' do |sp|
it 'redirects to SP after IdV is complete', email: true do
allow(FeatureManagement).to receive(:prefill_otp_codes?).and_return(true)
email = 'test@test.com'

visit_idp_from_sp_with_loa3(sp)
Expand Down
52 changes: 52 additions & 0 deletions spec/support/idv_examples/usps_verification_selection.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
shared_examples 'selecting usps address verification method' do |sp|
it 'allows the user to select verification via USPS letter', email: true do
visit_idp_from_sp_with_loa3(sp)

user = register_user

click_idv_begin
fill_out_idv_form_ok
click_idv_continue
fill_out_financial_form_ok
click_idv_continue

click_idv_address_choose_usps

click_on t('idv.buttons.mail.send')

expect(current_path).to eq verify_review_path
expect(page).to_not have_content t('idv.messages.phone.phone_of_record')

fill_in :user_password, with: user_password

expect { click_submit_default }.
to change { UspsConfirmation.count }.from(0).to(1)

expect(current_path).to eq verify_confirmations_path
click_acknowledge_personal_key

user.reload

expect(user.events.account_verified.size).to be(0)
expect(user.profiles.count).to eq 1

profile = user.profiles.first

expect(profile.active?).to eq false
expect(profile.deactivation_reason).to eq 'verification_pending'
expect(profile.phone_confirmed).to eq false

usps_confirmation_entry = UspsConfirmation.last.decrypted_entry

expect(current_path).to eq(account_path)
expect(page).to have_content(t('account.index.verification.reactivate_button'))

if sp == :saml
expect(usps_confirmation_entry.issuer).
to eq('https://rp1.serviceprovider.com/auth/saml/metadata')
elsif sp == :oidc
expect(usps_confirmation_entry.issuer).
to eq('urn:gov:gsa:openidconnect:sp:server')
end
end
end