bits_service_client 0.2.2.pre.8 → 0.2.2.pre.9
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/bits_service_client/client.rb +22 -14
- data/lib/bits_service_client/resource_pool.rb +16 -2
- data/lib/bits_service_client/version.rb +1 -1
- data/lib/bits_service_client.rb +1 -0
- 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: 8ffe244bb3268bff64c983b8c9bb706e2dc7b134
|
4
|
+
data.tar.gz: 9c5dced93c1563f94ee1da10106e71761b52fd38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7556eee77c0e6b4b813b677306f59387a718722716f6e3725e69193fbe2a3f6bcc9a7c8577b25bc821473f15bea7c4caf9525e40337557aac9932ab9307811c4
|
7
|
+
data.tar.gz: 6f4e47a725c021a74012627bbeb8fdb44368681f5289c36ebe245e974d8e72a231f4495c9b0e0f73dd41081aee9bfb43241c8d284b5e68636c69c7a2d44f7e86
|
@@ -16,20 +16,9 @@ module BitsService
|
|
16
16
|
raise ResourceTypeNotPresent.new('Must specify resource type') unless resource_type
|
17
17
|
@resource_type = resource_type
|
18
18
|
@vcap_request_id = vcap_request_id
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
c.use_ssl = true if @private_endpoint.scheme.start_with?('https')
|
23
|
-
c.verify_mode = OpenSSL::SSL::VERIFY_PEER if @private_endpoint.scheme.start_with?('https')
|
24
|
-
end
|
25
|
-
)
|
26
|
-
@public_http_client = LoggingHttpClient.new(
|
27
|
-
Net::HTTP.new(@public_endpoint.host, @public_endpoint.port).tap do |c|
|
28
|
-
c.read_timeout = request_timeout_in_seconds
|
29
|
-
c.use_ssl = true if @public_endpoint.scheme.start_with?('https')
|
30
|
-
c.verify_mode = OpenSSL::SSL::VERIFY_PEER if @public_endpoint.scheme.start_with?('https')
|
31
|
-
end
|
32
|
-
)
|
19
|
+
|
20
|
+
@private_http_client = create_logging_http_client(@private_endpoint, bits_service_options, request_timeout_in_seconds)
|
21
|
+
@public_http_client = create_logging_http_client(@public_endpoint, bits_service_options, request_timeout_in_seconds)
|
33
22
|
end
|
34
23
|
|
35
24
|
def local?
|
@@ -132,6 +121,25 @@ module BitsService
|
|
132
121
|
|
133
122
|
attr_reader :resource_type
|
134
123
|
|
124
|
+
def create_logging_http_client(endpoint, bits_service_options, request_timeout_in_seconds)
|
125
|
+
LoggingHttpClient.new(
|
126
|
+
Net::HTTP.new(endpoint.host, endpoint.port).tap do |c|
|
127
|
+
c.read_timeout = request_timeout_in_seconds
|
128
|
+
enable_ssl(c, validated(bits_service_options, :ca_cert_path)) if endpoint.scheme == 'https'
|
129
|
+
end
|
130
|
+
)
|
131
|
+
end
|
132
|
+
|
133
|
+
def enable_ssl(http_client, ca_cert_path)
|
134
|
+
cert_store = OpenSSL::X509::Store.new
|
135
|
+
cert_store.set_default_paths
|
136
|
+
cert_store.add_file ca_cert_path
|
137
|
+
|
138
|
+
http_client.use_ssl = true
|
139
|
+
http_client.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
140
|
+
http_client.cert_store = cert_store
|
141
|
+
end
|
142
|
+
|
135
143
|
def generate_private_url(guid)
|
136
144
|
path = resource_path(guid)
|
137
145
|
|
@@ -1,11 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
module BitsService
|
3
3
|
class ResourcePool
|
4
|
-
def initialize(endpoint:, request_timeout_in_seconds:, vcap_request_id: '')
|
4
|
+
def initialize(endpoint:, request_timeout_in_seconds:, vcap_request_id: '', ca_cert_path: nil)
|
5
5
|
@endpoint = URI.parse(endpoint)
|
6
6
|
@request_timeout_in_seconds = request_timeout_in_seconds
|
7
7
|
@vcap_request_id = vcap_request_id
|
8
8
|
@logger = Steno.logger('cc.bits_service_client')
|
9
|
+
@ca_cert_path = ca_cert_path
|
9
10
|
end
|
10
11
|
|
11
12
|
def matches(resources_json)
|
@@ -94,7 +95,20 @@ module BitsService
|
|
94
95
|
end
|
95
96
|
|
96
97
|
def http_client
|
97
|
-
@http_client ||= Net::HTTP.new(endpoint.host, endpoint.port).tap
|
98
|
+
@http_client ||= Net::HTTP.new(endpoint.host, endpoint.port).tap do |c|
|
99
|
+
c.read_timeout = @request_timeout_in_seconds
|
100
|
+
enable_ssl(c, @ca_cert_path) if endpoint.scheme == 'https'
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def enable_ssl(http_client, ca_cert_path)
|
105
|
+
cert_store = OpenSSL::X509::Store.new
|
106
|
+
cert_store.set_default_paths
|
107
|
+
cert_store.add_file ca_cert_path if ca_cert_path
|
108
|
+
|
109
|
+
http_client.use_ssl = true
|
110
|
+
http_client.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
111
|
+
http_client.cert_store = cert_store
|
98
112
|
end
|
99
113
|
end
|
100
114
|
end
|
data/lib/bits_service_client.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bits_service_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.2.pre.
|
4
|
+
version: 0.2.2.pre.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rizwan Reza
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2017-10-
|
14
|
+
date: 2017-10-10 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: steno
|