vmware-vra 3.1.0 → 3.1.3

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.
@@ -16,23 +16,23 @@
16
16
  # See the License for the specific language governing permissions and
17
17
  # limitations under the License.
18
18
  #
19
- require 'spec_helper'
19
+ require "spec_helper"
20
20
 
21
21
  describe Vra::CatalogSource do
22
22
  let(:client) do
23
23
  Vra::Client.new(
24
- username: 'user@corp.local',
25
- password: 'password',
26
- tenant: 'tenant',
27
- base_url: 'https://vra.corp.local'
24
+ username: "user@corp.local",
25
+ password: "password",
26
+ tenant: "tenant",
27
+ base_url: "https://vra.corp.local"
28
28
  )
29
29
  end
30
30
 
31
31
  let(:sample_data) do
32
- JSON.parse(File.read('spec/fixtures/resource/sample_catalog_source.json'))
32
+ JSON.parse(File.read("spec/fixtures/resource/sample_catalog_source.json"))
33
33
  end
34
34
 
35
- describe '#initialize' do
35
+ describe "#initialize" do
36
36
  let(:source) do
37
37
  described_class.allocate
38
38
  end
@@ -41,89 +41,89 @@ describe Vra::CatalogSource do
41
41
  allow(client).to receive(:get_parsed).and_return(sample_data)
42
42
  end
43
43
 
44
- it 'should validate and fetch data' do
44
+ it "should validate and fetch data" do
45
45
  expect(source).to receive(:validate!)
46
46
  expect(source).to receive(:fetch_data)
47
47
 
48
- source.send(:initialize, client, id: '123456')
48
+ source.send(:initialize, client, id: "123456")
49
49
  end
50
50
 
51
- it 'should fetch data when id is passed' do
52
- source.send(:initialize, client, id: '123456')
51
+ it "should fetch data when id is passed" do
52
+ source.send(:initialize, client, id: "123456")
53
53
 
54
54
  expect(source.send(:data)).not_to be_nil
55
55
  end
56
56
 
57
- it 'should set id when data is passed' do
57
+ it "should set id when data is passed" do
58
58
  source.send(:initialize, client, data: sample_data)
59
59
 
60
- expect(source.id).to eq('123456')
60
+ expect(source.id).to eq("123456")
61
61
  end
62
62
  end
63
63
 
64
- describe '#validate' do
64
+ describe "#validate" do
65
65
  let(:source) do
66
66
  described_class.allocate
67
67
  end
68
68
 
69
- it 'should raise exception when neither id nor data passed' do
69
+ it "should raise exception when neither id nor data passed" do
70
70
  expect { source.send(:initialize, client) }.to raise_error(ArgumentError)
71
71
  end
72
72
 
73
- it 'should raise exception when both id and data is passed' do
74
- params = [client, { id: 'com.vmw.vra.workflow', data: sample_data }]
73
+ it "should raise exception when both id and data is passed" do
74
+ params = [client, { id: "com.vmw.vra.workflow", data: sample_data }]
75
75
  expect { source.send(:initialize, *params) }.to raise_error(ArgumentError)
76
76
  end
77
77
  end
78
78
 
79
- describe '#fetch_data' do
79
+ describe "#fetch_data" do
80
80
  let(:source) do
81
81
  described_class.allocate
82
82
  end
83
83
 
84
- it 'should fetch the data correctly' do
84
+ it "should fetch the data correctly" do
85
85
  allow(client).to receive(:get_parsed).and_return(sample_data)
86
- source.send(:initialize, client, id: '123456')
86
+ source.send(:initialize, client, id: "123456")
87
87
 
88
88
  data = source.send(:data)
89
89
  expect(data).to be(sample_data)
90
- expect(source.id).to eq(data['id'])
91
- expect(data['name']).to eq('Devops')
90
+ expect(source.id).to eq(data["id"])
91
+ expect(data["name"]).to eq("Devops")
92
92
  end
93
93
 
