roqua-healthy 1.4.3 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +8 -0
- data/Appraisals +2 -0
- data/README.md +7 -0
- data/bin/parse_local_xml +1 -1
- data/lib/roqua/healthy/a19/fetcher.rb +1 -0
- data/lib/roqua/healthy/a19/response_validator.rb +1 -1
- data/lib/roqua/healthy/client.rb +7 -1
- data/lib/roqua/healthy/version.rb +1 -1
- data/spec/unit/a19/fetcher_spec.rb +5 -0
- data/spec/unit/client_spec.rb +12 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3959d17316a51405355769df7a3bd596599676b
|
4
|
+
data.tar.gz: 4d4192a2c29410a69420e98e611c9c56ab590e3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9977ba10cb3b7b6f267231f8f910713fb989614019d6d44b4cc2c09e6ca9671924b80373c30e33a78d331dae3599dd2761a2005fefa1cebba5c389220eac9df9
|
7
|
+
data.tar.gz: 7241aae05b61c2f276f86ba5ce34c24b3abd8ee788084ac1e7cd746788ef7469be58643084dd25c4790e0e8087a9fc704c680599e1296b266fede1a88f57a205
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/Appraisals
CHANGED
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
@@ -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
|
data/lib/roqua/healthy/client.rb
CHANGED
@@ -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
|
@@ -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
|
data/spec/unit/client_spec.rb
CHANGED
@@ -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
|
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
|
+
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-
|
14
|
+
date: 2017-04-18 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|