Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds AAMVA test scripts #9588

Merged
merged 3 commits into from
Nov 15, 2023
Merged
Changes from 1 commit
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
55 changes: 55 additions & 0 deletions spec/scripts/aamva_cert_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
require 'rails_helper'

RSpec.describe 'AAMVA cert script' do
before do
allow(IdentityConfig.store).to receive(:proofer_mock_fallback).and_return(false)
allow(IdentityConfig.store).to receive(:aamva_private_key).
and_return(Base64.strict_encode64(AamvaFixtures.aamva_private_key.to_der))
allow(IdentityConfig.store).to receive(:aamva_public_key).
and_return(Base64.strict_encode64(AamvaFixtures.aamva_public_key.to_der))
end

# This script can be run against the DLDV test environment (with the correct URLs)
subject(:run_script) do
Copy link
Contributor Author

Choose a reason for hiding this comment

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

another idea would be to put this in scripts/ dir something, so the script itself and the test are separate? but this seemed easy enough since the expectation is that we'd copy-paste most of this in the console anyways

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like it would be quicker to find in the scripts directory while in the middle of an incident. And your comment talks about running it in the DLDV test env. This also works in prod, right?

Is this the Jonny Proofer data, or is that somewhere else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was focused on having a DLDV test cert script, rather than a script we could use to check connectivity in prod, so now I think there are two modes that we could use:

  1. DLDV auth test
  2. one-off "jonny proofs" test to check prod connectivity

Copy link
Contributor Author

Choose a reason for hiding this comment

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

made a big refactor in f827639, now we have two scripts:

  • bin/aamva-test-cert --auth-url=URL --verification-url=URL which does the cert testing
  • bin/aamva-test-connectivity which just sends Jonny Proofs

proofer = Proofing::Resolution::ProgressiveProofer.new.send(:state_id_proofer)
proofer.config.cert_enabled = true
proofer.config.auth_url = 'https://example.com/a'
proofer.config.verification_url = 'https://example.com:18449/b'

Rails.cache.delete(Proofing::Aamva::AuthenticationClient::AUTH_TOKEN_CACHE_KEY)

applicant = {
'state_id_number' => 'DLDVSTRUCTUREDTEST12', # fake info that came from them
'state_id_jurisdiction' => 'VA',
'state_id_type' => 'drivers_license',
'uuid' => 'test'
}

proofer.proof(applicant)
end

after do
Rails.cache.delete(Proofing::Aamva::AuthenticationClient::AUTH_TOKEN_CACHE_KEY)
end

it 'provides a sample script that can be run to test AAMVA' do
stub_request(:post, 'https://example.com/a').
with(body: %r{http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT}).
to_return(body: AamvaFixtures.security_token_response, status: 200)
stub_request(:post, 'https://example.com/a').
with(body: %r{http://aamva.org/authentication/3.1.0/IAuthenticationService/Authenticate}).
to_return(body: AamvaFixtures.authentication_token_response, status: 200)
stub_request(:post, 'https://example.com:18449/b').
to_return(body: AamvaFixtures.verification_response_namespaced_success)

result = run_script
expect(result.exception).to be_nil

expect(WebMock).to(
have_requested(:post, 'https://example.com:18449/b').with do |req|
expect(Nokogiri::XML(req.body).at_xpath('//ns1:MessageDestinationId').text).
to eq('P6'), 'it sends a request with the designated fake state'
end,
)
end
end