94
- it 'should raise when catalog with id not found' do
94
+ it "should raise when catalog with id not found" do
95
95
  allow(client).to receive(:get_parsed).and_raise(Vra::Exception::HTTPNotFound)
96
96
 
97
- expect { source.send(:initialize, client, id: sample_data['id']) }
97
+ expect { source.send(:initialize, client, id: sample_data["id"]) }
98
98
  .to raise_error(Vra::Exception::NotFound)
99
- .with_message("catalog source ID #{sample_data['id']} does not exist")
99
+ .with_message("catalog source ID #{sample_data["id"]} does not exist")
100
100
  end
101
101
  end
102
102
 
103
- describe 'attributes' do
103
+ describe "attributes" do
104
104
  let(:sample_type_data) do
105
- JSON.parse(File.read('spec/fixtures/resource/sample_catalog_type.json'))
105
+ JSON.parse(File.read("spec/fixtures/resource/sample_catalog_type.json"))
106
106
  end
107
107
 
108
- it 'should have the correct attributes' do
108
+ it "should have the correct attributes" do
109
109
  allow(client).to receive(:get_parsed).twice.and_return(sample_data, sample_type_data)
110
110
 
111
- source = described_class.new(client, id: sample_data['id'])
112
- expect(source.name).to eq('Devops')
113
- expect(source.catalog_type_id).to eq('com.vmw.blueprint')
111
+ source = described_class.new(client, id: sample_data["id"])
112
+ expect(source.name).to eq("Devops")
113
+ expect(source.catalog_type_id).to eq("com.vmw.blueprint")
114
114
  expect(source.catalog_type).to be_a(Vra::CatalogType)
115
- expect(source.config).to eq({ 'sourceProjectId' => 'pro-123456'})
115
+ expect(source.config).to eq({ "sourceProjectId" => "pro-123456" })
116
116
  expect(source.global?).to be_falsey
117
- expect(source.project_id).to eq('pro-123456')
117
+ expect(source.project_id).to eq("pro-123456")
118
118
  end
119
119
  end
120
120
 
121
- describe '#create' do
121
+ describe "#create" do
122
122
  let(:create_params) do
123
123
  {
124
- name: 'Devops',
125
- catalog_type_id: 'com.vmw.blueprint',
126
- project_id: 'pro-123456'
124
+ name: "Devops",
125
+ catalog_type_id: "com.vmw.blueprint",
126
+ project_id: "pro-123456",
127
127
  }
128
128
  end
129
129
 
@@ -131,17 +131,17 @@ describe Vra::CatalogSource do
131
131
  allow(client).to receive(:authorized?).and_return(true)
132
132
  end
133
133
 
134
- it 'should call the create api' do
135
- response = double('response', code: 200, body: sample_data.to_json, success?: true)
134
+ it "should call the create api" do
135
+ response = double("response", code: 200, body: sample_data.to_json, success?: true)
136
136
  expect(Vra::Http).to receive(:execute)
137
137
  .with(method: :post,
138
- url: client.full_url('/catalog/api/admin/sources'),
138
+ url: client.full_url("/catalog/api/admin/sources"),
139
139
  payload: {
140
- name: 'Devops',
141
- typeId: 'com.vmw.blueprint',
140
+ name: "Devops",
141
+ typeId: "com.vmw.blueprint",
142
142
  config: {
143
- sourceProjectId: 'pro-123456'
144
- }
143
+ sourceProjectId: "pro-123456",
144
+ },
145
145
  }.to_json,
146
146
  headers: anything,
147
147
  verify_ssl: true)
@@ -150,28 +150,28 @@ describe Vra::CatalogSource do
150
150
  described_class.create(client, create_params)
151
151
  end
152
152
 
153
- it 'should create a new source' do
154
- response = double('response', code: 200, body: sample_data.to_json, success?: true)
153
+ it "should create a new source" do
154
+ response = double("response", code: 200, body: sample_data.to_json, success?: true)
155
155
  allow(Vra::Http).to receive(:execute).and_return(response)
156
156
 
157
157
  new_source = described_class.create(client, create_params)
158
158
 
159
159
  expect(new_source).to be_a(described_class)
