Skip to content

Commit

Permalink
LG-15603: Add local Attribute for Account creation (#11575)
Browse files Browse the repository at this point in the history
* changelog: Upcoming Features, Authentication, Threatmetrix API add local_attribute_1 for user when available

* change strong migration back

* remove &. for service provider

* add new line
  • Loading branch information
mdiarra3 authored Dec 5, 2024
1 parent 48da2e9 commit 5a76ef8
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/controllers/concerns/mfa_setup_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def threatmetrix_attrs
request_ip: request&.remote_ip,
threatmetrix_session_id: session[:threatmetrix_session_id],
email: EmailContext.new(current_user).last_sign_in_email_address.email,
uuid_prefix: current_sp&.app_id,
}
end

Expand Down
4 changes: 3 additions & 1 deletion app/jobs/account_creation_threat_metrix_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ def perform(
user_id: nil,
threatmetrix_session_id: nil,
request_ip: nil,
email: nil
email: nil,
uuid_prefix: nil
)
device_profiling_result = AccountCreation::DeviceProfiling.new.proof(
request_ip: request_ip,
threatmetrix_session_id: threatmetrix_session_id,
user_email: email,
uuid_prefix: uuid_prefix,
)
ensure
user = User.find_by(id: user_id)
Expand Down
8 changes: 6 additions & 2 deletions app/services/account_creation/device_profiling.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ class DeviceProfiling
attr_reader :request_ip,
:threatmetrix_session_id,
:user_email,
:device_profile_result
:device_profile_result,
:uuid_prefix
def proof(
request_ip:,
threatmetrix_session_id:,
user_email:
user_email:,
uuid_prefix:
)
@request_ip = request_ip
@threatmetrix_session_id = threatmetrix_session_id
@user_email = user_email
@uuid_prefix = uuid_prefix

@device_profile_result = device_profile
end
Expand All @@ -27,6 +30,7 @@ def device_profile
threatmetrix_session_id: threatmetrix_session_id,
email: user_email,
request_ip: request_ip,
uuid_prefix: uuid_prefix,
)
end

Expand Down
2 changes: 2 additions & 0 deletions spec/jobs/account_creation_threat_metrix_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
RSpec.describe AccountCreationThreatMetrixJob, type: :job do
let(:user) { create(:user, :fully_registered) }
let(:request_ip) { Faker::Internet.ip_v4_address }
let(:service_provider) { create(:service_provider) }
let(:threatmetrix_session_id) { SecureRandom.uuid }
let(:authentication_device_profiling) { :collect_only }
let(:lexisnexis_threatmetrix_mock_enabled) { false }
Expand All @@ -28,6 +29,7 @@
user_id: user.id,
threatmetrix_session_id: threatmetrix_session_id,
request_ip: request_ip,
uuid_prefix: service_provider.app_id,
)
end

Expand Down
2 changes: 2 additions & 0 deletions spec/services/account_creation/device_profiling_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
let(:threatmetrix_proofer_result) do
instance_double(Proofing::DdpResult, success?: true, transaction_id: 'ddp-123')
end
let(:service_provider) { create(:service_provider) }
let(:threatmetrix_proofer) do
instance_double(
Proofing::LexisNexis::Ddp::Proofer,
Expand All @@ -24,6 +25,7 @@
request_ip: Faker::Internet.ip_v4_address,
threatmetrix_session_id: threatmetrix_session_id,
user_email: Faker::Internet.email,
uuid_prefix: service_provider.app_id,
)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,25 @@
expected_json = JSON.parse(LexisNexisFixtures.ddp_authentication_request_json)
expect(response_json).to eq(expected_json)
end

context 'with service provider associated with user' do
let(:applicant) do
{
threatmetrix_session_id: 'UNIQUE_SESSION_ID',
email: '[email protected]',
request_ip: '127.0.0.1',
uuid_prefix: 'SPNUM',
}
end

it 'returns a properly formed request body' do
response_json = JSON.parse(subject.body)

base_json = JSON.parse(LexisNexisFixtures.ddp_authentication_request_json)
expected_json = base_json.merge({ 'local_attrib_1' => 'SPNUM' })
expect(response_json).to eq(expected_json)
end
end
end
end

Expand Down

0 comments on commit 5a76ef8

Please sign in to comment.