allscripts_unity_client 3.3.0 → 3.3.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26d2a1e44edd1f0566f998f0d6a0a458be686621
|
4
|
+
data.tar.gz: 8a8e6d47cdcba9fe7cd5bcf775d40055eca85d13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7caa5e1b1a0e0bc6fd40f5331cc48bbe4b4ba8421d795a873670cacd2742270889b611d5e0604a96ca09a3027324d771043036b18373e762b856af5376de14a6
|
7
|
+
data.tar.gz: 9115bca3320748180f5c39423763fc75e9c7e45c7032e3ebb45657795d7d899a0aacb51155147e4850afcfada554f0a2bd40ed7f3c502512670837a978adda5c
|
data/.travis.yml
CHANGED
@@ -49,17 +49,21 @@ module AllscriptsUnityClient
|
|
49
49
|
|
50
50
|
def magic(parameters = {})
|
51
51
|
request = JSONUnityRequest.new(parameters, @options.timezone, @options.appname, @security_token)
|
52
|
-
log_magic(request)
|
53
|
-
|
54
52
|
request_hash = request.to_hash
|
55
|
-
log_info("Request Data: #{request_hash}")
|
56
53
|
request_data = MultiJson.dump(request_hash)
|
57
54
|
|
58
55
|
start_timer
|
59
56
|
response = @connection.post(build_uri('MagicJson'), request_data)
|
60
|
-
log_info("Response Status: #{response.status}")
|
61
57
|
end_timer
|
62
58
|
|
59
|
+
# NOTE: ClientDriver#log_magic uses ClientDriver#log_info, which
|
60
|
+
# appends timing info (if end_timer has been called previously),
|
61
|
+
# and then resets the timer.
|
62
|
+
#
|
63
|
+
# It would be nice if future work made this less stateful.
|
64
|
+
log_magic(request)
|
65
|
+
log_info("Response Status: #{response.status}")
|
66
|
+
|
63
67
|
response = MultiJson.load(response.body)
|
64
68
|
raise_if_response_error(response)
|
65
69
|
|
@@ -83,8 +87,10 @@ module AllscriptsUnityClient
|
|
83
87
|
response = @connection.post(build_uri('GetToken'), MultiJson.dump(request_data.to_hash))
|
84
88
|
end_timer
|
85
89
|
|
86
|
-
raise_if_response_error(response.body)
|
87
90
|
log_get_security_token
|
91
|
+
log_info("Response Status: #{response.status}")
|
92
|
+
|
93
|
+
raise_if_response_error(response.body)
|
88
94
|
|
89
95
|
@security_token = response.body
|
90
96
|
end
|
@@ -3,8 +3,16 @@ require 'spec_helper'
|
|
3
3
|
describe AllscriptsUnityClient::JSONClientDriver do
|
4
4
|
it_behaves_like 'a client driver'
|
5
5
|
|
6
|
+
let(:fake_logger) do
|
7
|
+
double(Logger)
|
8
|
+
end
|
9
|
+
|
10
|
+
before do
|
11
|
+
allow(fake_logger).to receive(:info)
|
12
|
+
end
|
13
|
+
|
6
14
|
subject do
|
7
|
-
client_driver = build(:json_client_driver)
|
15
|
+
client_driver = build(:json_client_driver, logger: fake_logger)
|
8
16
|
client_driver.security_token = SecureRandom.uuid
|
9
17
|
client_driver
|
10
18
|
end
|
@@ -42,11 +50,6 @@ describe AllscriptsUnityClient::JSONClientDriver do
|
|
42
50
|
before do
|
43
51
|
stub_request(:post, "http://www.example.com/Unity/UnityService.svc/json/MagicJson").
|
44
52
|
to_return(status: 200, body: get_server_info, headers: {})
|
45
|
-
|
46
|
-
allow(subject).to receive(:start_timer)
|
47
|
-
allow(subject).to receive(:end_timer)
|
48
|
-
allow(subject).to receive(:log_magic)
|
49
|
-
allow(subject).to receive(:log_info).twice
|
50
53
|
end
|
51
54
|
|
52
55
|
it 'should POST to /Unity/UnityService.svc/json/MagicJson' do
|
@@ -65,33 +68,22 @@ describe AllscriptsUnityClient::JSONClientDriver do
|
|
65
68
|
)
|
66
69
|
end
|
67
70
|
|
68
|
-
it 'should
|
69
|
-
|
70
|
-
expect(subject).to have_received(:start_timer)
|
71
|
-
end
|
71
|
+
it 'should log the request duration' do
|
72
|
+
expect(fake_logger).to receive(:info).with(/Unity API Magic request to [^ ]+ \[SomeRequest\] [0-9.]+ seconds/)
|
72
73
|
|
73
|
-
|
74
|
-
subject.magic
|
75
|
-
expect(subject).to have_received(:start_timer)
|
74
|
+
subject.magic(action: 'SomeRequest')
|
76
75
|
end
|
77
76
|
|
78
|
-
it 'should
|
79
|
-
|
80
|
-
expect(subject).to have_received(:log_magic)
|
81
|
-
end
|
77
|
+
it 'should log the response code' do
|
78
|
+
expect(fake_logger).to receive(:info).with(/Response Status: 200/)
|
82
79
|
|
83
|
-
|
84
|
-
subject.magic
|
85
|
-
expect(subject).to have_received(:log_info).twice
|
80
|
+
subject.magic(action: 'SomeRequest')
|
86
81
|
end
|
87
82
|
end
|
88
83
|
|
89
84
|
describe '#get_security_token!' do
|
90
85
|
before(:each) {
|
91
86
|
stub_request(:post, 'http://www.example.com/Unity/UnityService.svc/json/GetToken').to_return(body: get_security_token)
|
92
|
-
allow(subject).to receive(:start_timer)
|
93
|
-
allow(subject).to receive(:end_timer)
|
94
|
-
allow(subject).to receive(:log_get_security_token)
|
95
87
|
}
|
96
88
|
|
97
89
|
it 'should POST to /Unity/UnityService.svc/json/GetToken with username, password, and appname' do
|
@@ -99,27 +91,22 @@ describe AllscriptsUnityClient::JSONClientDriver do
|
|
99
91
|
expect(WebMock).to have_requested(:post, 'http://www.example.com/Unity/UnityService.svc/json/GetToken').with(body: /\{"Username":"[^"]+","Password":"[^"]+","Appname":"[^"]+"\}/, headers: { 'Content-Type' => 'application/json' })
|
100
92
|
end
|
101
93
|
|
102
|
-
it '
|
103
|
-
|
104
|
-
expect(subject).to have_received(:start_timer)
|
105
|
-
end
|
94
|
+
it 'log the request to get a security token' do
|
95
|
+
expect(fake_logger).to receive(:info).with(/Unity API GetSecurityToken request to [^ ]+ [0-9.]+ seconds/)
|
106
96
|
|
107
|
-
it 'should call end_timer' do
|
108
97
|
subject.get_security_token!
|
109
|
-
expect(subject).to have_received(:start_timer)
|
110
98
|
end
|
111
99
|
|
112
|
-
it '
|
100
|
+
it 'logs the response code from getting a security token' do
|
101
|
+
expect(fake_logger).to receive(:info).with(/Response Status: 200/)
|
102
|
+
|
113
103
|
subject.get_security_token!
|
114
|
-
expect(subject).to have_received(:log_get_security_token)
|
115
104
|
end
|
116
105
|
end
|
117
106
|
|
118
107
|
describe '#retire_security_token!' do
|
119
108
|
before(:each) {
|
120
109
|
stub_request(:post, 'http://www.example.com/Unity/UnityService.svc/json/RetireSecurityToken').to_return(body: retire_security_token)
|
121
|
-
allow(subject).to receive(:start_timer)
|
122
|
-
allow(subject).to receive(:end_timer)
|
123
110
|
allow(subject).to receive(:log_retire_security_token)
|
124
111
|
}
|
125
112
|
|
@@ -128,16 +115,6 @@ describe AllscriptsUnityClient::JSONClientDriver do
|
|
128
115
|
expect(WebMock).to have_requested(:post, 'http://www.example.com/Unity/UnityService.svc/json/RetireSecurityToken').with(body: /\{"Token":"[^"]+","Appname":"[^"]+"\}/, headers: { 'Content-Type' => 'application/json' })
|
129
116
|
end
|
130
117
|
|
131
|
-
it 'should call start_timer' do
|
132
|
-
subject.retire_security_token!
|
133
|
-
expect(subject).to have_received(:start_timer)
|
134
|
-
end
|
135
|
-
|
136
|
-
it 'should call end_timer' do
|
137
|
-
subject.retire_security_token!
|
138
|
-
expect(subject).to have_received(:start_timer)
|
139
|
-
end
|
140
|
-
|
141
118
|
it 'should call log_retire_security_token' do
|
142
119
|
subject.retire_security_token!
|
143
120
|
expect(subject).to have_received(:log_retire_security_token)
|
@@ -81,7 +81,8 @@ shared_examples 'a unity request' do
|
|
81
81
|
|
82
82
|
context 'when given a UTC date time string' do
|
83
83
|
it 'returns an ISO8601 string' do
|
84
|
-
|
84
|
+
now = DateTime.now.utc
|
85
|
+
now_iso8601 = now.strftime('%Y-%m-%dT%H:%M:%S%:z')
|
85
86
|
expect(subject.send(:process_date, now_iso8601)).to eq(now_iso8601)
|
86
87
|
end
|
87
88
|
end
|
@@ -97,7 +98,7 @@ shared_examples 'a unity request' do
|
|
97
98
|
context 'when given a UTC Time' do
|
98
99
|
it 'returns an ISO8601 string' do
|
99
100
|
now = Time.now.utc
|
100
|
-
now_iso8601 = now.strftime('%Y-%m-%dT%H:%M:%S
|
101
|
+
now_iso8601 = now.strftime('%Y-%m-%dT%H:%M:%S%:z')
|
101
102
|
expect(subject.send(:process_date, now)).to eq(now_iso8601)
|
102
103
|
end
|
103
104
|
end
|
@@ -105,9 +106,9 @@ shared_examples 'a unity request' do
|
|
105
106
|
context 'when given a UTC DateTime' do
|
106
107
|
it 'returns an ISO8601 string' do
|
107
108
|
now = DateTime.now.utc
|
108
|
-
now_iso8601 = now.
|
109
|
+
now_iso8601 = now.strftime('%Y-%m-%dT%H:%M:%S%:z')
|
109
110
|
expect(subject.send(:process_date, now)).to eq(now_iso8601)
|
110
111
|
end
|
111
112
|
end
|
112
113
|
end
|
113
|
-
end
|
114
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: allscripts_unity_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- healthfinch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|