vmware-vra 2.7.2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/CHANGELOG.md +5 -0
  4. data/README.md +79 -144
  5. data/Rakefile +0 -11
  6. data/lib/vra/catalog.rb +39 -8
  7. data/lib/vra/catalog_base.rb +62 -0
  8. data/lib/vra/catalog_item.rb +28 -74
  9. data/lib/vra/catalog_source.rb +116 -0
  10. data/lib/vra/catalog_type.rb +56 -0
  11. data/lib/vra/client.rb +62 -54
  12. data/lib/vra/deployment.rb +155 -0
  13. data/lib/vra/deployment_request.rb +117 -0
  14. data/lib/vra/{resources.rb → deployments.rb} +26 -17
  15. data/lib/vra/exceptions.rb +1 -1
  16. data/lib/vra/http.rb +11 -6
  17. data/lib/vra/request.rb +28 -36
  18. data/lib/vra/request_parameters.rb +12 -12
  19. data/lib/vra/resource.rb +32 -203
  20. data/lib/vra/version.rb +2 -2
  21. data/lib/vra.rb +15 -12
  22. data/spec/catalog_item_spec.rb +64 -222
  23. data/spec/catalog_source_spec.rb +178 -0
  24. data/spec/catalog_spec.rb +112 -72
  25. data/spec/catalog_type_spec.rb +114 -0
  26. data/spec/client_spec.rb +271 -226
  27. data/spec/deployment_request_spec.rb +192 -0
  28. data/spec/deployment_spec.rb +227 -0
  29. data/spec/deployments_spec.rb +80 -0
  30. data/spec/fixtures/resource/sample_catalog_item.json +18 -0
  31. data/spec/fixtures/resource/sample_catalog_item_2.json +18 -0
  32. data/spec/fixtures/resource/sample_catalog_source.json +20 -0
  33. data/spec/fixtures/resource/sample_catalog_type.json +49 -0
  34. data/spec/fixtures/resource/sample_dep_actions.json +58 -0
  35. data/spec/fixtures/resource/sample_dep_request.json +19 -0
  36. data/spec/fixtures/resource/sample_dep_resource.json +112 -0
  37. data/spec/fixtures/resource/sample_deployment.json +26 -0
  38. data/spec/fixtures/resource/sample_entitlements.json +25 -0
  39. data/spec/http_spec.rb +63 -61
  40. data/spec/request_spec.rb +62 -68
  41. data/spec/resource_spec.rb +71 -390
  42. data/spec/spec_helper.rb +10 -4
  43. data/vmware-vra.gemspec +0 -1
  44. metadata +40 -30
  45. data/.travis.yml +0 -14
  46. data/lib/vra/catalog_request.rb +0 -137
  47. data/lib/vra/requests.rb +0 -41
  48. data/spec/catalog_request_spec.rb +0 -268
  49. data/spec/requests_spec.rb +0 -60
  50. data/spec/resources_spec.rb +0 -71
