Skip to content

Commit

Permalink
LG-14397: Remove use_fed_domain_class (#11326)
Browse files Browse the repository at this point in the history
* LG-14397 Remove use_fed_domain_class config

changelog: Internal, Configuration, Remove configuration not needed any longer

* Fix incorrect example description
* Add test for "email addresses" wihout domains
  • Loading branch information
vrajmohan authored Oct 10, 2024
1 parent 9969571 commit a2e33f7
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 285 deletions.
7 changes: 1 addition & 6 deletions app/models/email_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,7 @@ def fed_or_mil_email?
end

def fed_email?
if IdentityConfig.store.use_fed_domain_class
return false unless domain
FederalEmailDomain.fed_domain?(domain)
else
email.end_with?('.gov')
end
FederalEmailDomain.fed_domain?(domain)
end

def mil_email?
Expand Down
3 changes: 0 additions & 3 deletions config/application.yml.default
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@ test_ssn_allowed_list: ''
totp_code_interval: 30
unauthorized_scope_enabled: false
use_dashboard_service_providers: false
use_fed_domain_class: false
use_kms: false
use_vot_in_sp_requests: true
usps_auth_token_refresh_job_enabled: false
Expand Down Expand Up @@ -451,7 +450,6 @@ development:
state_tracking_enabled: true
telephony_adapter: test
use_dashboard_service_providers: true
use_fed_domain_class: true
usps_eipp_sponsor_id: '222222222222222'
usps_ipp_sponsor_id: '111111111111111'
usps_ipp_transliteration_enabled: true
Expand Down Expand Up @@ -584,7 +582,6 @@ test:
telephony_adapter: test
test_ssn_allowed_list: '999999999'
totp_code_interval: 3
use_fed_domain_class: true
usps_eipp_sponsor_id: '222222222222222'
usps_ipp_root_url: 'http://localhost:1000'
usps_ipp_sponsor_id: '111111111111111'
Expand Down
1 change: 0 additions & 1 deletion lib/identity_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,6 @@ def self.store
config.add(:usps_auth_token_refresh_job_enabled, type: :boolean)
config.add(:usps_confirmation_max_days, type: :integer)
config.add(:usps_eipp_sponsor_id, type: :string)
config.add(:use_fed_domain_class, type: :boolean)
config.add(:usps_ipp_client_id, type: :string)
config.add(:usps_ipp_password, type: :string)
config.add(:usps_ipp_request_timeout, type: :integer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,51 +19,19 @@
)
end

context 'with user having gov or mil email and use_fed_domain_class set to false' do
let(:user) do
create(:user, email: '[email protected]', piv_cac_recommended_dismissed_at: Time.zone.now)
end
context 'with user having gov or mil email' do
let!(:federal_domain) { create(:federal_email_domain, name: 'gsa.gov') }

before do
allow(IdentityConfig.store).to receive(:use_fed_domain_class).and_return(false)
let(:user) do
create(
:user,
email: '[email protected]',
piv_cac_recommended_dismissed_at: interstitial_dismissed_at,
)
end

context 'having already visited the PIV interstitial page' do
it 'tracks the visit in analytics' do
get :index

expect(@analytics).to have_logged_event(
'User Registration: 2FA Setup visited',
enabled_mfa_methods_count: 0,
gov_or_mil_email: true,
)
end
end
let(:interstitial_dismissed_at) { Time.zone.now }

context 'directed to page without having visited PIV interstitial page' do
let(:user) do
create(:user, email: '[email protected]')
end

it 'redirects user to piv_recommended_path' do
get :index

expect(response).to redirect_to(login_piv_cac_recommended_url)
end
end
end

context 'with user having gov or mil email and use_fed_domain_class set to true' do
before do
allow(IdentityConfig.store).to receive(:use_fed_domain_class).and_return(true)
end

let!(:federal_domain) { create(:federal_email_domain, name: 'gsa.gov') }
let(:user) do
create(:user, email: '[email protected]', piv_cac_recommended_dismissed_at: Time.zone.now)
end
context 'having already visited the PIV interstitial page' do
it 'tracks the visit in analytics' do
get :index

Expand All @@ -76,9 +44,7 @@
end

context 'directed to page without having visited PIV interstitial page' do
let(:user) do
create(:user, email: '[email protected]')
end
let(:interstitial_dismissed_at) { nil }

it 'redirects user to piv_recommended_path' do
get :index
Expand Down
167 changes: 49 additions & 118 deletions spec/features/sign_in/piv_recommended_after_sign_in_spec.rb
Original file line number Diff line number Diff line change
@@ -1,132 +1,63 @@
require 'rails_helper'

RSpec.feature 'Piv recommended after Sign in' do
context 'use_fed_domain_class set to true' do
let!(:federal_email_domain) { create(:federal_email_domain, name: 'gsa.gov') }

before do
allow(IdentityConfig.store).to receive(:use_fed_domain_class).and_return(true)
end

scenario 'User with valid fed email directed to recommend page and get to setup piv' do
user = create(:user, :with_phone, { email: '[email protected]' })

visit new_user_session_path
fill_in_credentials_and_submit(user.email, user.password)
fill_in_code_with_last_phone_otp
click_submit_default
expect(page).to have_current_path(login_piv_cac_recommended_path)
click_button(t('two_factor_authentication.piv_cac_upsell.add_piv'))
expect(page).to have_current_path(setup_piv_cac_path)
end

scenario 'User with mil email directed to recommended PIV page and goes to add piv page' do
user = create(:user, :with_phone, { email: '[email protected]' })

visit new_user_session_path
fill_in_credentials_and_submit(user.email, user.password)
fill_in_code_with_last_phone_otp
click_submit_default
expect(page).to have_current_path(login_piv_cac_recommended_path)
click_button(t('two_factor_authentication.piv_cac_upsell.add_piv'))
expect(page).to have_current_path(setup_piv_cac_path)
end

scenario 'User with fed email and skips recommendation page' do
user = create(:user, :with_phone, { email: '[email protected]' })

visit new_user_session_path
fill_in_credentials_and_submit(user.email, user.password)
fill_in_code_with_last_phone_otp
click_submit_default
expect(page).to have_current_path(login_piv_cac_recommended_path)
click_button(t('two_factor_authentication.piv_cac_upsell.skip'))
expect(page).to have_current_path(account_path)
end

scenario 'User with mil email and skips recommendation page' do
user = create(:user, :with_phone, { email: '[email protected]' })

visit new_user_session_path
fill_in_credentials_and_submit(user.email, user.password)
fill_in_code_with_last_phone_otp
click_submit_default
expect(page).to have_current_path(login_piv_cac_recommended_path)
click_button(t('two_factor_authentication.piv_cac_upsell.skip'))
expect(page).to have_current_path(account_path)
end

scenario 'User with invalid .gov email directed to account page' do
user = create(:user, :with_phone, { email: '[email protected]' })

visit new_user_session_path
fill_in_credentials_and_submit(user.email, user.password)
fill_in_code_with_last_phone_otp
click_submit_default
expect(page).to have_current_path(account_path)
end
let!(:federal_email_domain) { create(:federal_email_domain, name: 'gsa.gov') }

scenario 'User with valid fed email directed to recommend page and get to setup piv' do
user = create(:user, :with_phone, { email: '[email protected]' })

visit new_user_session_path
fill_in_credentials_and_submit(user.email, user.password)
fill_in_code_with_last_phone_otp
click_submit_default
expect(page).to have_current_path(login_piv_cac_recommended_path)
click_button(t('two_factor_authentication.piv_cac_upsell.add_piv'))
expect(page).to have_current_path(setup_piv_cac_path)
end

context 'use_fed_domain_class set to false' do
before do
allow(IdentityConfig.store).to receive(:use_fed_domain_class).and_return(false)
end
scenario 'User with .gov email directed to recommend page and get to setup piv' do
user = create(:user, :with_phone, { email: '[email protected]' })

visit new_user_session_path
fill_in_credentials_and_submit(user.email, user.password)
fill_in_code_with_last_phone_otp
click_submit_default
expect(page).to have_current_path(login_piv_cac_recommended_path)
click_button(t('two_factor_authentication.piv_cac_upsell.add_piv'))
expect(page).to have_current_path(setup_piv_cac_path)
end
scenario 'User with mil email directed to recommended PIV page and goes to add piv page' do
user = create(:user, :with_phone, { email: '[email protected]' })

scenario 'User with .mil email directed to recommended PIV page and goes to add piv page' do
user = create(:user, :with_phone, { email: '[email protected]' })

visit new_user_session_path
fill_in_credentials_and_submit(user.email, user.password)
fill_in_code_with_last_phone_otp
click_submit_default
expect(page).to have_current_path(login_piv_cac_recommended_path)
click_button(t('two_factor_authentication.piv_cac_upsell.add_piv'))
expect(page).to have_current_path(setup_piv_cac_path)
end
visit new_user_session_path
fill_in_credentials_and_submit(user.email, user.password)
fill_in_code_with_last_phone_otp
click_submit_default
expect(page).to have_current_path(login_piv_cac_recommended_path)
click_button(t('two_factor_authentication.piv_cac_upsell.add_piv'))
expect(page).to have_current_path(setup_piv_cac_path)
end

scenario 'User with fed email and skips recommendation page' do
user = create(:user, :with_phone, { email: 'example@example.gov' })
scenario 'User with fed email and skips recommendation page' do
user = create(:user, :with_phone, { email: 'example@gsa.gov' })

visit new_user_session_path
fill_in_credentials_and_submit(user.email, user.password)
fill_in_code_with_last_phone_otp
click_submit_default
expect(page).to have_current_path(login_piv_cac_recommended_path)
click_button(t('two_factor_authentication.piv_cac_upsell.skip'))
expect(page).to have_current_path(account_path)
end
visit new_user_session_path
fill_in_credentials_and_submit(user.email, user.password)
fill_in_code_with_last_phone_otp
click_submit_default
expect(page).to have_current_path(login_piv_cac_recommended_path)
click_button(t('two_factor_authentication.piv_cac_upsell.skip'))
expect(page).to have_current_path(account_path)
end

scenario 'User with mil email and skips recommendation page' do
user = create(:user, :with_phone, { email: '[email protected]' })
scenario 'User with mil email and skips recommendation page' do
user = create(:user, :with_phone, { email: '[email protected]' })

visit new_user_session_path
fill_in_credentials_and_submit(user.email, user.password)
fill_in_code_with_last_phone_otp
click_submit_default
expect(page).to have_current_path(login_piv_cac_recommended_path)
click_button(t('two_factor_authentication.piv_cac_upsell.skip'))
expect(page).to have_current_path(account_path)
end
visit new_user_session_path
fill_in_credentials_and_submit(user.email, user.password)
fill_in_code_with_last_phone_otp
click_submit_default
expect(page).to have_current_path(login_piv_cac_recommended_path)
click_button(t('two_factor_authentication.piv_cac_upsell.skip'))
expect(page).to have_current_path(account_path)
end

scenario 'User with invalid no .gov or .mil email directed to account page' do
user = create(:user, :with_phone, { email: 'example@bad.com' })
scenario 'User with invalid .gov email directed to account page' do
user = create(:user, :with_phone, { email: 'example@bad.gov' })

visit new_user_session_path
fill_in_credentials_and_submit(user.email, user.password)
fill_in_code_with_last_phone_otp
click_submit_default
expect(page).to have_current_path(account_path)
end
visit new_user_session_path
fill_in_credentials_and_submit(user.email, user.password)
fill_in_code_with_last_phone_otp
click_submit_default
expect(page).to have_current_path(account_path)
end
end
Loading

0 comments on commit a2e33f7

Please sign in to comment.