160
- expect(new_source.name).to eq('Devops')
161
- expect(new_source.project_id).to eq('pro-123456')
160
+ expect(new_source.name).to eq("Devops")
161
+ expect(new_source.project_id).to eq("pro-123456")
162
162
  end
163
163
  end
164
164
 
165
- describe '#entitle!' do
166
- it 'should entitle the source' do
165
+ describe "#entitle!" do
166
+ it "should entitle the source" do
167
167
  allow(client).to receive(:authorized?).and_return(true)
168
- stub_request(:get, client.full_url('/catalog/api/admin/sources/123456'))
168
+ stub_request(:get, client.full_url("/catalog/api/admin/sources/123456"))
169
169
  .to_return(status: 200, body: sample_data.to_json, headers: {})
170
170
 
171
- response = double('response', body: '{"message": "success"}', success?: true)
171
+ response = double("response", body: '{"message": "success"}', success?: true)
172
172
  allow(client).to receive(:http_post).and_return(response)
173
173
 
174
- entitle_response = described_class.entitle!(client, '123456')
174
+ entitle_response = described_class.entitle!(client, "123456")
175
175
  expect(entitle_response).not_to be_nil
176
176
  end
177
177
  end
data/spec/catalog_spec.rb CHANGED
@@ -17,42 +17,42 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require 'spec_helper'
20
+ require "spec_helper"
21
21
 
22
22
  describe Vra::Catalog do
23
23
  let(:client) do
24
24
  Vra::Client.new(
25
- username: 'user@corp.local',
26
- password: 'password',
27
- tenant: 'tenant',
28
- base_url: 'https://vra.corp.local'
25
+ username: "user@corp.local",
26
+ password: "password",
27
+ tenant: "tenant",
28
+ base_url: "https://vra.corp.local"
29
29
  )
30
30
  end
31
31
 
32
32
  let(:catalog_item) do
33
- JSON.parse(File.read('spec/fixtures/resource/sample_catalog_item.json'))
33
+ JSON.parse(File.read("spec/fixtures/resource/sample_catalog_item.json"))
34
34
  end
35
35
 
36
36
  let(:entitled_catalog_item) do
37
- JSON.parse(File.read('spec/fixtures/resource/sample_catalog_item_2.json'))
37
+ JSON.parse(File.read("spec/fixtures/resource/sample_catalog_item_2.json"))
38
38
  end
39
39
 
40
40
  before(:each) do
41
41
  allow(client).to receive(:authorized?).and_return(true)
42
42
  end
43
43
 
44
- describe '#all_items' do
45
- it 'calls the catalogItems endpoint' do
44
+ describe "#all_items" do
45
+ it "calls the catalogItems endpoint" do
46
46
  expect(client).to receive(:http_get_paginated_array!)
47
- .with('/catalog/api/admin/items', nil)
47
+ .with("/catalog/api/items", nil)
48
48
  .and_return([catalog_item])
49
49
 
50
50
  client.catalog.all_items
51
51
  end
52
52
 
53
- it 'returns a Vra::CatalogItem object' do
53
+ it "returns a Vra::CatalogItem object" do
54
54
  allow(client).to receive(:http_get_paginated_array!)
55
- .with('/catalog/api/admin/items', nil)
55
+ .with("/catalog/api/items", nil)
56
56
  .and_return([catalog_item])
57
57
 
58
58
  items = client.catalog.all_items
@@ -61,60 +61,60 @@ describe Vra::Catalog do
61
61
  end
62
62
  end
63
63
 
64
- describe '#entitled_items' do
65
- it 'calls the entitledCatalogItems endpoint' do
64
+ describe "#entitled_items" do
65
+ it "calls the entitledCatalogItems endpoint" do
66
66
  expect(client).to receive(:get_parsed)
67
- .with('/catalog/api/admin/entitlements?projectId=pro-123456')
68
- .and_return(JSON.parse(File.read('spec/fixtures/resource/sample_entitlements.json')))
67
+ .with("/catalog/api/admin/entitlements?projectId=pro-123456")
68
+ .and_return(JSON.parse(File.read("spec/fixtures/resource/sample_entitlements.json")))
69
69
 
