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
2 changes: 2 additions & 0 deletions app/services/pii/attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ module Pii
# the state in the state id address, which may not be the state that issued the ID
:identity_doc_address_state,
:ssn, :dob, :phone,
# The country the passport was issued in.
:issuing_country_code,
*DEPRECATED_PII_ATTRIBUTES,
keyword_init: true
) do
Expand Down
1 change: 0 additions & 1 deletion spec/controllers/idv/personal_key_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def assert_personal_key_generated_for_profiles(*profile_pii_pairs)
state_id_issued
state_id_number
document_type_received
issuing_country_code
]

profile_pii_pairs.each do |profile, pii|
Expand Down
276 changes: 276 additions & 0 deletions spec/features/idv/doc_auth/idv_flow_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,276 @@
require 'rails_helper'

RSpec.describe 'Completing all IDV steps', :js, :allow_browser_log do
include IdvStepHelper
include InPersonHelper
include PassportApiHelpers

let(:user) { user_with_2fa }
let(:phone_number) { '2028675309' }
let(:fake_dos_api_endpoint) { 'http://fake_dos_api_endpoint/' }

before do
allow(IdentityConfig.store).to receive(:doc_auth_vendor).and_return(doc_auth_vendor)
allow(IdentityConfig.store).to receive(:doc_auth_vendor_default).and_return(doc_auth_vendor)
allow(IdentityConfig.store).to receive(:doc_auth_passport_vendor).and_return(doc_auth_vendor)
allow(IdentityConfig.store).to receive(:doc_auth_passport_vendor_default).and_return(
doc_auth_vendor,
)
allow(IdentityConfig.store).to receive(:doc_auth_vendor_switching_enabled).and_return(true)
allow(IdentityConfig.store).to receive(:dos_passport_mrz_endpoint)
.and_return(fake_dos_api_endpoint)
stub_health_check_settings
stub_health_check_endpoints_success
stub_request(:post, fake_dos_api_endpoint)
.to_return_json({ status: 200, body: { response: 'YES' } })
end

describe 'when doc auth vendor is "lexis_nexis"' do
let(:doc_auth_vendor) { 'lexis_nexis' }

before do
stub_request(:post, /.*\/restws\/identity\/v3\/accounts\/.*\/workflows\/.*\/conversations/)
.and_return(status: 200, body: doc_auth_response)
end

describe 'IDV State ID flow' do
let(:doc_auth_response) { LexisNexisFixtures.true_id_response_success }

scenario 'When the user completes all IDV steps' do
visit_idp_from_oidc_sp_with_ial2
sign_in_and_2fa_user(user)
visit idv_welcome_path
complete_welcome_step
complete_agreement_step
complete_hybrid_handoff_step
complete_choose_id_type_step
attach_images(Rails.root.join('spec', 'fixtures', 'doc_auth_images', 'id-front.jpg'))
submit_images
complete_ssn_step
complete_verify_step
fill_out_phone_form_ok(phone_number)
verify_phone_otp
complete_enter_password_step(user)

expect(page).to have_current_path(idv_personal_key_path)

profile = user.profiles.last

expect(profile.active).to be(true)
expect(profile.decrypt_pii(user.password)).to have_attributes(
first_name: 'LICENSE',
middle_name: nil,
last_name: 'SAMPLE',
dob: '1966-05-05',
ssn: Idp::Constants::MOCK_IDV_APPLICANT_WITH_SSN[:ssn],
phone: phone_number,
address1: '123 ABC AVE',
address2: 'APT 3E',
city: 'ANYTOWN',
state: 'NY',
zipcode: '12345',
same_address_as_id: nil,
identity_doc_address1: nil,
identity_doc_address2: nil,
identity_doc_city: nil,
identity_doc_zipcode: nil,
identity_doc_address_state: nil,
state_id_jurisdiction: 'NY',
issuing_country_code: nil,
)
end
end

describe 'IDV Passport Flow' do
let(:address1) { '123 Main St' }
let(:city) { 'Anywhere' }
let(:state_abbr) { 'VA' }
let(:state) { 'Virginia' }
let(:zipcode) { '66044' }
let(:fake_dos_api_endpoint) { 'http://fake_dos_api_endpoint/' }
let(:doc_auth_response) { LexisNexisFixtures.true_id_response_passport_without_tamper }

before do
end

scenario 'When the user completes all IDV steps' do
visit_idp_from_oidc_sp_with_ial2
sign_in_and_2fa_user(user)
visit idv_welcome_path
complete_welcome_step
complete_agreement_step
complete_hybrid_handoff_step
complete_choose_id_type_step(choose_id_type: 'passport')
attach_passport_image(
Rails.root.join('spec', 'fixtures', 'doc_auth_images', 'passport.jpg'),
)
submit_images
complete_ssn_step
fill_in 'idv_form_address1', with: address1
fill_in 'idv_form_city', with: city
select state, from: 'idv_form_state'
fill_in 'idv_form_zipcode', with: zipcode
click_idv_continue
complete_verify_step
fill_out_phone_form_ok(phone_number)
verify_phone_otp
complete_enter_password_step(user)

expect(page).to have_current_path(idv_personal_key_path)

profile = user.profiles.last