@@ -0,0 +1,112 @@
1
+ {
2
+ "id": "res-123",
3
+ "name": "Cloud_vSphere_Machine_1",
4
+ "type": "Cloud.vSphere.Machine",
5
+ "createdAt": "2021-12-20T13:22:10.404600Z",
6
+ "properties": {
7
+ "resourceId": "671c2ec7-4863-42c8-addf-7e420cb190b7",
8
+ "Owner": "admin",
9
+ "zone_overlapping_migrated": "true",
10
+ "powerState": "ON",
11
+ "environmentName": "On premise",
12
+ "hasSnapshots": "false",
13
+ "computeHostType": "ClusterComputeResource",
14
+ "id": "/resources/compute/671c2ec7-4863-42c8-addf-7e420cb190b7",
15
+ "cpuCount": 2,
16
+ "totalMemoryMB": 8192,
17
+ "endpointType": "vsphere",
18
+ "resourceLink": "/resources/compute/671c2ec7-4863-42c8-addf-7e420cb190b7",
19
+ "networks": [
20
+ {
21
+ "address": "192.168.110.200",
22
+ "assignment": "dynamic",
23
+ "mac_address": "00:50:56:ae:95:3c",
24
+ "name": "VM Network",
25
+ "resourceName": "VM Network",
26
+ "id": "/resources/network-interfaces/net-1",
27
+ "ipv6Addresses": [
28
+ "fd27:5600:0:232::7cd",
29
+ "fe80::59be:c7d0:665f:13f5"
30
+ ],
31
+ "deviceIndex": 0
32
+ },
33
+ {
34
+ "address": "192.168.220.200",
35
+ "assignment": "dynamic",
36
+ "mac_address": "00:50:56:ae:95:3d",
37
+ "name": "Management Network",
38
+ "resourceName": "Management Network",
39
+ "id": "/resources/network-interfaces/net-2",
40
+ "ipv6Addresses": [
41
+ "fd27:5600:0:232::8cd",
42
+ "fe80::59be:c7d0:665f:13e1"
43
+ ],
44
+ "deviceIndex": 0
45
+ }
46
+ ],
47
+ "resourcePool": "/resources/pools/d66ae91db21f2075-7f703c5265a63d87",
48
+ "componentType": "Cloud.vSphere.Machine",
49
+ "address": "10.30.236.64",
50
+ "resourceGroupName": "VRATEMPDCI",
51
+ "datastoreName": "ncvra01",
52
+ "coreCount": "2",
53
+ "flavorMappingName": "",
54
+ "customizationSpec": "vRA-Windows2019",
55
+ "resourceDescLink": "/resources/compute-descriptions/e756089d-5256-48eb-977c-4af31405eb72",
56
+ "project": "pro-123",
57
+ "provisionGB": "100",
58
+ "zone": "USMORVRA01",
59
+ "memoryGB": "8",
60
+ "image": "VRA-nc-base-w2k19",
61
+ "resourceName": "nc-vra-2073",
62
+ "flavor": "Medium",
63
+ "softwareName": "Microsoft Windows Server 2016 or later (64-bit)",
64
+ "name": "Cloud_vSphere_Machine_1",
65
+ "region": "USNC-VRA-CL01",
66
+ "storage": {
67
+ "disks": [
68
+ {
69
+ "independent": "false",
70
+ "sharesLevel": "normal",
71
+ "diskPlacementRef": "Datastore:datastore-361848",
72
+ "controllerKey": "1000",
73
+ "type": "HDD",
74
+ "shares": "1000",
75
+ "provisionGB": "100",
76
+ "encrypted": false,
77
+ "bootOrder": 1,
78
+ "provisioningType": "thin",
79
+ "capacityGb": 100,
80
+ "vm": "VirtualMachine:vm-1086705",
81
+ "limitIops": "-1",
82
+ "name": "nc-vra-2073-boot-disk",
83
+ "controllerUnitNumber": "0",
84
+ "persistent": false,
85
+ "vcUuid": "d9a8730b-c244-4cd2-a570-41f3724b1bff"
86
+ },
87
+ {
88
+ "encrypted": false,
89
+ "capacityGb": 0,
90
+ "vm": "VirtualMachine:vm-1086705",
91
+ "name": "CD/DVD drive 1",
92
+ "controllerUnitNumber": "0",
93
+ "controllerKey": "15000",
94
+ "type": "CDROM",
95
+ "persistent": false,
96
+ "vcUuid": "d9a8730b-c244-4cd2-a570-41f3724b1bff"
97
+ }
98
+ ]
99
+ },
100
+ "providerId": "5035dbc0-5ecd-2875-f21c-5fe844e4dcd4",
101
+ "osType": "WINDOWS",
102
+ "instanceUUID": "5035dbc0-5ecd-2875-f21c-5fe844e4dcd4",
103
+ "endpointId": "d3b65631-3196-4e38-ad4a-ee02afa2bea4",
104
+ "datacenter": "Datacenter:datacenter-342098",
105
+ "primaryMAC": "00:50:56:b5:72:2d",
106
+ "computeHostRef": "ClusterComputeResource:domain-c342105",
107
+ "account": "nc-devvcmor01",
108
+ "vcUuid": "d9a8730b-c244-4cd2-a570-41f3724b1bff"
109
+ },
110
+ "syncStatus": "SUCCESS",
111
+ "state": "OK"
112
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "id": "dep-123",
3
+ "name": "win-DCI",
4
+ "description": "win-dci deployment",
5
+ "orgId": "origin-123",
6
+ "catalogItemId": "cat-123",
7
+ "catalogItemVersion": "6",
8
+ "blueprintId": "blueprint-123",
9
+ "blueprintVersion": "6",
10
+ "iconId": "icon-123",
11
+ "createdAt": "2021-12-31T09:25:09.668646Z",
12
+ "createdBy": "administrator",
13
+ "ownedBy": "administrator",
14
+ "lastUpdatedAt": "2021-12-31T09:27:32.801759Z",
15
+ "lastUpdatedBy": "administrator",
16
+ "leaseExpireAt": "2022-03-01T09:27:00Z",
17
+ "inputs": {
18
+ "count": 1,
19
+ "image": "SQL 2016",
20
+ "flavor": "Medium",
21
+ "sql-image": "Windows2016",
22
+ "hardware-config": "Medium"
23
+ },
24
+ "projectId": "pro-123456",
25
+ "status": "CREATE_SUCCESSFUL"
26
+ }
@@ -0,0 +1,25 @@
1
+ [
2
+ {
3
+ "id": "0225face-95dd-49a5-b0cd-493759a2f7c5",
4
+ "projectId": "6ba69375-79d5-42c3-a099-7d32739f71a7",
5
+ "definition": {
6
+ "type": "CatalogSourceIdentifier",
7
+ "id": "18102dc2-9e48-487a-93a8-aafab2ecc057",
8
+ "name": "DCI",
9
+ "sourceType": "com.vmw.blueprint",
10
+ "numItems": 17,
11
+ "iconId": "1495b8d9-9428-30d6-9626-10ff9281645e"
12
+ }
13
+ },
14
+ {
15
+ "id": "07317598-0a6b-47c4-a5e9-ba0c9ce430b1",
16
+ "projectId": "6ba69375-79d5-42c3-a099-7d32739f71a7",
17
+ "definition": {
18
+ "type": "CatalogItemIdentifier",
19
+ "id": "e186f066-7971-485a-8aed-bf75f16d3ea8",
20
+ "name": "TemplateCreation",
21
+ "sourceType": "com.vmw.vro.workflow",
22
+ "numItems": 1
23
+ }
24
+ }
25
+ ]
data/spec/http_spec.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
- require "spec_helper"
3
- require "webmock"
2
+
3
+ require 'spec_helper'
4
+ require 'webmock'
4
5
 
