Skip to content

Commit

Permalink
Include MHV in organic experiment (#12195)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
holytoastr authored Mar 29, 2023
1 parent ec7ffd0 commit e72c681
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 11 deletions.
15 changes: 12 additions & 3 deletions app/services/acceptable_verified_credential_adoption_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
2 changes: 1 addition & 1 deletion config/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit e72c681

Please sign in to comment.