70
- client.catalog.entitled_items('pro-123456')
70
+ client.catalog.entitled_items("pro-123456")
71
71
  end
72
72
 
73
- it 'returns a Vra::CatalogItem object' do
73
+ it "returns a Vra::CatalogItem object" do
74
74
  allow(client).to receive(:get_parsed)
75
- .with('/catalog/api/admin/entitlements?projectId=pro-123456')
76
- .and_return(JSON.parse(File.read('spec/fixtures/resource/sample_entitlements.json')))
75
+ .with("/catalog/api/admin/entitlements?projectId=pro-123456")
76
+ .and_return(JSON.parse(File.read("spec/fixtures/resource/sample_entitlements.json")))
77
77
 
78
- items = client.catalog.entitled_items('pro-123456')
78
+ items = client.catalog.entitled_items("pro-123456")
79
79
 
80
80
  expect(items.first).to be_an_instance_of(Vra::CatalogItem)
81
81
  end
82
82
 
83
- it 'return a Vra::CatalogSource object on source entitlements' do
83
+ it "return a Vra::CatalogSource object on source entitlements" do
84
84
  allow(client).to receive(:get_parsed)
85
- .with('/catalog/api/admin/entitlements?projectId=pro-123456')
86
- .and_return(JSON.parse(File.read('spec/fixtures/resource/sample_entitlements.json')))
85
+ .with("/catalog/api/admin/entitlements?projectId=pro-123456")
86
+ .and_return(JSON.parse(File.read("spec/fixtures/resource/sample_entitlements.json")))
87
87
 
88
- items = client.catalog.entitled_sources('pro-123456')
88
+ items = client.catalog.entitled_sources("pro-123456")
89
89
 
90
90
  expect(items.first).to be_an_instance_of(Vra::CatalogSource)
91
91
  end
92
92
  end
93
93
 
94
- describe '#request' do
95
- it 'returns a new Vra::CatalogRequest object' do
94
+ describe "#request" do
95
+ it "returns a new Vra::CatalogRequest object" do
96
96
  allow(Vra::CatalogItem).to receive(:new)
97
- request = client.catalog.request('blueprint-1', cpus: 2)
97
+ request = client.catalog.request("blueprint-1", cpus: 2)
98
98
  expect(request).to be_an_instance_of(Vra::DeploymentRequest)
99
99
  end
100
100
  end
101
101
 
102
- describe '#sources' do
102
+ describe "#sources" do
103
103
  let(:source_data) do
104
- JSON.parse(File.read('spec/fixtures/resource/sample_catalog_source.json'))
104
+ JSON.parse(File.read("spec/fixtures/resource/sample_catalog_source.json"))
105
105
  end
106
106
 
107
- it 'should call the api to fetch the sources' do
107
+ it "should call the api to fetch the sources" do
108
108
  expect(client).to receive(:http_get_paginated_array!)
109
- .with('/catalog/api/admin/sources', nil)
109
+ .with("/catalog/api/admin/sources", nil)
110
110
  .and_return([source_data])
111
111
 
112
112
  client.catalog.all_sources
113
113
  end
114
114
 
115
- it 'should return the Vra::CatalogSource object' do
115
+ it "should return the Vra::CatalogSource object" do
116
116
  expect(client).to receive(:http_get_paginated_array!)
117
- .with('/catalog/api/admin/sources', nil)
117
+ .with("/catalog/api/admin/sources", nil)
118
118
  .and_return([source_data])
119
119
 
120
120
  source = client.catalog.all_sources.first
@@ -123,22 +123,22 @@ describe Vra::Catalog do
123
123
  end
124
124
  end
125
125
 
126
- describe '#types' do
126
+ describe "#types" do
127
127
  let(:type_data) do
128
- JSON.parse(File.read('spec/fixtures/resource/sample_catalog_type.json'))
128
+ JSON.parse(File.read("spec/fixtures/resource/sample_catalog_type.json"))
129
129
  end
