From 3fe25106a6055554124fc3f657147d67c7d858a9 Mon Sep 17 00:00:00 2001 From: Zach Margolis Date: Mon, 31 Jul 2017 11:18:11 -0400 Subject: [PATCH] Allow pre-filling OTP in dev environment **Why**: Additional flexibility for load testing --- lib/feature_management.rb | 6 +++-- spec/lib/feature_management_spec.rb | 35 +++++++++++++++++++++++------ 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/lib/feature_management.rb b/lib/feature_management.rb index e88d2e3f93e..881dfe453a2 100644 --- a/lib/feature_management.rb +++ b/lib/feature_management.rb @@ -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 ENVS_WHERE_PREFILLING_USPS_CODE_ALLOWED = %w[ idp.dev.login.gov idp.int.login.gov idp.qa.login.gov @@ -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? diff --git a/spec/lib/feature_management_spec.rb b/spec/lib/feature_management_spec.rb index 676fe6ef723..dd1adf85677 100644 --- a/spec/lib/feature_management_spec.rb +++ b/spec/lib/feature_management_spec.rb @@ -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 @@ -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