5
6
  describe Vra::Http do
6
7
  def expecting_request(method, url, with = nil)
@@ -26,128 +27,129 @@ describe Vra::Http do
26
27
  execute :head, params
27
28
  end
28
29
 
29
- describe "#execute" do
30
- it "makes a HEAD request" do
31
- headers = { "X-Made-Up-Header" => "Foo AND bar? Are you sure?" }
30
+ describe '#execute' do
31
+ it 'makes a HEAD request' do
32
+ headers = { 'X-Made-Up-Header' => 'Foo AND bar? Are you sure?' }
32
33
 
33
- expecting_request(:head, "http://test.local", headers: headers) do
34
- head url: "http://test.local", headers: headers
34
+ expecting_request(:head, 'http://test.local', headers: headers) do
35
+ head url: 'http://test.local', headers: headers
35
36
  end
36
37
  end
37
38
 
38
- it "makes a GET request" do
39
- headers = { "X-Made-Up-Header" => "Foo AND bar? Are you sure?" }
39
+ it 'makes a GET request' do
40
+ headers = { 'X-Made-Up-Header' => 'Foo AND bar? Are you sure?' }
40
41
 
41
- expecting_request(:get, "http://test.local", headers: headers) do
42
- get url: "http://test.local", headers: headers
42
+ expecting_request(:get, 'http://test.local', headers: headers) do
43
+ get url: 'http://test.local', headers: headers
43
44
  end
44
45
  end
45
46
 
46
- it "makes a POST request" do
47
- headers = { "X-Made-Up-Header" => "Foo AND bar? Are you sure?" }
48
- payload = "withabodylikethis"
47
+ it 'makes a POST request' do
48
+ headers = { 'X-Made-Up-Header' => 'Foo AND bar? Are you sure?' }
49
+ payload = 'withabodylikethis'
49
50
 
50
- expecting_request(:post, "http://test.local", headers: headers, body: payload) do
51
- post url: "http://test.local", headers: headers, payload: payload
51
+ expecting_request(:post, 'http://test.local', headers: headers, body: payload) do
52
+ post url: 'http://test.local', headers: headers, payload: payload
52
53
  end
53
54
  end
54
55
 
55
- it "preserves Location" do
56
- stub_request(:head, "http://test.local")
57
- .to_return(headers: { "Location" => "http://test-location.local" })
56
+ it 'preserves Location' do
57
+ stub_request(:head, 'http://test.local')
58
+ .to_return(headers: { 'Location' => 'http://test-location.local' })
58
59
 
59
- response = head(url: "http://test.local")
60
+ response = head(url: 'http://test.local')
60
61
 
61
- expect(response.location).to eq "http://test-location.local"
62
+ expect(response.location).to eq 'http://test-location.local'
62
63
  end
63
64
 
64
- it "preserves status code" do
65
- stub_request(:head, "http://test.local")
66
- .to_return(status: [204, "No content"])
65
+ it 'preserves status code' do
66
+ stub_request(:head, 'http://test.local')
67
+ .to_return(status: [204, 'No content'])
67
68
 
68
- response = head(url: "http://test.local")
69
+ response = head(url: 'http://test.local')
69
70
 
70
71
  expect(response.code).to eq 204
71
72
  end
72
73
 
73
- it "configures ssl verification" do
74
+ it 'configures ssl verification' do
74
75
  allow(Net::HTTP).to receive(:start).and_wrap_original do |_http, *args|
75
76
  expect(args.last).to include(verify_mode: OpenSSL::SSL::VERIFY_NONE)
76
- double("response", final?: true, success?: true)
77
+ double('response', final?: true, success?: true)
77
78
  end
78
79
 
79
- execute(:get, url: "https://test.local", verify_ssl: false)
80
+ execute(:get, url: 'https://test.local', verify_ssl: false)
80
81
  end
81
82
 
82
- context "when successful" do
83
- it "returns a successful response given a status 200" do
84
- stub_request(:head, "http://test.local")
85
- .to_return(status: [200, "Whatevs"])
83
+ context 'when successful' do
84
+ it 'returns a successful response given a status 200' do
85
+ stub_request(:head, 'http://test.local')
86
+ .to_return(status: [200, 'Whatevs'])
86
87
 
87
- response = head(url: "http://test.local")
88
+ response = head(url: 'http://test.local')
88
89
 
89
90
  expect(response.success_ok?).to be_truthy
90
91
  end
91
92
 
92
- it "returns a successful response given a status 204" do
93
- stub_request(:head, "http://test.local")
94
- .to_return(status: [204, "Whatevs"])
93
+ it 'returns a successful response given a status 204' do
94
+ stub_request(:head, 'http://test.local')
95
+ .to_return(status: [204, 'Whatevs'])
95
96
 
96
- response = head(url: "http://test.local")
97
+ response = head(url: 'http://test.local')
97
98
 
98
99
  expect(response.success_no_content?).to be_truthy
99
100
  end
100
101
  end
101
102
 
102
- context "when unsuccessful" do
103
+ context 'when unsuccessful' do
103
104
  (400..418).each do |status|
104
- it 'raises an exception given a status #{status}' do
105
- stub_request(:get, "http://test.local")
106
- .to_return(status: [status, "Whatevs"],
107
- body: "Error body")
105
+ it "raises an exception given a status #{status}" do
106
+ stub_request(:get, 'http://test.local')
107
+ .to_return(status: [status, 'Whatevs'],
108
+ body: '{"message":"Error"}')
108
109
 
109
- expect { get(url: "http://test.local") }.to raise_error do |error|
110
+ expect { get(url: 'http://test.local') }.to raise_error do |error|
110
111
  expect(error).to be_a(StandardError)
111
112
  expect(error.http_code).to eq status
112
- expect(error.response).to eq "Error body"
113
+ expect(error.response).to eq({ 'message' => 'Error' })
113
114
  end
114
115
  end
115
116
  end
116
117
  end
117
118
 
118
- context "when redirected" do
119
+ context 'when redirected' do
119
120
  [301, 302, 307].each do |status|
120
- %i{get head}.each do |method|
121
+ %i[get head].each do |method|
121
122
  it "follows #{status} redirected #{method.to_s.upcase} requests" do
122
- stub_request(method, "http://test.local")
123
- .to_return(status: [status, "redirect"],
124
- headers: { "Location" => "http://test.local/redirect" })
125
- expecting_request(method, "http://test.local/redirect") do
126
- execute(method, url: "http://test.local")
123
+ stub_request(method, 'http://test.local')
124
+ .to_return(status: [status, 'redirect'],
125
+ headers: { 'Location' => 'http://test.local/redirect' })
126
+
127
+ expecting_request(method, 'http://test.local/redirect') do
128
+ execute(method, url: 'http://test.local')
127
129
  end
128
130
  end
129
131
  end
130
132
 
131
133
  it "does not follow #{status} redirected POST requests" do
