roqua-healthy 1.4.3 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9671caf50e1efc23c7bf188c74fc55d5898c1a16
4
- data.tar.gz: ad836d232fc0c15c81b866b3953eefd42f92e13d
3
+ metadata.gz: f3959d17316a51405355769df7a3bd596599676b
4
+ data.tar.gz: 4d4192a2c29410a69420e98e611c9c56ab590e3d
5
5
  SHA512:
6
- metadata.gz: cb328e0dc13e579ec37a399aee4811d251703830693048d135eb6557313eb9847c16167a8289d0f4df51df951d7a91a02569f5aec6c7044c26efbd93137cb861
7
- data.tar.gz: 920ee8298069a93fe883f13d882f9ed07ba4f2a3010bfc3e61c45eaaf99fa43b5adf0b61bcad8cfa268e68812e470c0b3bd9fc8f865330d5eefe2795340ecc1a
6
+ metadata.gz: 9977ba10cb3b7b6f267231f8f910713fb989614019d6d44b4cc2c09e6ca9671924b80373c30e33a78d331dae3599dd2761a2005fefa1cebba5c389220eac9df9
7
+ data.tar.gz: 7241aae05b61c2f276f86ba5ce34c24b3abd8ee788084ac1e7cd746788ef7469be58643084dd25c4790e0e8087a9fc704c680599e1296b266fede1a88f57a205
data/.gitignore CHANGED
@@ -8,3 +8,4 @@ pkg/
8
8
  tmp/
9
9
  vendor/cache/*.gem
10
10
  tmp/rspec_guard_result
11
+ coverage/
data/.rubocop.yml CHANGED
@@ -22,3 +22,11 @@ MethodLength:
22
22
 
23
23
  SignalException:
24
24
  Enabled: False
25
+
26
+ Style/EmptyLineAfterMagicComment:
27
+ Enabled: False
28
+
29
+ Style/FileName:
30
+ Exclude:
31
+ - Appraisals
32
+
data/Appraisals CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  appraise "rails41" do
2
4
  gem "activesupport", "4.1"
3
5
  end
data/README.md CHANGED
@@ -15,6 +15,13 @@ client = Healthy::A19::Client(a19_endpoint: 'https://...')
15
15
  client.fetch_a19(patient_identifier)
16
16
  ```
17
17
 
18
+ or if the server you connect to needs http basic authentication:
19
+
20
+ ```ruby
21
+ client = Healthy::A19::Client(a19_endpoint: 'https://...', a19_username: 'foo', a19_password: 'bar')
22
+ client.fetch_a19(patient_identifier)
23
+ ```
24
+
18
25
  ### Adding integration tests
19
26
 
20
27
  If you find any A19 response that Healthy currently does not handle correctly, please add a fixture and integration test for it.
data/bin/parse_local_xml CHANGED
@@ -5,6 +5,6 @@ require 'roqua_healthy'
5
5
  require 'pp'
6
6
 
7
7
  body = ARGF.read
8
- message = Hash.from_xml(body).fetch("HL7Message") { Hash.new }
8
+ message = Hash.from_xml(body).fetch("HL7Message", {})
9
9
 
10
10
  pp Roqua::Healthy::A19::Transformer.new(message).to_patient
@@ -27,6 +27,7 @@ module Roqua
27
27
  def mirth_response
28
28
  Net::HTTP.start(remote_url.host, remote_url.port, use_ssl: use_ssl?) do |http|
29
29
  request = Net::HTTP::Post.new(remote_url.path)
30
+ request.basic_auth(@client.a19_username, @client.a19_password) if @client.use_basic_auth?
30
31
  request.set_form_data(mirth_params)
31
32
  http.request request
32
33
  end
@@ -36,7 +36,7 @@ module Roqua
36
36
  case response_code
37
37
  when '200'
38
38
  validate_200
39
- when '403'
39
+ when '401', '403'
40
40
  validate_403
41
41
  when '404'
42
42
  validate_404
@@ -4,16 +4,22 @@ module Roqua
4
4
  class Client
5
5
  include ::Roqua::Support::Instrumentation
6
6
 
7
- attr_accessor :a19_endpoint
7
+ attr_accessor :a19_endpoint, :a19_username, :a19_password
8
8
 
9
9
  def initialize(options = {})
10
10
  @a19_endpoint = options[:a19_endpoint]
11
+ @a19_username = options[:a19_username]
12
+ @a19_password = options[:a19_password]
11
13
  end
12
14
 
13
15
  def a19_endpoint
14
16
  @a19_endpoint || Roqua::Healthy.a19_endpoint
15
17
  end
16
18
 
19
+ def use_basic_auth?
20
+ @a19_username.present? || @a19_password.present?
21
+ end
22
+
17
23
  def fetch_a19(patient_id)
18
24
  with_instrumentation 'hl7.a19', patient_id: patient_id do
19
25
  message = A19::Fetcher.new(patient_id, self).fetch
@@ -2,6 +2,6 @@
2
2
  module Roqua
3
3
  module Healthy
4
4
  # healthy version
5
- VERSION = "1.4.3"
5
+ VERSION = "1.5.0"
6
6
  end
7
7
  end
@@ -67,6 +67,11 @@ describe Roqua::Healthy::A19::Fetcher do
67
67
  expect { subject.fetch }.to raise_exception(Roqua::Healthy::Timeout)
68
68
  end
69
69
 
70
+ it 'raises when upstream authentication fails' do
71
+ stub_mirth_response "<failure><error>Unauthorized</error></failure>", 401
72
+ expect { subject.fetch }.to raise_exception(Roqua::Healthy::AuthenticationFailure)
73
+ end
74
+
70
75
  it 'saves the client' do
71
76
  expect(subject.client).to eq client
72
77
  end
@@ -3,9 +3,18 @@ require 'spec_helper'
3
3
 
4
4
  describe Roqua::Healthy::Client do
5
5
  context 'fully configured client' do
6
- subject { Roqua::Healthy::Client.new(a19_endpoint: 'http://a19_endpoint.dev') }
6
+ subject do
7
+ Roqua::Healthy::Client.new(
8
+ a19_endpoint: 'http://a19_endpoint.dev',
9
+ a19_username: 'foo',
10
+ a19_password: 'bar'
11
+ )
12
+ end
7
13
 
8
14
  it { expect(subject.a19_endpoint).to eq 'http://a19_endpoint.dev' }
15
+ it { expect(subject.a19_username).to eq 'foo' }
16
+ it { expect(subject.a19_password).to eq 'bar' }
17
+ it { expect(subject.use_basic_auth?).to be_truthy }
9
18
  end
10
19
 
11
20
  context 'unconfigured client' do
@@ -14,5 +23,7 @@ describe Roqua::Healthy::Client do
14
23
  it 'defaults to system wide config' do
15
24
  expect(subject.a19_endpoint).to eq Roqua::Healthy.a19_endpoint
16
25
  end
26
+
27
+ it { expect(subject.use_basic_auth?).to be_falsey }
17
28
  end
18
29
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roqua-healthy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.3
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marten Veldthuis
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2017-01-26 00:00:00.000000000 Z
14
+ date: 2017-04-18 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport