cf-uaa-lib 3.13.0 → 3.14.1
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 +4 -4
- data/lib/uaa/http.rb +14 -1
- data/lib/uaa/info.rb +1 -3
- data/lib/uaa/scim.rb +1 -3
- data/lib/uaa/token_issuer.rb +1 -3
- data/lib/uaa/version.rb +1 -1
- data/spec/http_spec.rb +28 -4
- data/spec/integration_spec.rb +30 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46d432989d2af2fe4fa1a5317daffba25c752728
|
4
|
+
data.tar.gz: 4daf1389ceb41788db00d04324a778b688c7397c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57c54fd8ee9caddf71d4580bd909a52e4bad75a6815cb0a595b05e43536aa2a1774a2eddf5d747f9d2feca37e295d50f0a7966ccaf34b4b6e188e19f58083445
|
7
|
+
data.tar.gz: 41b36b3d6df7b9b2d5a55d65b0afadc62ac73837823bca76e3cfc4820fd6f3d0c17f57e9731ce1378a3e02fa272b08262712f5deb8895429eb72785911d0c455
|
data/lib/uaa/http.rb
CHANGED
@@ -48,10 +48,17 @@ module Http
|
|
48
48
|
|
49
49
|
def self.included(base)
|
50
50
|
base.class_eval do
|
51
|
-
|
51
|
+
attr_reader :skip_ssl_validation, :ssl_ca_file, :ssl_cert_store, :http_timeout
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
def initialize_http_options(options)
|
56
|
+
@skip_ssl_validation = options[:skip_ssl_validation]
|
57
|
+
@ssl_ca_file = options[:ssl_ca_file]
|
58
|
+
@ssl_cert_store = options[:ssl_cert_store]
|
59
|
+
@http_timeout = options[:http_timeout]
|
60
|
+
end
|
61
|
+
|
55
62
|
# Sets the current logger instance to recieve error messages.
|
56
63
|
# @param [Logger] logr
|
57
64
|
# @return [Logger]
|
@@ -201,6 +208,12 @@ module Http
|
|
201
208
|
http = HTTPClient.new
|
202
209
|
end
|
203
210
|
|
211
|
+
if http_timeout
|
212
|
+
http.connect_timeout = http_timeout
|
213
|
+
http.send_timeout = http_timeout
|
214
|
+
http.receive_timeout = http_timeout
|
215
|
+
end
|
216
|
+
|
204
217
|
@http_cache[cache_key] = http
|
205
218
|
end
|
206
219
|
|
data/lib/uaa/info.rb
CHANGED
@@ -31,10 +31,8 @@ class Info
|
|
31
31
|
# string keys are returned.
|
32
32
|
def initialize(target, options = {})
|
33
33
|
self.target = target
|
34
|
-
self.skip_ssl_validation = options[:skip_ssl_validation]
|
35
|
-
self.ssl_ca_file = options[:ssl_ca_file]
|
36
|
-
self.ssl_cert_store = options[:ssl_cert_store]
|
37
34
|
self.symbolize_keys = options[:symbolize_keys]
|
35
|
+
initialize_http_options(options)
|
38
36
|
end
|
39
37
|
|
40
38
|
# sets whether the keys in returned hashes should be symbols.
|
data/lib/uaa/scim.rb
CHANGED
@@ -149,10 +149,8 @@ class Scim
|
|
149
149
|
def initialize(target, auth_header, options = {})
|
150
150
|
@target, @auth_header = target, auth_header
|
151
151
|
@key_style = options[:symbolize_keys] ? :downsym : :down
|
152
|
-
self.skip_ssl_validation = options[:skip_ssl_validation]
|
153
|
-
self.ssl_ca_file = options[:ssl_ca_file]
|
154
|
-
self.ssl_cert_store = options[:ssl_cert_store]
|
155
152
|
@zone = options[:zone]
|
153
|
+
initialize_http_options(options)
|
156
154
|
end
|
157
155
|
|
158
156
|
# Convenience method to get the naming attribute, e.g. userName for user,
|
data/lib/uaa/token_issuer.rb
CHANGED
@@ -109,9 +109,7 @@ class TokenIssuer
|
|
109
109
|
@target, @client_id, @client_secret = target, client_id, client_secret
|
110
110
|
@token_target = options[:token_target] || target
|
111
111
|
@key_style = options[:symbolize_keys] ? :sym : nil
|
112
|
-
|
113
|
-
self.ssl_ca_file = options[:ssl_ca_file]
|
114
|
-
self.ssl_cert_store = options[:ssl_cert_store]
|
112
|
+
initialize_http_options(options)
|
115
113
|
end
|
116
114
|
|
117
115
|
# Allows an app to discover what credentials are required for
|
data/lib/uaa/version.rb
CHANGED
data/spec/http_spec.rb
CHANGED
@@ -69,7 +69,7 @@ describe CF::UAA::Http do
|
|
69
69
|
let(:ssl_config) { double('ssl_config') }
|
70
70
|
|
71
71
|
it 'sets verify mode to VERIFY_NONE' do
|
72
|
-
http_instance.skip_ssl_validation
|
72
|
+
http_instance.initialize_http_options({skip_ssl_validation: true})
|
73
73
|
|
74
74
|
expect(http_double).to receive(:ssl_config).and_return(ssl_config)
|
75
75
|
expect(ssl_config).to receive(:verify_mode=).with(OpenSSL::SSL::VERIFY_NONE)
|
@@ -91,7 +91,7 @@ describe CF::UAA::Http do
|
|
91
91
|
let(:ssl_config) { double('ssl_config') }
|
92
92
|
|
93
93
|
it 'passes it' do
|
94
|
-
http_instance.ssl_ca_file
|
94
|
+
http_instance.initialize_http_options({ssl_ca_file: '/fake-ca-file'})
|
95
95
|
|
96
96
|
expect(http_double).to receive(:ssl_config).and_return(ssl_config).twice
|
97
97
|
expect(ssl_config).to receive(:set_trust_ca).with('/fake-ca-file')
|
@@ -105,7 +105,7 @@ describe CF::UAA::Http do
|
|
105
105
|
let(:ssl_config) { double('ssl_config') }
|
106
106
|
|
107
107
|
it 'passes it' do
|
108
|
-
http_instance.ssl_cert_store
|
108
|
+
http_instance.initialize_http_options({ssl_cert_store: cert_store})
|
109
109
|
|
110
110
|
expect(http_double).to receive(:ssl_config).and_return(ssl_config).twice
|
111
111
|
expect(ssl_config).to receive(:cert_store=).with(cert_store)
|
@@ -114,5 +114,29 @@ describe CF::UAA::Http do
|
|
114
114
|
http_instance.http_get('https://uncached.example.com')
|
115
115
|
end
|
116
116
|
end
|
117
|
+
|
118
|
+
context 'when an http request timeout is provided' do
|
119
|
+
it 'sets all timeouts on the http clien to the http_timeout' do
|
120
|
+
http_instance.initialize_http_options({http_timeout: 10})
|
121
|
+
|
122
|
+
expect(http_double).to receive(:connect_timeout=).with(10)
|
123
|
+
expect(http_double).to receive(:send_timeout=).with(10)
|
124
|
+
expect(http_double).to receive(:receive_timeout=).with(10)
|
125
|
+
|
126
|
+
http_instance.http_get('https://uncached.example.com')
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'when an http request timeout is not provided' do
|
131
|
+
it 'does not override the default' do
|
132
|
+
http_instance.initialize_http_options({})
|
133
|
+
|
134
|
+
expect(http_double).not_to receive(:connect_timeout=)
|
135
|
+
expect(http_double).not_to receive(:send_timeout=)
|
136
|
+
expect(http_double).not_to receive(:receive_timeout=)
|
137
|
+
|
138
|
+
http_instance.http_get('https://uncached.example.com')
|
139
|
+
end
|
140
|
+
end
|
117
141
|
end
|
118
|
-
end
|
142
|
+
end
|
data/spec/integration_spec.rb
CHANGED
@@ -44,6 +44,34 @@ module CF::UAA
|
|
44
44
|
Scim.new(target, admin_token_issuer.client_credentials_grant.auth_header, options.merge(:symbolize_keys => true))
|
45
45
|
end
|
46
46
|
|
47
|
+
describe 'when UAA does not respond' do
|
48
|
+
let(:http_timeout) { 0.01 }
|
49
|
+
let(:default_http_client_timeout) { 60 }
|
50
|
+
let(:scim) { Scim.new(@target, "", {:http_timeout => http_timeout}) }
|
51
|
+
let(:token_issuer) { TokenIssuer.new(@target, "", "", {:http_timeout => http_timeout}) }
|
52
|
+
let(:blackhole_ip) { '10.255.255.1'}
|
53
|
+
|
54
|
+
before do
|
55
|
+
@target = "http://#{blackhole_ip}"
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'times out the connection at the configured time for the scim' do
|
59
|
+
expect {
|
60
|
+
Timeout.timeout(default_http_client_timeout - 1) do
|
61
|
+
scim.get(:user, "admin")
|
62
|
+
end
|
63
|
+
}.to raise_error HTTPClient::TimeoutError
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'times out the connection at the configured time for the token issuer' do
|
67
|
+
expect {
|
68
|
+
Timeout.timeout(default_http_client_timeout - 1) do
|
69
|
+
token_issuer.client_credentials_grant
|
70
|
+
end
|
71
|
+
}.to raise_error HTTPClient::TimeoutError
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
47
75
|
if ENV['UAA_CLIENT_TARGET']
|
48
76
|
describe 'UAA Integration:' do
|
49
77
|
|
@@ -128,7 +156,7 @@ module CF::UAA
|
|
128
156
|
end
|
129
157
|
|
130
158
|
it 'should report the uaa client version' do
|
131
|
-
expect(VERSION).to match(/\d
|
159
|
+
expect(VERSION).to match(/\d+.\d+.\d+/)
|
132
160
|
end
|
133
161
|
|
134
162
|
it 'makes sure the server is there by getting the prompts for an implicit grant' do
|
@@ -209,4 +237,4 @@ module CF::UAA
|
|
209
237
|
end
|
210
238
|
end
|
211
239
|
end
|
212
|
-
end
|
240
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cf-uaa-lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.14.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Syer
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2018-05-02 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: multi_json
|
@@ -236,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
236
236
|
version: '0'
|
237
237
|
requirements: []
|
238
238
|
rubyforge_project: cf-uaa-lib
|
239
|
-
rubygems_version: 2.
|
239
|
+
rubygems_version: 2.5.1
|
240
240
|
signing_key:
|
241
241
|
specification_version: 4
|
242
242
|
summary: Client library for CloudFoundry UAA
|