132
- stub_request(:post, "http://test.local")
133
- .to_return(status: [status, "redirect"],
134
- headers: { "Location" => "http://test.local/redirect" })
134
+ stub_request(:post, 'http://test.local')
135
+ .to_return(status: [status, 'redirect'],
136
+ headers: { 'Location' => 'http://test.local/redirect' })
135
137
 
136
- expect { post(url: "http://test.local") }.to raise_error do |error|
138
+ expect { post(url: 'http://test.local') }.to raise_error do |error|
137
139
  expect(error).to be_a(StandardError)
138
140
  expect(error.http_code).to eq status
139
141
  end
140
142
  end
141
143
  end
142
144
 
143
- %i{head post}.each do |method|
145
+ %i[head post].each do |method|
144
146
  it "converts #{method.to_s.upcase} to GET on 303 redirect" do
145
- stub_request(method, "http://test.local")
146
- .to_return(status: [303, "See Other"],
147
- headers: { "Location" => "http://test.local/redirect" })
147
+ stub_request(method, 'http://test.local')
148
+ .to_return(status: [303, 'See Other'],
149
+ headers: { 'Location' => 'http://test.local/redirect' })
148
150
 
149
- expecting_request(:get, "http://test.local/redirect") do
150
- execute method, url: "http://test.local"
151
+ expecting_request(:get, 'http://test.local/redirect') do
152
+ execute method, url: 'http://test.local'
151
153
  end
152
154
  end
153
155
  end
data/spec/request_spec.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  #
3
3
  # Author:: Chef Partner Engineering (<partnereng@chef.io>)
4
- # Copyright:: Copyright (c) 2015 Chef Software, Inc.
4
+ # Copyright:: Copyright (c) 2022 Chef Software, Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,15 +17,15 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require "spec_helper"
20
+ require 'spec_helper'
21
21
 
22
- shared_examples "refresh_trigger_method" do |method|
23
- it "calls #refresh_if_needed" do
22
+ shared_examples 'refresh_trigger_method' do |method|
23
+ it 'calls #refresh_if_needed' do
24
24
  expect(request).to receive(:refresh_if_empty)
25
25
  request.send(method)
26
26
  end
27
27
 
28
- it "returns nil if request data is empty" do
28
+ it 'returns nil if request data is empty' do
29
29
  allow(request).to receive(:refresh_if_empty)
30
30
  allow(request).to receive(:request_empty?).and_return true
31
31
  expect(request.send(method)).to eq nil
@@ -34,113 +34,107 @@ end
34
34
 
35
35
  describe Vra::Request do
36
36
  let(:client) do
37
- Vra::Client.new(username: "user@corp.local",
38
- password: "password",
39
- tenant: "tenant",
40
- base_url: "https://vra.corp.local")
37
+ Vra::Client.new(
38
+ username: 'user@corp.local',
39
+ password: 'password',
40
+ tenant: 'tenant',
41
+ base_url: 'https://vra.corp.local'
42
+ )
41
43
  end
42
44
 
43
- let(:request_id) { "2c3df007-b1c4-4687-b332-310089c4851d" }
45
+ let(:deployment_id) { 'dep-123' }
46
+
47
+ let(:request_id) { 'req-123' }
48
+
49
+ let(:completed_payload) do
50
+ JSON.parse(File.read('spec/fixtures/resource/sample_dep_request.json'))
51
+ end
44
52
 
45
53
  let(:in_progress_payload) do
46
- {
47
- "phase" => "IN_PROGRESS",
48
- "requestCompletion" => {
49
- "requestCompletionState" => nil,
50
- "completionDetails" => nil,
51
- },
52
- }
54
+ JSON.parse(File.read('spec/fixtures/resource/sample_dep_request.json'))
55
+ .merge('status' => 'IN_PROGRESS')
53
56
  end
54
57
 
55
- let(:completed_payload) do
56
- {
57
- "phase" => "SUCCESSFUL",
58
- "requestCompletion" => {
59
- "requestCompletionState" => "SUCCESSFUL",
60
- "completionDetails" => "Request succeeded. Created test-machine.",
61
- },
62
- }
58
+ let(:request) { Vra::Request.new(client, deployment_id, data: in_progress_payload) }
59
+
60
+ before(:each) do
61
+ allow(client).to receive(:authorized?).and_return(true)
63
62
  end
64
63
 
