Skip to content

Commit a3c8ad7

Browse files
committed
Fix CI test
1 parent f544bb0 commit a3c8ad7

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

engines/instance_verification/spec/requests/api/connect/v3/systems/products_controller_spec.rb

+19-10
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
end
7272

7373
context 'when verification provider returns false' do
74-
# let(:plugin_double) { instance_double('InstanceVerification::Providers::Example') }
74+
let(:plugin_double) { instance_double('InstanceVerification::Providers::Example') }
7575

7676
before do
7777
stub_request(:post, scc_activate_url)
@@ -80,8 +80,9 @@
8080
body: { error: 'Unexpected instance verification error has occurred' }.to_json,
8181
headers: {}
8282
)
83-
# allow(InstanceVerification::Providers::Example).to receive(:new).and_return(plugin_double)
84-
# allow(plugin_double).to receive(:allowed_extension?).and_return(true)
83+
allow(InstanceVerification::Providers::Example).to receive(:new).and_return(plugin_double)
84+
allow(plugin_double).to receive(:allowed_extension?).and_return(true)
85+
allow(plugin_double).to receive(:instance_valid?).and_return(false)
8586
post url, params: payload, headers: headers
8687
end
8788

@@ -145,8 +146,9 @@
145146
context 'when verification provider returns false' do
146147
before do
147148
expect(InstanceVerification::Providers::Example).to receive(:new)
148-
.with(be_a(ActiveSupport::Logger), be_a(ActionDispatch::Request), payload, instance_data).and_return(plugin_double)
149+
.with(be_a(ActiveSupport::Logger), be_a(ActionDispatch::Request), payload, instance_data).and_return(plugin_double).at_least(:once)
149150
expect(plugin_double).to receive(:instance_valid?).and_return(false)
151+
allow(plugin_double).to receive(:allowed_extension?).and_return(true)
150152
post url, params: payload, headers: headers
151153
end
152154

@@ -159,8 +161,9 @@
159161
context 'when verification provider raises an unhandled exception' do
160162
before do
161163
expect(InstanceVerification::Providers::Example).to receive(:new)
162-
.with(be_a(ActiveSupport::Logger), be_a(ActionDispatch::Request), payload, instance_data).and_return(plugin_double)
164+
.with(be_a(ActiveSupport::Logger), be_a(ActionDispatch::Request), payload, instance_data).and_return(plugin_double).at_least(:once)
163165
expect(plugin_double).to receive(:instance_valid?).and_raise('Custom plugin error')
166+
allow(plugin_double).to receive(:allowed_extension?).and_return(true)
164167
post url, params: payload, headers: headers
165168
end
166169

@@ -175,9 +178,9 @@
175178

176179
before do
177180
expect(InstanceVerification::Providers::Example).to receive(:new)
178-
.with(be_a(ActiveSupport::Logger), be_a(ActionDispatch::Request), payload, instance_data).and_return(plugin_double)
181+
.with(be_a(ActiveSupport::Logger), be_a(ActionDispatch::Request), payload, instance_data).and_return(plugin_double).at_least(:once)
179182
expect(plugin_double).to receive(:instance_valid?).and_raise(InstanceVerification::Exception, 'Custom plugin error')
180-
183+
allow(plugin_double).to receive(:allowed_extension?).and_return(true)
181184
post url, params: payload, headers: headers
182185
end
183186

@@ -231,9 +234,9 @@
231234
end
232235

233236
before do
234-
allow(InstanceVerification::Providers::Example).to receive(:new)
235-
.with(nil, nil, nil, instance_data).and_return(plugin_double)
237+
allow(InstanceVerification::Providers::Example).to receive(:new).and_return(plugin_double)
236238
allow(plugin_double).to receive(:parse_instance_data).and_return({ InstanceId: 'foo' })
239+
allow(plugin_double).to receive(:allowed_extension?).and_return(true)
237240

238241
FactoryBot.create(:subscription, product_classes: product_classes)
239242
stub_request(:post, scc_activate_url)
@@ -403,7 +406,7 @@
403406
.to_return(status: 201, body: scc_response_body, headers: {})
404407

405408
expect(InstanceVerification).not_to receive(:update_cache).with('127.0.0.1', system.login, product.id)
406-
409+
allow(plugin_double).to receive(:allowed_extension?).and_return(true)
407410
post url, params: payload_no_token, headers: headers
408411
end
409412

@@ -415,6 +418,10 @@
415418
end
416419

417420
context 'when the system is hybrid' do
421+
before do
422+
allow_any_instance_of(InstanceVerification::Providers::Example).to receive(:allowed_extension?).and_return(true)
423+
end
424+
418425
context "when system doesn't have hw_info" do
419426
let(:system) { FactoryBot.create(:system, :hybrid) }
420427

@@ -449,6 +456,7 @@
449456
before do
450457
expect(InstanceVerification::Providers::Example).to receive(:new)
451458
.with(be_a(ActiveSupport::Logger), be_a(ActionDispatch::Request), payload, instance_data).and_return(plugin_double)
459+
allow(plugin_double).to receive(:allowed_extension?).and_return(true)
452460
expect(plugin_double).to receive(:instance_valid?).and_return(false)
453461
post url, params: payload, headers: headers
454462
end
@@ -463,6 +471,7 @@
463471
before do
464472
expect(InstanceVerification::Providers::Example).to receive(:new)
465473
.with(be_a(ActiveSupport::Logger), be_a(ActionDispatch::Request), payload, instance_data).and_return(plugin_double)
474+
allow(plugin_double).to receive(:allowed_extension?).and_return(true)
466475
expect(plugin_double).to receive(:instance_valid?).and_raise('Custom plugin error')
467476
post url, params: payload, headers: headers
468477
end

0 commit comments

Comments
 (0)