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
3 changes: 3 additions & 0 deletions app/controllers/users/verify_account_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ class VerifyAccountController < ApplicationController

def index
@verify_account_form = VerifyAccountForm.new(user: current_user)

return unless FeatureManagement.reveal_usps_code?
@code = JSON.parse(user_session[:decrypted_pii])['otp']['raw']
end

def create
Expand Down
3 changes: 1 addition & 2 deletions app/views/users/verify_account/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ p.mt-tiny.mb0 = t('forms.verify_profile.instructions')
html: { autocomplete: 'off', method: :post, role: 'form' }) do |f|
= f.error :base
= f.input :otp, required: true, label: t('forms.verify_profile.name'), wrapper: :inline_form do
= f.input_field :otp, as: :inline, autofocus: true, type: 'text', maxlength: '10'
= f.input_field :otp, as: :inline, autofocus: true, type: 'text', maxlength: '10', value: @code
= f.button :submit, t('forms.verify_profile.submit')
end
12 changes: 12 additions & 0 deletions lib/feature_management.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
class FeatureManagement
PT_DOMAIN_NAME = 'idp.pt.login.gov'.freeze

ENVS_WHERE_PREFILLING_USPS_CODE_ALLOWED = %w[
idp.dev.login.gov idp.int.login.gov idp.qa.login.gov
].freeze

def self.telephony_disabled?
Figaro.env.telephony_disabled == 'true'
end
Expand Down Expand Up @@ -43,4 +47,12 @@ def self.use_dashboard_service_providers?
def self.enable_identity_verification?
Figaro.env.enable_identity_verification == 'true'
end

def self.reveal_usps_code?
Rails.env.development? || current_env_allowed_to_see_usps_code?
end

def self.current_env_allowed_to_see_usps_code?
ENVS_WHERE_PREFILLING_USPS_CODE_ALLOWED.include?(Figaro.env.domain_name)
end
end
3 changes: 2 additions & 1 deletion spec/features/openid_connect/openid_connect_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,12 @@
let(:phone_confirmed) { false }

it 'prompts to finish verifying profile, then redirects to SP' do
allow(FeatureManagement).to receive(:reveal_usps_code?).and_return(true)

visit oidc_auth_url

sign_in_live_with_2fa(user)

fill_in t('forms.verify_profile.name'), with: usps_otp_code_for(user)
click_button t('forms.verify_profile.submit')

expect(current_path).to eq(sign_up_completed_path)
Expand Down
3 changes: 2 additions & 1 deletion spec/features/saml/loa3_sso_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,14 @@
let(:phone_confirmed) { false }

it 'prompts for confirmation code at sign in' do
allow(FeatureManagement).to receive(:reveal_usps_code?).and_return(true)

saml_authn_request = auth_request.create(loa3_with_bundle_saml_settings)
visit saml_authn_request
sign_in_live_with_2fa(user)

expect(current_path).to eq verify_account_path

fill_in t('forms.verify_profile.name'), with: usps_otp_code_for(user)
click_button t('forms.verify_profile.submit')

expect(current_path).to eq(sign_up_completed_path)
Expand Down
29 changes: 29 additions & 0 deletions spec/lib/feature_management_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,33 @@
end
end
end

describe '#reveal_usps_code?' do
context 'server domain name is dev, qa, or int' do
it 'returns true' do
%w[idp.dev.login.gov idp.int.login.gov idp.qa.login.gov].each do |domain|
allow(Figaro.env).to receive(:domain_name).and_return(domain)

expect(FeatureManagement.reveal_usps_code?).to eq(true)
end
end
end

context 'Rails env is development' do
it 'returns true' do
allow(Rails.env).to receive(:development?).and_return(true)

expect(FeatureManagement.reveal_usps_code?).to eq(true)
end
end

context 'Rails env is not development and server is not dev, qa, or int' do
it 'returns false' do
allow(Rails.env).to receive(:development?).and_return(false)
allow(Figaro.env).to receive(:domain_name).and_return('foo.login.gov')

expect(FeatureManagement.reveal_usps_code?).to eq(false)
end
end
end
end
4 changes: 0 additions & 4 deletions spec/support/features/idv_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ def user_password
Features::SessionHelper::VALID_PASSWORD
end

def usps_otp_code_for(user)
user.profiles.first.decrypt_pii(user.unlock_user_access_key(user.password))[:otp]
end

def fill_out_idv_form_ok
fill_in 'profile_first_name', with: 'José'
fill_in 'profile_last_name', with: 'One'
Expand Down