vmware-vra 3.1.2 → 3.2.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 +4 -4
- data/.github/workflows/linters.yml +9 -0
- data/.markdownlint.yaml +5 -0
- data/.mdlrc +1 -0
- data/CHANGELOG.md +15 -0
- data/README.md +40 -29
- data/Rakefile +2 -2
- data/lib/vra/catalog.rb +6 -7
- data/lib/vra/catalog_base.rb +4 -4
- data/lib/vra/catalog_item.rb +12 -12
- data/lib/vra/catalog_source.rb +13 -13
- data/lib/vra/catalog_type.rb +6 -6
- data/lib/vra/client.rb +26 -15
- data/lib/vra/deployment.rb +25 -21
- data/lib/vra/deployment_request.rb +8 -9
- data/lib/vra/deployments.rb +1 -1
- data/lib/vra/http.rb +6 -6
- data/lib/vra/request.rb +10 -6
- data/lib/vra/request_parameters.rb +9 -9
- data/lib/vra/resource.rb +16 -16
- data/lib/vra/version.rb +1 -1
- data/lib/vra.rb +14 -14
- data/spec/catalog_item_spec.rb +50 -50
- data/spec/catalog_source_spec.rb +53 -53
- data/spec/catalog_spec.rb +45 -45
- data/spec/catalog_type_spec.rb +32 -32
- data/spec/client_spec.rb +202 -202
- data/spec/deployment_request_spec.rb +74 -74
- data/spec/deployment_spec.rb +70 -70
- data/spec/deployments_spec.rb +19 -19
- data/spec/http_spec.rb +59 -59
- data/spec/request_spec.rb +34 -34
- data/spec/resource_spec.rb +55 -55
- data/spec/spec_helper.rb +4 -4
- metadata +9 -9
- data/.github/ISSUE_TEMPLATE.md +0 -23
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -14
- data/.github/workflows/unit.yml +0 -23
data/spec/catalog_item_spec.rb
CHANGED
@@ -17,142 +17,142 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
require
|
20
|
+
require "spec_helper"
|
21
21
|
|
22
22
|
describe Vra::CatalogItem do
|
23
23
|
let(:client) do
|
24
24
|
Vra::Client.new(
|
25
|
-
username:
|
26
|
-
password:
|
27
|
-
|
28
|
-
base_url:
|
25
|
+
username: "user@corp.local",
|
26
|
+
password: "password",
|
27
|
+
domain: "domain",
|
28
|
+
base_url: "https://vra.corp.local"
|
29
29
|
)
|
30
30
|
end
|
31
31
|
|
32
|
-
let(:catalog_id) {
|
32
|
+
let(:catalog_id) { "123456" }
|
33
33
|
|
34
34
|
let(:catalog_item_payload) do
|
35
|
-
JSON.parse(File.read(
|
35
|
+
JSON.parse(File.read("spec/fixtures/resource/sample_catalog_item.json"))
|
36
36
|
end
|
37
37
|
|
38
38
|
let(:other_catalog_item_payload) do
|
39
|
-
JSON.parse(File.read(
|
39
|
+
JSON.parse(File.read("spec/fixtures/resource/sample_catalog_item_2.json"))
|
40
40
|
end
|
41
41
|
|
42
|
-
describe
|
43
|
-
it
|
42
|
+
describe "#initialize" do
|
43
|
+
it "raises an error if no ID or catalog item data have been provided" do
|
44
44
|
expect { Vra::CatalogItem.new(client) }.to raise_error(ArgumentError)
|
45
45
|
end
|
46
46
|
|
47
|
-
it
|
48
|
-
expect { Vra::CatalogItem.new(client, id: 123, data:
|
47
|
+
it "raises an error if an ID and catalog item data have both been provided" do
|
48
|
+
expect { Vra::CatalogItem.new(client, id: 123, data: "foo") }.to raise_error(ArgumentError)
|
49
49
|
end
|
50
50
|
|
51
|
-
context
|
52
|
-
it
|
51
|
+
context "when an ID is provided" do
|
52
|
+
it "fetches the catalog_item record" do
|
53
53
|
catalog_item = Vra::CatalogItem.allocate
|
54
54
|
expect(catalog_item).to receive(:fetch_catalog_item)
|
55
55
|
catalog_item.send(:initialize, client, id: catalog_id)
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
context
|
60
|
-
it
|
59
|
+
context "when catalog item data is provided" do
|
60
|
+
it "populates the ID correctly" do
|
61
61
|
catalog_item = Vra::CatalogItem.new(client, data: catalog_item_payload)
|
62
62
|
expect(catalog_item.id).to eq catalog_id
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
describe
|
68
|
-
context
|
69
|
-
let(:response) { double(
|
67
|
+
describe "#fetch_catalog_item" do
|
68
|
+
context "when the catalog item exists" do
|
69
|
+
let(:response) { double("response", code: 200, body: catalog_item_payload.to_json) }
|
70
70
|
|
71
|
-
it
|
72
|
-
expect(client).to receive(:http_get).with(
|
73
|
-
Vra::CatalogItem.new(client, id:
|
71
|
+
it "calls http_get against the catalog_service" do
|
72
|
+
expect(client).to receive(:http_get).with("/catalog/api/items/catalog-12345").and_return(response)
|
73
|
+
Vra::CatalogItem.new(client, id: "catalog-12345")
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
context
|
78
|
-
it
|
77
|
+
context "when the catalog item does not exist" do
|
78
|
+
it "raises an exception" do
|
79
79
|
allow(client)
|
80
80
|
.to receive(:http_get)
|
81
|
-
.with(
|
81
|
+
.with("/catalog/api/items/catalog-12345")
|
82
82
|
.and_raise(Vra::Exception::HTTPNotFound)
|
83
83
|
|
84
|
-
expect { Vra::CatalogItem.new(client, id:
|
84
|
+
expect { Vra::CatalogItem.new(client, id: "catalog-12345") }
|
85
85
|
.to raise_error(Vra::Exception::NotFound)
|
86
|
-
.with_message(
|
86
|
+
.with_message("catalog ID catalog-12345 does not exist")
|
87
87
|
end
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
-
describe
|
92
|
-
it
|
91
|
+
describe "#entitle!" do
|
92
|
+
it "should entitle the catalog item" do
|
93
93
|
allow(client).to receive(:authorized?).and_return(true)
|
94
|
-
stub_request(:get, client.full_url(
|
94
|
+
stub_request(:get, client.full_url("/catalog/api/items/123456"))
|
95
95
|
.to_return(status: 200, body: catalog_item_payload.to_json, headers: {})
|
96
96
|
|
97
|
-
response = double(
|
97
|
+
response = double("response", body: '{"message": "success"}', success?: true)
|
98
98
|
allow(client).to receive(:http_post).and_return(response)
|
99
99
|
|
100
|
-
entitle_response = described_class.entitle!(client,
|
100
|
+
entitle_response = described_class.entitle!(client, "123456")
|
101
101
|
expect(entitle_response).not_to be_nil
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
105
|
-
describe
|
106
|
-
it
|
105
|
+
describe "#attributes" do
|
106
|
+
it "should have the correct attributes" do
|
107
107
|
allow(client).to receive(:authorized?).and_return(true)
|
108
|
-
stub_request(:get, client.full_url(
|
108
|
+
stub_request(:get, client.full_url("/catalog/api/admin/sources/source-123456"))
|
109
109
|
.to_return(
|
110
110
|
status: 200,
|
111
|
-
body: File.read(
|
111
|
+
body: File.read("spec/fixtures/resource/sample_catalog_source.json"),
|
112
112
|
headers: {}
|
113
113
|
)
|
114
114
|
catalog_item = described_class.new(client, data: catalog_item_payload)
|
115
115
|
|
116
|
-
expect(catalog_item.name).to eq(
|
117
|
-
expect(catalog_item.description).to eq(
|
118
|
-
expect(catalog_item.source_id).to eq(
|
119
|
-
expect(catalog_item.source_name).to eq(
|
120
|
-
expect(catalog_item.icon_id).to eq(
|
116
|
+
expect(catalog_item.name).to eq("centos")
|
117
|
+
expect(catalog_item.description).to eq("Centos Cat")
|
118
|
+
expect(catalog_item.source_id).to eq("source-123456")
|
119
|
+
expect(catalog_item.source_name).to eq("Source 123")
|
120
|
+
expect(catalog_item.icon_id).to eq("1495b8d9")
|
121
121
|
expect(catalog_item.source).to be_a(Vra::CatalogSource)
|
122
122
|
expect(catalog_item.type).to be_a(Vra::CatalogType)
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
-
describe
|
126
|
+
describe "#versions" do
|
127
127
|
let(:versions_response) do
|
128
|
-
[{ id:
|
128
|
+
[{ id: "2", description: "v2.0" }, { id: "1", description: "v1.0" }]
|
129
129
|
end
|
130
130
|
|
131
131
|
before do
|
132
132
|
allow(client).to receive(:authorized?).and_return(true)
|
133
133
|
end
|
134
134
|
|
135
|
-
it
|
135
|
+
it "should call the api to fetch the versions" do
|
136
136
|
expect(client)
|
137
137
|
.to receive(:http_get_paginated_array!)
|
138
|
-
.with(
|
138
|
+
.with("/catalog/api/items/catalog-12345/versions")
|
139
139
|
.and_return(versions_response)
|
140
140
|
|
141
|
-
described_class.fetch_latest_version(client,
|
141
|
+
described_class.fetch_latest_version(client, "catalog-12345")
|
142
142
|
end
|
143
143
|
|
144
|
-
it
|
145
|
-
stub_request(:get, client.full_url(
|
144
|
+
it "should return the correct version" do
|
145
|
+
stub_request(:get, client.full_url("/catalog/api/items/catalog-12345/versions?$skip=0&$top=20"))
|
146
146
|
.to_return(
|
147
147
|
status: 200,
|
148
148
|
body: {
|
149
149
|
content: versions_response,
|
150
|
-
totalPages: 1
|
150
|
+
totalPages: 1,
|
151
151
|
}.to_json,
|
152
152
|
headers: {}
|
153
153
|
)
|
154
154
|
|
155
|
-
expect(described_class.fetch_latest_version(client,
|
155
|
+
expect(described_class.fetch_latest_version(client, "catalog-12345")).to eq("2")
|
156
156
|
end
|
157
157
|
end
|
158
158
|
end
|
data/spec/catalog_source_spec.rb
CHANGED
@@ -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
|
19
|
+
require "spec_helper"
|
20
20
|
|
21
21
|
describe Vra::CatalogSource do
|
22
22
|
let(:client) do
|
23
23
|
Vra::Client.new(
|
24
|
-
username:
|
25
|
-
password:
|
26
|
-
|
27
|
-
base_url:
|
24
|
+
username: "user@corp.local",
|
25
|
+
password: "password",
|
26
|
+
domain: "domain",
|
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(
|
32
|
+
JSON.parse(File.read("spec/fixtures/resource/sample_catalog_source.json"))
|
33
33
|
end
|
34
34
|
|
35
|
-
describe
|
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
|
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:
|
48
|
+
source.send(:initialize, client, id: "123456")
|
49
49
|
end
|
50
50
|
|
51
|
-
it
|
52
|
-
source.send(:initialize, client, id:
|
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
|
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(
|
60
|
+
expect(source.id).to eq("123456")
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
describe
|
64
|
+
describe "#validate" do
|
65
65
|
let(:source) do
|
66
66
|
described_class.allocate
|
67
67
|
end
|
68
68
|
|
69
|
-
it
|
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
|
74
|
-
params = [client, { id:
|
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
|
79
|
+
describe "#fetch_data" do
|
80
80
|
let(:source) do
|
81
81
|
described_class.allocate
|
82
82
|
end
|
83
83
|
|
84
|
-
it
|
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:
|
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[
|
91
|
-
expect(data[
|
90
|
+
expect(source.id).to eq(data["id"])
|
91
|
+
expect(data["name"]).to eq("Devops")
|
92
92
|
end
|
93
93
|
|
94
|
-
it
|
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[
|
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[
|
99
|
+
.with_message("catalog source ID #{sample_data["id"]} does not exist")
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
-
describe
|
103
|
+
describe "attributes" do
|
104
104
|
let(:sample_type_data) do
|
105
|
-
JSON.parse(File.read(
|
105
|
+
JSON.parse(File.read("spec/fixtures/resource/sample_catalog_type.json"))
|
106
106
|
end
|
107
107
|
|
108
|
-
it
|
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[
|
112
|
-
expect(source.name).to eq(
|
113
|
-
expect(source.catalog_type_id).to eq(
|
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({
|
115
|
+
expect(source.config).to eq({ "sourceProjectId" => "pro-123456" })
|
116
116
|
expect(source.global?).to be_falsey
|
117
|
-
expect(source.project_id).to eq(
|
117
|
+
expect(source.project_id).to eq("pro-123456")
|
118
118
|
end
|
119
119
|
end
|
120
120
|
|
121
|
-
describe
|
121
|
+
describe "#create" do
|
122
122
|
let(:create_params) do
|
123
123
|
{
|
124
|
-
name:
|
125
|
-
catalog_type_id:
|
126
|
-
project_id:
|
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
|
135
|
-
response = double(
|
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(
|
138
|
+
url: client.full_url("/catalog/api/admin/sources"),
|
139
139
|
payload: {
|
140
|
-
name:
|
141
|
-
typeId:
|
140
|
+
name: "Devops",
|
141
|
+
typeId: "com.vmw.blueprint",
|
142
142
|
config: {
|
143
|
-
sourceProjectId:
|
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
|
154
|
-
response = double(
|
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(
|
161
|
-
expect(new_source.project_id).to eq(
|
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
|
166
|
-
it
|
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(
|
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(
|
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,
|
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
|
20
|
+
require "spec_helper"
|
21
21
|
|
22
22
|
describe Vra::Catalog do
|
23
23
|
let(:client) do
|
24
24
|
Vra::Client.new(
|
25
|
-
username:
|
26
|
-
password:
|
27
|
-
|
28
|
-
base_url:
|
25
|
+
username: "user@corp.local",
|
26
|
+
password: "password",
|
27
|
+
domain: "domain",
|
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(
|
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(
|
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
|
45
|
-
it
|
44
|
+
describe "#all_items" do
|
45
|
+
it "calls the catalogItems endpoint" do
|
46
46
|
expect(client).to receive(:http_get_paginated_array!)
|
47
|
-
.with(
|
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
|
53
|
+
it "returns a Vra::CatalogItem object" do
|
54
54
|
allow(client).to receive(:http_get_paginated_array!)
|
55
|
-
.with(
|
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
|
65
|
-
it
|
64
|
+
describe "#entitled_items" do
|
65
|
+
it "calls the entitledCatalogItems endpoint" do
|
66
66
|
expect(client).to receive(:get_parsed)
|
67
|
-
.with(
|
68
|
-
.and_return(JSON.parse(File.read(
|
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(
|
70
|
+
client.catalog.entitled_items("pro-123456")
|
71
71
|
end
|
72
72
|
|
73
|
-
it
|
73
|
+
it "returns a Vra::CatalogItem object" do
|
74
74
|
allow(client).to receive(:get_parsed)
|
75
|
-
.with(
|
76
|
-
.and_return(JSON.parse(File.read(
|
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(
|
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
|
83
|
+
it "return a Vra::CatalogSource object on source entitlements" do
|
84
84
|
allow(client).to receive(:get_parsed)
|
85
|
-
.with(
|
86
|
-
.and_return(JSON.parse(File.read(
|
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(
|
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
|
95
|
-
it
|
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(
|
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
|
102
|
+
describe "#sources" do
|
103
103
|
let(:source_data) do
|
104
|
-
JSON.parse(File.read(
|
104
|
+
JSON.parse(File.read("spec/fixtures/resource/sample_catalog_source.json"))
|
105
105
|
end
|
106
106
|
|
107
|
-
it
|
107
|
+
it "should call the api to fetch the sources" do
|
108
108
|
expect(client).to receive(:http_get_paginated_array!)
|
109
|
-
.with(
|
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
|
115
|
+
it "should return the Vra::CatalogSource object" do
|
116
116
|
expect(client).to receive(:http_get_paginated_array!)
|
117
|
-
.with(
|
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
|
126
|
+
describe "#types" do
|
127
127
|
let(:type_data) do
|
128
|
-
JSON.parse(File.read(
|
128
|
+
JSON.parse(File.read("spec/fixtures/resource/sample_catalog_type.json"))
|
129
129
|
end
|
130
130
|
|
131
|
-
it
|
131
|
+
it "should call the api to fetch the types" do
|
132
132
|
expect(client).to receive(:http_get_paginated_array!)
|
133
|
-
.with(
|
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
|
139
|
+
it "should return the Vra::CatalogType object" do
|
140
140
|
expect(client).to receive(:http_get_paginated_array!)
|
141
|
-
.with(
|
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
|
150
|
+
describe "#fetch_catalog_by_name" do
|
151
151
|
let(:catalog_item) do
|
152
|
-
JSON.parse(File.read(
|
152
|
+
JSON.parse(File.read("spec/fixtures/resource/sample_catalog_item.json"))
|
153
153
|
end
|
154
154
|
|
155
|
-
it
|
155
|
+
it "returns the catalogs by name" do
|
156
156
|
expect(client).to receive(:http_get_paginated_array!)
|
157
|
-
.with(
|
157
|
+
.with("/catalog/api/items", "search=centos")
|
158
158
|
.and_return([catalog_item])
|
159
159
|
|
160
|
-
cat = client.catalog.fetch_catalog_items(
|
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
|