expect(profile.active).to be(true)
expect(profile.decrypt_pii(user.password)).to have_attributes(
first_name: 'DAVID',
middle_name: 'PASSPORT',
last_name: 'SAMPLE',
dob: '1986-07-01',
ssn: Idp::Constants::MOCK_IDV_APPLICANT_WITH_SSN[:ssn],
phone: phone_number,
address1:,
address2: '',
city:,
state: state_abbr,
zipcode:,
same_address_as_id: nil,
identity_doc_address1: nil,
identity_doc_address2: nil,
identity_doc_city: nil,
identity_doc_zipcode: nil,
identity_doc_address_state: nil,
state_id_jurisdiction: nil,
issuing_country_code: 'USA',
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.

This may be a result of the fixture (and thus in practice out of our control), but the Jira ticket specified the value should be either 'US' or 'Department of State'.

Does it matter?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this matters for the tests. It will take a string.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will check with Amir on this though.

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.

'USA' also works 👍🏿

)
end
end
end

describe 'when doc auth vendor is "socure"' do
let(:doc_auth_vendor) { 'socure' }
let(:socure_docv_webhook_secret_key) { 'socure_docv_webhook_secret_key' }
let(:fake_socure_docv_document_request_endpoint) { 'https://fake-socure.test/document-request' }

before do
allow(IdentityConfig.store).to receive(:socure_docv_enabled).and_return(true)
allow(IdentityConfig.store).to receive(:socure_docv_webhook_secret_key)
.and_return(socure_docv_webhook_secret_key)
allow(IdentityConfig.store).to receive(:socure_docv_document_request_endpoint)
.and_return(fake_socure_docv_document_request_endpoint)
allow(IdentityConfig.store).to receive(:ruby_workers_idv_enabled).and_return(false)
@docv_transaction_token = stub_docv_document_request(user:)
stub_request(:post, /.*\/api\/3.0\/EmailAuthScore/)
.and_return(status: 200, body: doc_auth_response)
end

describe 'IDV State ID flow' do
let(:doc_auth_response) { SocureDocvFixtures.pass_json }

scenario 'When the user completes all IDV steps' do
visit_idp_from_oidc_sp_with_ial2
sign_in_and_2fa_user(user)
visit idv_welcome_path
complete_welcome_step
complete_agreement_step
complete_hybrid_handoff_step
complete_choose_id_type_step
visit idv_socure_document_capture_path
expect(page).to have_current_path(idv_socure_document_capture_path)
socure_docv_upload_documents(docv_transaction_token: @docv_transaction_token)
visit idv_socure_document_capture_update_path
complete_ssn_step
complete_verify_step
fill_out_phone_form_ok(phone_number)
verify_phone_otp
complete_enter_password_step(user)

expect(page).to have_current_path(idv_personal_key_path)

profile = user.profiles.last

expect(profile.active).to be(true)
expect(profile.decrypt_pii(user.password)).to have_attributes(
first_name: 'Dwayne',
middle_name: nil,
last_name: 'Denver',
dob: '2002-01-01',
ssn: Idp::Constants::MOCK_IDV_APPLICANT_WITH_SSN[:ssn],
phone: phone_number,
address1: '123 Example Street',
address2: 'New York City NY 10001',
city: 'New York City',
state: 'NY',
zipcode: '10001',
same_address_as_id: nil,
identity_doc_address1: nil,
identity_doc_address2: nil,
identity_doc_city: nil,
identity_doc_zipcode: nil,
identity_doc_address_state: nil,
state_id_jurisdiction: 'NY',
issuing_country_code: 'USA',
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.

Same as above - does this need to be US?

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.

'USA' works 👍🏿

)
end
end

describe 'IDV Passport flow' do
let(:address1) { '123 Main St' }
let(:city) { 'Anywhere' }
let(:state_abbr) { 'VA' }
let(:state) { 'Virginia' }
let(:zipcode) { '66044' }
let(:doc_auth_response) { SocureDocvFixtures.pass_json(document_type: :passport) }

scenario 'When the user completes all IDV steps' do
visit_idp_from_oidc_sp_with_ial2
sign_in_and_2fa_user(user)
visit idv_welcome_path
complete_welcome_step
complete_agreement_step
complete_hybrid_handoff_step
complete_choose_id_type_step(choose_id_type: 'passport')
visit idv_socure_document_capture_path
expect(page).to have_current_path(idv_socure_document_capture_path)
socure_docv_upload_documents(docv_transaction_token: @docv_transaction_token)
visit idv_socure_document_capture_update_path
complete_ssn_step
fill_in 'idv_form_address1', with: address1
fill_in 'idv_form_city', with: city
select state, from: 'idv_form_state'
fill_in 'idv_form_zipcode', with: zipcode
click_idv_continue
complete_verify_step
fill_out_phone_form_ok(phone_number)
verify_phone_otp
complete_enter_password_step(user)

expect(page).to have_current_path(idv_personal_key_path)

profile = user.profiles.last

expect(profile.active).to be(true)
expect(profile.decrypt_pii(user.password)).to have_attributes(
first_name: 'DWAYNE',
middle_name: nil,
last_name: 'DENVER',
dob: '1965-02-05',
ssn: Idp::Constants::MOCK_IDV_APPLICANT_WITH_SSN[:ssn],
phone: phone_number,
address1:,
address2: '',
city:,
state: state_abbr,
zipcode:,
same_address_as_id: nil,
identity_doc_address1: nil,
identity_doc_address2: nil,
identity_doc_city: nil,
identity_doc_zipcode: nil,
identity_doc_address_state: nil,
state_id_jurisdiction: nil,
issuing_country_code: 'USA',
)
end
end
end
end
Loading