65
- let(:request) { Vra::Request.new(client, request_id) }
64
+ describe '#initialize' do
65
+ it 'sets the id' do
66
+ allow(client).to receive(:get_parsed).and_return(completed_payload)
66
67
 
67
- describe "#initialize" do
68
- it "sets the id" do
69
- expect(request.id).to eq request_id
68
+ req = described_class.new(client, deployment_id, id: request_id)
69
+ expect(req.id).to eq(request_id)
70
+ end
71
+
72
+ it 'sets the attributes correctly' do
73
+ allow(client).to receive(:get_parsed).and_return(completed_payload)
74
+
75
+ req = described_class.new(client, deployment_id, id: request_id)
76
+ expect(req.status).to eq('SUCCESSFUL')
77
+ expect(req.completed?).to be_truthy
78
+ expect(req.failed?).to be_falsey
79
+ expect(req.name).to eq('Create')
80
+ expect(req.requested_by).to eq('admin')
70
81
  end
71
82
  end
72
83
 
73
- describe "#refresh" do
74
- it "calls the request API endpoint" do
84
+ describe '#refresh' do
85
+ it 'calls the request API endpoint' do
75
86
  expect(client).to receive(:get_parsed)
76
- .with("/catalog-service/api/consumer/requests/#{request_id}")
87
+ .with("/deployment/api/deployments/#{deployment_id}/requests/#{request_id}?deleted=true")
77
88
  .and_return(in_progress_payload)
78
89
 
79
90
  request.refresh
80
91
  end
81
- end
82
92
 
83
- describe "#refresh_if_empty" do
84
- context "request data is empty" do
85
- it "calls #refresh" do
86
- expect(request).to receive(:refresh)
87
- request.refresh_if_empty
88
- end
93
+ it 'should raise an exception if the resource not found' do
94
+ allow(client).to receive(:get_parsed).and_raise(Vra::Exception::HTTPNotFound)
95
+
96
+ expect { request.refresh }
97
+ .to raise_error(Vra::Exception::NotFound)
98
+ .with_message("request ID #{request_id} is not found")
89
99
  end
100
+ end
90
101
 
91
- context "request data is not empty" do
92
- it "does not call #refresh" do
102
+ describe '#refresh_if_empty' do
103
+ context 'request data is not empty' do
104
+ it 'does not call #refresh' do
93
105
  allow(request).to receive(:request_empty?).and_return(false)
94
106
  expect(request).to_not receive(:refresh)
95
107
  end
96
108
  end
97
109
  end
98
110
 
99
- describe "#status" do
100
- it_behaves_like "refresh_trigger_method", :status
111
+ describe '#status' do
112
+ it_behaves_like 'refresh_trigger_method', :status
101
113
  end
102
114
 
103
- describe "#completed?" do
104
- context "when the request is neither successful or failed yet" do
105
- it "returns false" do
115
+ describe '#completed?' do
116
+ context 'when the request is neither successful or failed yet' do
117
+ it 'returns false' do
106
118
  allow(request).to receive(:successful?).and_return(false)
107
119
  allow(request).to receive(:failed?).and_return(false)
108
120
  expect(request.completed?).to eq false
109
121
  end
110
122
  end
111
123
 
112
- context "when the request is successful" do
113
- it "returns true" do
124
+ context 'when the request is successful' do
125
+ it 'returns true' do
114
126
  allow(request).to receive(:successful?).and_return(true)
115
127
  allow(request).to receive(:failed?).and_return(false)
116
128
  expect(request.completed?).to eq true
117
129
  end
118
130
  end
119
131
 
120
- context "when the request failed" do
121
- it "returns true" do
132
+ context 'when the request failed' do
133
+ it 'returns true' do
122
134
  allow(request).to receive(:successful?).and_return(false)
123
135
  allow(request).to receive(:failed?).and_return(true)
124
136
  expect(request.completed?).to eq true
125
137
  end
126
138
  end
127
139
  end
128
-
129
- describe "#completion_state" do
130
- it_behaves_like "refresh_trigger_method", :completion_state
131
- end
132
-
133
- describe "#completion_details" do
134
- it_behaves_like "refresh_trigger_method", :completion_details
135
- end
136
-
137
- describe "#resources" do
138
- it "calls the requests resources API endpoint" do
139
- expect(client).to receive(:http_get_paginated_array!)
140
- .with("/catalog-service/api/consumer/requests/#{request_id}/resources")
141
- .and_return([])
142
-
143
- request.resources
144
- end
145
- end
146
140
  end