130
130
 
131
- it 'should call the api to fetch the types' do
131
+ it "should call the api to fetch the types" do
132
132
  expect(client).to receive(:http_get_paginated_array!)
133
- .with('/catalog/api/types', nil)
133
+ .with("/catalog/api/types", nil)
134
134
  .and_return([type_data])
135
135
 
136
136
  client.catalog.all_types
137
137
  end
138
138
 
139
- it 'should return the Vra::CatalogType object' do
139
+ it "should return the Vra::CatalogType object" do
140
140
  expect(client).to receive(:http_get_paginated_array!)
141
- .with('/catalog/api/types', nil)
141
+ .with("/catalog/api/types", nil)
142
142
  .and_return([type_data])
143
143
 
144
144
  source = client.catalog.all_types.first
@@ -147,17 +147,17 @@ describe Vra::Catalog do
147
147
  end
148
148
  end
149
149
 
150
- describe '#fetch_catalog_by_name' do
150
+ describe "#fetch_catalog_by_name" do
151
151
  let(:catalog_item) do
152
- JSON.parse(File.read('spec/fixtures/resource/sample_catalog_item.json'))
152
+ JSON.parse(File.read("spec/fixtures/resource/sample_catalog_item.json"))
153
153
  end
154
154
 
155
- it 'returns the catalogs by name' do
155
+ it "returns the catalogs by name" do
156
156
  expect(client).to receive(:http_get_paginated_array!)
157
- .with('/catalog/api/admin/items', 'search=centos')
157
+ .with("/catalog/api/items", "search=centos")
158
158
  .and_return([catalog_item])
159
159
 
160
- cat = client.catalog.fetch_catalog_items('centos').first
160
+ cat = client.catalog.fetch_catalog_items("centos").first
161
161
 
162
162
  expect(cat).to be_an_instance_of(Vra::CatalogItem)
163
163
  end
@@ -16,23 +16,23 @@
16
16
  # See the License for the specific language governing permissions and
17
17
  # limitations under the License.
18
18
  #
19
- require 'spec_helper'
19
+ require "spec_helper"
20
20
 
21
21
  describe Vra::CatalogType do
22
22
  let(:client) do
23
23
  Vra::Client.new(
24
- username: 'user@corp.local',
25
- password: 'password',
26
- tenant: 'tenant',
27
- base_url: 'https://vra.corp.local'
24
+ username: "user@corp.local",
25
+ password: "password",
26
+ tenant: "tenant",
27
+ base_url: "https://vra.corp.local"
28
28
  )
29
29
  end
30
30
 
31
31
  let(:sample_data) do
32
- JSON.parse(File.read('spec/fixtures/resource/sample_catalog_type.json'))
32
+ JSON.parse(File.read("spec/fixtures/resource/sample_catalog_type.json"))
33
33
  end
34
34
 
35
- describe '#initialize' do
35
+ describe "#initialize" do
36
36
  let(:cat_type) do
37
37
  described_class.allocate
38
38
  end
@@ -41,74 +41,74 @@ describe Vra::CatalogType do
41
41
  allow(client).to receive(:get_parsed).and_return(sample_data)
42
42
  end
43
43
 
44
- it 'should validate and fetch data' do
44
+ it "should validate and fetch data" do
45
45
  expect(cat_type).to receive(:validate!)
46
46
  expect(cat_type).to receive(:fetch_data)
47
47
 
48
- cat_type.send(:initialize, client, id: 'com.vmw.vro.workflow')
48
+ cat_type.send(:initialize, client, id: "com.vmw.vro.workflow")
49
49
  end
50
50
 
51
- it 'should fetch data when id is passed' do
52
- cat_type.send(:initialize, client, id: 'com.vmw.vro.workflow')
51
+ it "should fetch data when id is passed" do
52
+ cat_type.send(:initialize, client, id: "com.vmw.vro.workflow")
53
53
 
54
54
  expect(cat_type.send(:data)).not_to be_nil
55
55
  end
56
56
 
