From e72c681468d763934ea97b2dbfdb3404342ab349 Mon Sep 17 00:00:00 2001 From: Melissa Miller Date: Wed, 29 Mar 2023 15:15:41 -0400 Subject: [PATCH] Include MHV in organic experiment (#12195) * Include MHV authentication in organic experiment * Update flag to better reflect requirements * Add service provider to json response * Memoize service_name * Change service_name to credential_type --- ...le_verified_credential_adoption_service.rb | 15 ++++++-- config/features.yml | 2 +- ...ansition_availabilities_controller_spec.rb | 7 ++-- ...rified_credential_adoption_service_spec.rb | 38 +++++++++++++++++-- 4 files changed, 51 insertions(+), 11 deletions(-) diff --git a/app/services/acceptable_verified_credential_adoption_service.rb b/app/services/acceptable_verified_credential_adoption_service.rb index 3e7dbbea886..02ffa33a54d 100644 --- a/app/services/acceptable_verified_credential_adoption_service.rb +++ b/app/services/acceptable_verified_credential_adoption_service.rb @@ -22,18 +22,27 @@ def result @result ||= {} end + def credential_type + @credential_type ||= user.identity.sign_in[:service_name] + end + def display_organic_modal_for_logingov_conversion result[:organic_modal] = - Flipper.enabled?(:organic_dsl_conversion_experiment, user) && user_qualifies_for_conversion? + Flipper.enabled?(:organic_conversion_experiment, user) && user_qualifies_for_conversion? + result[:credential_type] = credential_type result end def user_qualifies_for_conversion? - logged_in_with_dsl? && !verified_credential_at? + (logged_in_with_dsl? || logged_in_with_mhv?) && !verified_credential_at? end def logged_in_with_dsl? - user.identity.sign_in[:service_name] == SAML::User::DSLOGON_CSID + credential_type == SAML::User::DSLOGON_CSID + end + + def logged_in_with_mhv? + credential_type == SAML::User::MHV_ORIGINAL_CSID end def verified_credential_at? diff --git a/config/features.yml b/config/features.yml index 0a4ffc07f14..2b7661fda0c 100644 --- a/config/features.yml +++ b/config/features.yml @@ -461,7 +461,7 @@ features: actor_type: user description: This determines the visibility of the OmniChannel link in the claim status tool enable_in_development: true - organic_dsl_conversion_experiment: + organic_conversion_experiment: actor_type: user description: Toggle to enable login.gov create account modal experiment pdf_warning_banner: diff --git a/spec/requests/v0/user_transition_availabilities_controller_spec.rb b/spec/requests/v0/user_transition_availabilities_controller_spec.rb index ab8f9c22a62..877ebc8031c 100644 --- a/spec/requests/v0/user_transition_availabilities_controller_spec.rb +++ b/spec/requests/v0/user_transition_availabilities_controller_spec.rb @@ -8,7 +8,7 @@ before { sign_in_as(user) } describe '/v0/user_transition_availabilities' do - context 'when Flipper organic_dsl_conversion_experiment is enabled' do + context 'when Flipper organic_conversion_experiment is enabled' do it 'is a valid request' do get '/v0/user_transition_availabilities' expect(response).to have_http_status(:ok) @@ -41,13 +41,14 @@ get '/v0/user_transition_availabilities' json_body = JSON.parse(response.body) expect(json_body).to include 'organic_modal' => true + expect(json_body).to include 'credential_type' => SAML::User::DSLOGON_CSID end end end - context 'when Flipper organic_dsl_conversion_experiment is disabled' do + context 'when Flipper organic_conversion_experiment is disabled' do before do - Flipper.disable(:organic_dsl_conversion_experiment) + Flipper.disable(:organic_conversion_experiment) end it 'is a valid request' do diff --git a/spec/services/acceptable_verified_credential_adoption_service_spec.rb b/spec/services/acceptable_verified_credential_adoption_service_spec.rb index 196ede0ed75..a8611c0591f 100644 --- a/spec/services/acceptable_verified_credential_adoption_service_spec.rb +++ b/spec/services/acceptable_verified_credential_adoption_service_spec.rb @@ -7,7 +7,7 @@ let(:user) { create(:user) } describe '.perform' do - context 'when Flipper organic_dsl_conversion_experiment is enabled' do + context 'when Flipper organic_conversion_experiment is enabled' do context 'User is dslogon authenticated' do context 'When user has avc' do let(:user) { create(:user, :dslogon, :accountable_with_logingov_uuid) } @@ -29,7 +29,9 @@ let(:user) { create(:user, :dslogon) } it 'hash returns true' do - expect(service.perform).to include(organic_modal: true) + result = service.perform + expect(result).to include(organic_modal: true) + expect(result).to include(credential_type: SAML::User::DSLOGON_CSID) end end end @@ -41,11 +43,39 @@ expect(service.perform).to include(organic_modal: false) end end + + context 'User is mhv authenticated' do + context 'When user has avc' do + let(:user) { create(:user, :mhv, :accountable_with_logingov_uuid) } + + it 'hash returns false' do + expect(service.perform).to include(organic_modal: false) + end + end + end + + context 'When user has ivc' do + let(:user) { create(:user, :mhv, :accountable) } + + it 'hash returns false' do + expect(service.perform).to include(organic_modal: false) + end + end + + context 'When user has no avc/ivc' do + let(:user) { create(:user, :mhv) } + + it 'hash returns true' do + result = service.perform + expect(result).to include(organic_modal: true) + expect(result).to include(credential_type: SAML::User::MHV_ORIGINAL_CSID) + end + end end - context 'When Flipper organic_dsl_conversion_experiment is disabled' do + context 'When Flipper organic_conversion_experiment is disabled' do before do - Flipper.disable(:organic_dsl_conversion_experiment) + Flipper.disable(:organic_conversion_experiment) end it 'hash returns false' do