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
7 changes: 6 additions & 1 deletion app/controllers/verify/usps_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ def index
def create
create_user_event(:usps_mail_sent, current_user)
idv_session.address_verification_mechanism = :usps
redirect_to verify_review_url

if current_user.decorate.needs_profile_usps_verification?
redirect_to account_path
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Climate says this is not tested. Can you double check that the specs are performing the correct steps? I would expect at least one of those specs (if not both) to have an expectation that the user ends up on the account_path.

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.

hmmm. Yeah, I'll check.

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.

the flow just wasn't completed. I updated the specs and Code Climate should be happy now

else
redirect_to verify_review_url
end
end

def usps_mail_service
Expand Down
54 changes: 44 additions & 10 deletions spec/features/saml/loa3_sso_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
include SamlAuthHelper
include IdvHelper

def perform_id_verification_with_usps_without_confirming_code_then_sign_out(user)
def perform_id_verification_with_usps_without_confirming_code(user)
allow(FeatureManagement).to receive(:prefill_otp_codes?).and_return(true)
saml_authn_request = auth_request.create(loa3_with_bundle_saml_settings)
visit saml_authn_request
sign_in_live_with_2fa(user)
click_link t('links.sign_in')
fill_in_credentials_and_submit(user.email, user.password)
click_submit_default
click_idv_begin
fill_out_idv_form_ok
click_idv_continue
Expand All @@ -18,6 +21,9 @@ def perform_id_verification_with_usps_without_confirming_code_then_sign_out(user
fill_in :user_password, with: user.password
click_submit_default
click_acknowledge_personal_key
end

def sign_out_user
first(:link, t('links.sign_out')).click
click_submit_default
end
Expand Down Expand Up @@ -217,19 +223,47 @@ def perform_id_verification_with_usps_without_confirming_code_then_sign_out(user
expect(current_url).to eq saml_authn_request
end

it 'provides an option to send another letter' do
user = create(:user, :signed_up)
context 'provides an option to send another letter' do
it 'without signing out' do
user = create(:user, :signed_up)

perform_id_verification_with_usps_without_confirming_code_then_sign_out(user)
perform_id_verification_with_usps_without_confirming_code(user)

sign_in_live_with_2fa(user)
expect(current_path).to eq account_path

expect(current_path).to eq verify_account_path
click_link(t('account.index.verification.reactivate_button'))

expect(current_path).to eq verify_account_path

click_link(t('idv.messages.usps.resend'))

expect(user.events.account_verified.size).to be(0)
expect(current_path).to eq(verify_usps_path)

click_button(t('idv.buttons.mail.resend'))

expect(current_path).to eq(account_path)
end

it 'after signing out' do
user = create(:user, :signed_up)

perform_id_verification_with_usps_without_confirming_code(user)
sign_out_user

sign_in_live_with_2fa(user)

expect(current_path).to eq verify_account_path

click_link(t('idv.messages.usps.resend'))

expect(user.events.account_verified.size).to be(0)
expect(current_path).to eq(verify_usps_path)

click_link(t('idv.messages.usps.resend'))
click_button(t('idv.buttons.mail.resend'))

expect(user.events.account_verified.size).to be(0)
expect(current_path).to eq(verify_usps_path)
expect(current_path).to eq(account_path)
end
end
end

Expand Down