-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* gem update * happy path for VBMS 2122 document upload * magic frozen comments * clean up the vbms integration * update gemfile and rubocop setting * one more rubocop change * fix broken spec * merge conflict * add vbms settings to base settings file * debug rails env * debugging settings for vbms * remove debugging logic * update specs for vbms test * rubocop updates * revert poa change * removing undeeded files * Use correct uploader job * revert uneeded gemfile changes
- Loading branch information
1 parent
032e1d5
commit df3d107
Showing
27 changed files
with
718 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,8 @@ Style/ZeroLengthPredicate: | |
|
||
Metrics/LineLength: | ||
Max: 120 | ||
Exclude: | ||
- 'Gemfile' | ||
|
||
Rails: | ||
Enabled: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
# OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE | ||
if Settings.vbms.present? | ||
ENV['CONNECT_VBMS_BASE_URL'] = Settings.vbms.vbms_base_url | ||
ENV['CONNECT_VBMS_BASE_URL'] = Settings.vbms.url | ||
ENV['CONNECT_VBMS_CACERT'] = Settings.vbms.ca_cert | ||
ENV['CONNECT_VBMS_CERT'] = Settings.vbms.cert | ||
ENV['CONNECT_VBMS_CLIENT_KEYFILE'] = Settings.vbms.client_keyfile | ||
ENV['CONNECT_VBMS_KEYPASS'] = Settings.vbms.keypass | ||
ENV['CONNECT_VBMS_SAML'] = Settings.vbms.saml | ||
ENV['CONNECT_VBMS_SERVER_CERT'] = Settings.vbms.server_cert | ||
ENV['CONNECT_VBMS_SHA256'] = 'false' | ||
ENV['CONNECT_VBMS_SHA256'] = 'true' | ||
ENV['CONNECT_VBMS_URL'] = "#{Settings.vbms.base_url}/vbmsp2-cms/streaming/eDocumentService-v4" | ||
ENV['CONNECT_VBMS_ENV_DIR'] = Settings.vbms.environment_directory | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
modules/claims_api/app/workers/claims_api/vbms_uploader.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'sidekiq' | ||
|
||
module ClaimsApi | ||
class VbmsUploader | ||
include Sidekiq::Worker | ||
|
||
def perform(power_of_attorney_id) | ||
power_of_attorney = ClaimsApi::PowerOfAttorney.find(power_of_attorney_id) | ||
uploader = ClaimsApi::PowerOfAttorneyUploader.new(power_of_attorney_id) | ||
uploader.retrieve_from_store!(power_of_attorney.file_data[:filename]) | ||
filepath = "#{uploader.file.file}/#{power_of_attorney.file_data['filename']}" | ||
|
||
upload_token_response = fetch_upload_token( | ||
filepath: filepath, | ||
file_number: power_of_attorney.auth_headers['va_eauth_pnid'] | ||
) | ||
upload_response = upload_document(filepath: filepath, upload_token: upload_token_response.upload_token) | ||
power_of_attorney.update( | ||
status: 'uploaded', | ||
vbms_new_document_version_ref_id: upload_response.upload_document_response[:@new_document_version_ref_id], | ||
vbms_document_series_ref_id: upload_response.upload_document_response[:@document_series_ref_id] | ||
) | ||
rescue VBMS::Unknown | ||
rescue_vbms_error(power_of_attorney) | ||
end | ||
|
||
def rescue_vbms_error(power_of_attorney) | ||
power_of_attorney.vbms_upload_failure_count = power_of_attorney.vbms_upload_failure_count + 1 | ||
power_of_attorney.vbms_error_message = 'An unknown error has occurred when uploading document' | ||
if power_of_attorney.vbms_upload_failure_count < 5 | ||
self.class.perform_in(30.minutes, power_of_attorney.id) | ||
else | ||
power_of_attorney.status = 'failed' | ||
end | ||
power_of_attorney.save | ||
end | ||
|
||
def client | ||
@client ||= VBMS::Client.from_env_vars | ||
end | ||
|
||
def fetch_upload_token(filepath:, file_number:) | ||
content_hash = Digest::SHA1.hexdigest(File.read(filepath)) | ||
filename = SecureRandom.uuid + File.basename(filepath) | ||
|
||
vbms_request = VBMS::Requests::InitializeUpload.new( | ||
content_hash: content_hash, | ||
filename: filename, | ||
file_number: file_number, | ||
va_receive_date: Time.zone.now, | ||
doc_type: '295', | ||
source: 'BVA', | ||
subject: '295', | ||
new_mail: true | ||
) | ||
client.send_request(vbms_request) | ||
end | ||
|
||
def upload_document(filepath:, upload_token:) | ||
upload_request = VBMS::Requests::UploadDocument.new( | ||
upload_token: upload_token, | ||
filepath: filepath | ||
) | ||
client.send_request(upload_request) | ||
end | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
...laims_api/db/migrate/20191118152927_add_vbms_id_fields_to_claims_api_power_of_attorney.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
class AddVbmsIdFieldsToClaimsApiPowerOfAttorney < ActiveRecord::Migration[5.2] | ||
def change | ||
add_column :claims_api_power_of_attorneys, :vbms_new_document_version_ref_id, :string | ||
add_column :claims_api_power_of_attorneys, :vbms_document_series_ref_id, :string | ||
add_column :claims_api_power_of_attorneys, :vbms_error_message, :string | ||
add_column :claims_api_power_of_attorneys, :vbms_upload_failure_count, :integer | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
...migrate/20191119141849_add_default_vbms_failure_count_to_claims_api_power_of_attorneys.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
class AddDefaultVbmsFailureCountToClaimsApiPowerOfAttorneys < ActiveRecord::Migration[5.2] | ||
def up | ||
change_column_default :claims_api_power_of_attorneys, :vbms_upload_failure_count, 0 | ||
end | ||
|
||
def down | ||
change_column_default :claims_api_power_of_attorneys, :vbms_upload_failure_count, nil | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
-----BEGIN CERTIFICATE----- | ||
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 | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQDfYs1U+yig+ouF | ||
hV2C9wgHLY3sgVlZcrDpK6ayVAbJ3zwjNo+N/ygNwHTdHfGxn6YBfcr22uXI6/6D | ||
TcQ5AujrgmncT6YtVPMsD6I8hNMWzqWPIZkHb6DK3mGutU9WCLoqxAcnDqEjnwGd | ||
zQSO4vK9JRfGssl/HBAr5zsKK3hcwt0iWQ8Q8Cy04FQh+RhTd7+7olRjevsW2jyg | ||
astJa1bnJDcJdSNNGbm8+iLlGmUwhMBYj/wnBbzNmQk8WdDSYGTqeWAmW7G/mxV+ | ||
2zy5gEcpoiObdzKvhh8makzVkfOrLPDzoGEuLyCsDhv0uhacNM6TqkhwxXHDkpN3 | ||
P55IKimnLjluMKIPw0pRTrZHTDcgiqFirgBA36ZmxhD3ARKCTJK1NnUB7ZVTYy7M | ||
w72o+igDRrYkqoP5Xe+qGq53QPi1lbn6+rKXk0wTBNn6OF69FW3PikFsVUJgygPH | ||
TQt6Lda8ZDPR8E6+8UJM5yvnLmJm9y6bQWbRXsj5DH/SQgtwoc7Pgg3jon4v9I9O | ||
Jk2J7NZD/Flm9z2SjQJwd8w221eTZrVb8zduthNvBfO/9OiBJZk6BAsSqy+IGeJm | ||
3m2deX8hxt1loVerlbMVo78EHljR0oQzVMiIt0IKVX22r+89sjvlmWX7Zd78nd9w | ||
fEx6m/K8rogRRMSfPaSslzgk8Zg+IQIDAQABAoICAH2sUiRLIHJgQfoeK5uwap3P | ||
LRcvNhsygQDNA/0zdJZBts2AtoaGU/xYl+aGICFz1arlIDh8seW1jvxD1e7VCkDk | ||
n7XIQY8jSaMyMG2ntDISk+XQWw1p6aX4MjBd5IJcapAAtJ1uh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/YgCLuS7X060FddJPOxVaUxuuw+OnaZRskaexokybFE | ||
FhwctAzIyPS8jxUXFFqsbmyBK85Feg54VLlPy5Ds3fsndXqsCCigz4pvy+jgh3jN | ||
FHoYBfxkGbwpix05wda/jETgTNOHrY7/PskMZoccYQlfrvE6sOXF8RmbzgTl0h8w | ||
RuoS4qnoS7hjmMneIXWEeXmm0j3iGx5PnIoClZun4HM1W45QIGrFczUi6TuzynPl | ||
2hXCaOx7hIHFk2XegJiJxMxTpzUkk8I= | ||
-----END PRIVATE KEY----- |
Binary file not shown.
Oops, something went wrong.