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
6 changes: 4 additions & 2 deletions lib/feature_management.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
class FeatureManagement
PT_DOMAIN_NAME = 'idp.pt.login.gov'.freeze
ENVS_WHERE_PREFILLING_OTP_ALLOWED = %w[
idp.dev.login.gov idp.pt.login.gov
].freeze
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.

Nit: would take a map &:freeze if you wanted to freeze the strings as before.


ENVS_WHERE_PREFILLING_USPS_CODE_ALLOWED = %w[
idp.dev.login.gov idp.int.login.gov idp.qa.login.gov
Expand All @@ -21,7 +23,7 @@ def self.development_and_telephony_disabled?
end

def self.prefill_otp_codes_allowed_in_production?
Figaro.env.domain_name == PT_DOMAIN_NAME && telephony_disabled?
ENVS_WHERE_PREFILLING_OTP_ALLOWED.include?(Figaro.env.domain_name) && telephony_disabled?
end

def self.enable_i18n_mode?
Expand Down
35 changes: 28 additions & 7 deletions spec/lib/feature_management_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,35 @@
end
end

context 'when the server is idp.pt.login.gov' do
before { allow(FeatureManagement).to receive(:telephony_disabled?).and_return(true) }

it 'returns true in production mode' do
context 'in production servers' do
before do
allow(FeatureManagement).to receive(:telephony_disabled?).and_return(true)
allow(Rails.env).to receive(:production?).and_return(true)
allow(Figaro.env).to receive(:domain_name).and_return(FeatureManagement::PT_DOMAIN_NAME)
allow(Figaro.env).to receive(:domain_name).and_return(domain_name)
end

expect(FeatureManagement.prefill_otp_codes?).to eq(true)
context 'when the server is idp.pt.login.gov' do
let(:domain_name) { 'idp.pt.login.gov' }

it 'prefills codes' do
expect(FeatureManagement.prefill_otp_codes?).to eq(true)
end
end

context 'when the server is idp.dev.login.gov' do
let(:domain_name) { 'idp.dev.login.gov' }

it 'prefills codes' do
expect(FeatureManagement.prefill_otp_codes?).to eq(true)
end
end

context 'when the server is idp.staging.login.gov' do
let(:domain_name) { 'idp.staging.login.gov' }

it 'does not prefill codes' do
expect(FeatureManagement.prefill_otp_codes?).to eq(false)
end
end
end

Expand All @@ -46,7 +67,7 @@

it 'returns false in production mode when server is pt' do
allow(Rails.env).to receive(:production?).and_return(true)
allow(Figaro.env).to receive(:domain_name).and_return(FeatureManagement::PT_DOMAIN_NAME)
allow(Figaro.env).to receive(:domain_name).and_return('idp.pt.login.gov')

expect(FeatureManagement.prefill_otp_codes?).to eq(false)
end
Expand Down