vmware-vra 1.6.1 → 1.7.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: 6ac2699b418d64fce4f9120bb6ba446153b0a8b8
4
- data.tar.gz: f9fd06ca3a0b903424bf3844e077e291711d0140
3
+ metadata.gz: 2c05eec01ac6553d3123ba37195f222122f35973
4
+ data.tar.gz: 13dcedf5c874c5b28177dea101a1eb877b1cb873
5
5
  SHA512:
6
- metadata.gz: b94be722c12fb7a9543757e369fa8ab53c4ece8855cbf197282761cc4086aefeba315f91b55b497bf62f5577111574236d970238acd817674a6ac065ae959466
7
- data.tar.gz: c1afa96be5492f647b90a0aa3ecda8a751fa58d5231f0158cd4e5b10c4b3471d7407263b1a18af141bc388c01df66b511382f8ce9c05a3cb69cfe86e90ea9c99
6
+ metadata.gz: 725f77a6be89f33ca1df6e227e430c410dfd601ddf334c37c76f9fc1ec8cd6891f409a21f234b43140d642118245b3a8cd6ae5c22d06d12174f46f591116a22e
7
+ data.tar.gz: b1bec412ef1899b76f60fac938fa6ad3926d857833cd7b334880710710eb4dcdaff4966679f67fb63de71f5a4fc65d8a77b5d41575c5650566015ccd6215ad31
@@ -1,5 +1,8 @@
1
1
  # vmware-vra-gem CHANGELOG
2
2
 
3
+ ## v1.7.0 (2016-08-02)
4
+ * [pr#31](https://github.com/chef-partners/vmware-vra-gem/pull/31) instructing Net::HTTP not to verify SSL when verify_ssl is false
5
+
3
6
  ## v1.6.1 (2016-05-10)
4
7
  * Bowing to the Rubocop gods.
5
8
 
@@ -36,8 +36,10 @@ module Vra
36
36
  def call
37
37
  uri = URI(params[:url]) || fail(':url required')
38
38
 
39
- Net::HTTP.start(uri.host, uri.port,
40
- use_ssl: uri.scheme == 'https') do |http|
39
+ ssl_params = { use_ssl: uri.scheme == 'https' }
40
+ ssl_params[:verify_mode] = OpenSSL::SSL::VERIFY_NONE unless verify_ssl?
41
+
42
+ Net::HTTP.start(uri.host, uri.port, ssl_params) do |http|
41
43
  request = http_request(params[:method], uri)
42
44
  request.initialize_http_header(params[:headers] || {})
43
45
  request.body = params[:payload] || ''
@@ -63,6 +65,11 @@ module Vra
63
65
  def new(new_params)
64
66
  self.class.new(params.dup.merge(new_params))
65
67
  end
68
+
69
+ def verify_ssl?
70
+ return true if params[:verify_ssl].nil?
71
+ params[:verify_ssl]
72
+ end
66
73
  end
67
74
 
68
75
  class Response
@@ -17,5 +17,5 @@
17
17
  #
18
18
 
19
19
  module Vra
20
- VERSION = '1.6.1'.freeze
20
+ VERSION = '1.7.0'.freeze
21
21
  end
@@ -121,4 +121,38 @@ describe Vra::CatalogRequest do
121
121
  end
122
122
  end
123
123
  end
124
+
125
+ let(:client_without_ssl) do
126
+ Vra::Client.new(username: 'user@corp.local',
127
+ password: 'password',
128
+ tenant: 'tenant',
129
+ base_url: 'https://vra.corp.local',
130
+ verify_ssl: false)
131
+ end
132
+
133
+ context 'when ssl is not verified by the client' do
134
+ let(:request) do
135
+ client_without_ssl.catalog.request('catalog-12345',
136
+ cpus: 2,
137
+ memory: 1024,
138
+ lease_days: 15,
139
+ requested_for: 'tester@corp.local',
140
+ notes: 'test notes',
141
+ subtenant_id: 'user_subtenant')
142
+ end
143
+
144
+ describe do
145
+ it 'passes verify_false to Vra::Http' do
146
+ allow(request.client).to receive(:authorized?).and_return(true)
147
+ expect(request.client.instance_variable_get('@verify_ssl')).to eq false
148
+
149
+ expect(Vra::Http).to receive(:execute).and_wrap_original do |_http, *args|
150
+ expect(*args).to include(verify_ssl: false)
151
+ double(location: 'auth/request_id')
152
+ end
153
+
154
+ request.submit
155
+ end
156
+ end
157
+ end
124
158
  end
@@ -352,6 +352,33 @@ describe Vra::Client do
352
352
  client.http_post(path, payload)
353
353
  end
354
354
 
355
+ context 'when not verifying ssl' do
356
+ let(:unverified_client) do
357
+ Vra::Client.new(username: 'user@corp.local',
358
+ password: 'password',
359
+ tenant: 'tenant',
360
+ base_url: 'https://vra.corp.local',
361
+ verify_ssl: false)
362
+ end
363
+
364
+ before(:each) do
365
+ allow(unverified_client).to receive(:authorized?).and_return(true)
366
+ end
367
+
368
+ it 'configures Net::HTTP with VERIFY_NONE' do
369
+ allow(Net::HTTP).to receive(:start).and_wrap_original do |_http, *args|
370
+ expect(args.last).to include(verify_mode: OpenSSL::SSL::VERIFY_NONE)
371
+ double('response', final?: true, success?: true)
372
+ end
373
+
374
+ unverified_client.http_post('/path', 'payload')
375
+
376
+ [:head, :get].each do |method|
377
+ unverified_client.http_fetch(method, '/test', true)
378
+ end
379
+ end
380
+ end
381
+
355
382
  it 'calls raise_http_exception upon error' do
356
383
  allow(client).to receive(:authorize!)
357
384
  allow(Vra::Http).to receive(:execute).and_raise(StandardError)
@@ -69,6 +69,15 @@ describe Vra::Http do
69
69
  expect(response.code).to eq 204
70
70
  end
71
71
 
72
+ it 'configures ssl verification' do
73
+ allow(Net::HTTP).to receive(:start).and_wrap_original do |_http, *args|
74
+ expect(args.last).to include(verify_mode: OpenSSL::SSL::VERIFY_NONE)
75
+ double('response', final?: true, success?: true)
76
+ end
77
+
78
+ execute(:get, url: 'https://test.local', verify_ssl: false)
79
+ end
80
+
72
81
  context 'when successful' do
73
82
  it 'returns a successful response given a status 200' do
74
83
  stub_request(:head, 'http://test.local')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vmware-vra
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Leff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-10 00:00:00.000000000 Z
11
+ date: 2016-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi-yajl
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
184
  version: '0'
185
185
  requirements: []
186
186
  rubyforge_project:
187
- rubygems_version: 2.2.2
187
+ rubygems_version: 2.5.1
188
188
  signing_key:
189
189
  specification_version: 4
190
190
  summary: Client gem for interacting with VMware vRealize Automation.