57
- it 'should set id when data is passed' do
57
+ it "should set id when data is passed" do
58
58
  cat_type.send(:initialize, client, data: sample_data)
59
59
 
60
- expect(cat_type.id).to eq('com.vmw.vro.workflow')
60
+ expect(cat_type.id).to eq("com.vmw.vro.workflow")
61
61
  end
62
62
  end
63
63
 
64
- describe '#validate' do
64
+ describe "#validate" do
65
65
  let(:cat_type) do
66
66
  described_class.allocate
67
67
  end
68
68
 
69
- it 'should raise exception when neither id nor data passed' do
69
+ it "should raise exception when neither id nor data passed" do
70
70
  expect { cat_type.send(:initialize, client) }.to raise_error(ArgumentError)
71
71
  end
72
72
 
73
- it 'should raise exception when both id and data is passed' do
74
- params = [client, { id: 'com.vmw.vra.workflow', data: sample_data }]
73
+ it "should raise exception when both id and data is passed" do
74
+ params = [client, { id: "com.vmw.vra.workflow", data: sample_data }]
75
75
  expect { cat_type.send(:initialize, *params) }.to raise_error(ArgumentError)
76
76
  end
77
77
  end
78
78
 
79
- describe '#fetch_data' do
79
+ describe "#fetch_data" do
80
80
  let(:cat_type) do
81
81
  described_class.allocate
82
82
  end
83
83
 
84
- it 'should fetch the data correctly' do
84
+ it "should fetch the data correctly" do
85
85
  allow(client).to receive(:get_parsed).and_return(sample_data)
86
- cat_type.send(:initialize, client, id: 'com.vmw.vro.workflow')
86
+ cat_type.send(:initialize, client, id: "com.vmw.vro.workflow")
87
87
 
88
88
  data = cat_type.send(:data)
89
89
  expect(data).not_to be_nil
90
- expect(cat_type.id).to eq(data['id'])
91
- expect(data['name']).to eq('vRealize Orchestrator Workflow')
90
+ expect(cat_type.id).to eq(data["id"])
91
+ expect(data["name"]).to eq("vRealize Orchestrator Workflow")
92
92
  end
93
93
 
94
- it 'should raise when catalog with type not found' do
94
+ it "should raise when catalog with type not found" do
95
95
  allow(client).to receive(:get_parsed).and_raise(Vra::Exception::HTTPNotFound)
96
96
 
97
- expect { cat_type.send(:initialize, client, id: sample_data['id']) }
97
+ expect { cat_type.send(:initialize, client, id: sample_data["id"]) }
98
98
  .to raise_error(Vra::Exception::NotFound)
99
- .with_message("catalog type ID #{sample_data['id']} does not exist")
99
+ .with_message("catalog type ID #{sample_data["id"]} does not exist")
100
100
  end
101
101
  end
102
102
 
103
- describe 'attributes' do
104
- it 'should have the correct attributes' do
103
+ describe "attributes" do
104
+ it "should have the correct attributes" do
105
105
  allow(client).to receive(:get_parsed).and_return(sample_data)
106
106
 
107
- cat_type = described_class.new(client, id: sample_data['id'])
108
- expect(cat_type.name).to eq('vRealize Orchestrator Workflow')
109
- expect(cat_type.base_url).to eq('https://vra.corp.local:8080/vro')
110
- expect(cat_type.config_schema).to eq(sample_data['configSchema'])
111
- expect(cat_type.icon_id).to eq('0616ff81-c13b-32fe-b3b9-de3c2edd85dd')
107
+ cat_type = described_class.new(client, id: sample_data["id"])
108
+ expect(cat_type.name).to eq("vRealize Orchestrator Workflow")
109
+ expect(cat_type.base_url).to eq("https://vra.corp.local:8080/vro")
110
+ expect(cat_type.config_schema).to eq(sample_data["configSchema"])
111
+ expect(cat_type.icon_id).to eq("0616ff81-c13b-32fe-b3b9-de3c2edd85dd")
112
112
  end
113
113
  end
114
114
  end