diff --git a/app/views/verify/address/index.html.slim b/app/views/verify/address/index.html.slim index 75c1d9cefd1..8044f6c6a4e 100644 --- a/app/views/verify/address/index.html.slim +++ b/app/views/verify/address/index.html.slim @@ -7,8 +7,9 @@ p .sm-col.sm-col-12.md-col-6 = link_to t('idv.buttons.activate_by_phone'), verify_phone_path, class: 'btn btn-primary mb2 center inline-block' - .sm-col.sm-col-12.md-col-6 - = link_to t('idv.buttons.activate_by_mail'), verify_usps_path, - class: 'btn btn-outline rounded-lg mb2 center' + - if FeatureManagement.enable_usps_verification? + .sm-col.sm-col-12.md-col-6 + = link_to t('idv.buttons.activate_by_mail'), verify_usps_path, + class: 'btn btn-outline rounded-lg mb2 center' = render 'shared/cancel', link: verify_cancel_path diff --git a/app/views/verify/phone/_verification_options.html.slim b/app/views/verify/phone/_verification_options.html.slim new file mode 100644 index 00000000000..8e1b6377f56 --- /dev/null +++ b/app/views/verify/phone/_verification_options.html.slim @@ -0,0 +1,3 @@ +p + = t('idv.form.no_alternate_phone_html', + link: link_to(t('idv.form.activate_by_mail'), verify_usps_path)) diff --git a/app/views/verify/phone/new.html.slim b/app/views/verify/phone/new.html.slim index 1b2a4ba7384..fc594dfa05c 100644 --- a/app/views/verify/phone/new.html.slim +++ b/app/views/verify/phone/new.html.slim @@ -26,8 +26,7 @@ em wrapper_html: { class: 'inline-block mr2' } = f.button :submit, t('forms.buttons.continue') -p - = t('idv.form.no_alternate_phone_html', - link: link_to(t('idv.form.activate_by_mail'), verify_usps_path)) +- if FeatureManagement.enable_usps_verification? + = render 'verification_options' = render @view_model.modal_partial, view_model: @view_model diff --git a/config/application.yml.example b/config/application.yml.example index 20b14d1b865..a0708c2e47f 100644 --- a/config/application.yml.example +++ b/config/application.yml.example @@ -58,6 +58,7 @@ development: domain_name: 'localhost:3000' enable_identity_verification: 'true' enable_test_routes: 'true' + enable_usps_verification: 'true' equifax_avs_username: 'sekret' equifax_eid_username: 'sekret' equifax_endpoint: 'sekret' @@ -109,6 +110,7 @@ production: domain_name: 'example.com' enable_identity_verification: 'false' enable_test_routes: 'false' + enable_usps_verification: 'false' equifax_avs_username: 'sekret' equifax_eid_username: 'sekret' equifax_endpoint: 'sekret' @@ -161,6 +163,7 @@ test: dashboard_api_token: '123ABC' enable_identity_verification: 'true' enable_test_routes: 'true' + enable_usps_verification: 'true' equifax_avs_username: 'sekret' equifax_eid_username: 'sekret' equifax_endpoint: 'sekret' diff --git a/config/initializers/figaro.rb b/config/initializers/figaro.rb index 77346d9a249..96d7d87a97c 100644 --- a/config/initializers/figaro.rb +++ b/config/initializers/figaro.rb @@ -6,6 +6,7 @@ 'domain_name', 'enable_identity_verification', 'enable_test_routes', + 'enable_usps_verification', 'equifax_ssh_passphrase', 'hmac_fingerprinter_key', 'idp_sso_target_url', diff --git a/config/routes.rb b/config/routes.rb index 35bf0ae568f..9a274057366 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -47,8 +47,6 @@ get '/account' => 'accounts#show' get '/account/reactivate' => 'users/reactivate_account#index', as: :reactivate_account post '/account/reactivate' => 'users/reactivate_account#create' - get '/account/verify' => 'users/verify_account#index', as: :verify_account - post '/account/verify' => 'users/verify_account#create' get '/account/verify_phone' => 'users/verify_profile_phone#index', as: :verify_profile_phone post '/account/verify_phone' => 'users/verify_profile_phone#create' @@ -135,6 +133,12 @@ put '/verify/session' => 'verify/sessions#create' delete '/verify/session' => 'verify/sessions#destroy' get '/verify/session/dupe' => 'verify/sessions#dupe' + + end + + if FeatureManagement.enable_usps_verification? + get '/account/verify' => 'users/verify_account#index', as: :verify_account + post '/account/verify' => 'users/verify_account#create' get '/verify/usps' => 'verify/usps#index' put '/verify/usps' => 'verify/usps#create' end diff --git a/lib/feature_management.rb b/lib/feature_management.rb index ff5d61cfb20..d8ef77b268d 100644 --- a/lib/feature_management.rb +++ b/lib/feature_management.rb @@ -48,6 +48,10 @@ def self.enable_identity_verification? Figaro.env.enable_identity_verification == 'true' end + def self.enable_usps_verification? + Figaro.env.enable_usps_verification == 'true' + end + def self.reveal_usps_code? Rails.env.development? || current_env_allowed_to_see_usps_code? end diff --git a/spec/features/openid_connect/openid_connect_spec.rb b/spec/features/openid_connect/openid_connect_spec.rb index 3034c1ec9b4..bd6127ede09 100644 --- a/spec/features/openid_connect/openid_connect_spec.rb +++ b/spec/features/openid_connect/openid_connect_spec.rb @@ -291,7 +291,6 @@ 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) diff --git a/spec/routing/id_verification_routing_spec.rb b/spec/routing/id_verification_routing_spec.rb index fdbf2260f91..efe20713910 100644 --- a/spec/routing/id_verification_routing_spec.rb +++ b/spec/routing/id_verification_routing_spec.rb @@ -14,7 +14,6 @@ verify/review verify/session verify/session/dupe - verify/usps ].freeze PUT_ROUTES = %w[ @@ -22,7 +21,6 @@ verify/phone verify/review verify/session - verify/usps ].freeze DELETE_ROUTES = %w[ diff --git a/spec/routing/usps_verification_routing.rb b/spec/routing/usps_verification_routing.rb new file mode 100644 index 00000000000..88cdd574276 --- /dev/null +++ b/spec/routing/usps_verification_routing.rb @@ -0,0 +1,69 @@ +require 'rails_helper' + +describe 'USPS verification routes' do + GET_ROUTES = %w[ + account/verify + verify/usps + ].freeze + + CREATE_ROUTES = %w[ + account/verify + ].freeze + + PUT_ROUTES = %w[ + verify/usps + ].freeze + + context 'when FeatureManagement.enable_usps_verification? is false' do + before do + allow(Figaro.env).to receive(:enable_identity_verification).and_return('false') + Rails.application.reload_routes! + end + + after(:all) do + Rails.application.reload_routes! + end + + it 'does not route to endpoints controlled by feature flag' do + GET_ROUTES.each do |route| + expect(get: route). + to route_to(controller: 'pages', action: 'page_not_found', path: route) + end + + CREATE_ROUTES.each do |route| + expect(post: route). + to route_to(controller: 'pages', action: 'page_not_found', path: route) + end + + PUT_ROUTES.each do |route| + expect(put: route). + to route_to(controller: 'pages', action: 'page_not_found', path: route) + end + end + end + + context 'when FeatureManagement.enable_usps_verification? is true' do + before do + allow(Figaro.env).to receive(:enable_identity_verification).and_return('true') + Rails.application.reload_routes! + end + + after(:all) do + Rails.application.reload_routes! + end + + it 'routes to endpoints controlled by feature flag' do + GET_ROUTES.each do |route| + expect(get: route).to be_routable + end + + CREATE_ROUTES.each do |route| + expect(post: route).to be_routable + end + + PUT_ROUTES.each do |route| + expect(put: route).to be_routable + end + end + end +end