|
71 | 71 | end
|
72 | 72 |
|
73 | 73 | 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') } |
75 | 75 |
|
76 | 76 | before do
|
77 | 77 | stub_request(:post, scc_activate_url)
|
|
80 | 80 | body: { error: 'Unexpected instance verification error has occurred' }.to_json,
|
81 | 81 | headers: {}
|
82 | 82 | )
|
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) |
85 | 86 | post url, params: payload, headers: headers
|
86 | 87 | end
|
87 | 88 |
|
|
145 | 146 | context 'when verification provider returns false' do
|
146 | 147 | before do
|
147 | 148 | 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) |
149 | 150 | expect(plugin_double).to receive(:instance_valid?).and_return(false)
|
| 151 | + allow(plugin_double).to receive(:allowed_extension?).and_return(true) |
150 | 152 | post url, params: payload, headers: headers
|
151 | 153 | end
|
152 | 154 |
|
|
159 | 161 | context 'when verification provider raises an unhandled exception' do
|
160 | 162 | before do
|
161 | 163 | 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) |
163 | 165 | expect(plugin_double).to receive(:instance_valid?).and_raise('Custom plugin error')
|
| 166 | + allow(plugin_double).to receive(:allowed_extension?).and_return(true) |
164 | 167 | post url, params: payload, headers: headers
|
165 | 168 | end
|
166 | 169 |
|
|
175 | 178 |
|
176 | 179 | before do
|
177 | 180 | 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) |
179 | 182 | 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) |
181 | 184 | post url, params: payload, headers: headers
|
182 | 185 | end
|
183 | 186 |
|
|
231 | 234 | end
|
232 | 235 |
|
233 | 236 | 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) |
236 | 238 | allow(plugin_double).to receive(:parse_instance_data).and_return({ InstanceId: 'foo' })
|
| 239 | + allow(plugin_double).to receive(:allowed_extension?).and_return(true) |
237 | 240 |
|
238 | 241 | FactoryBot.create(:subscription, product_classes: product_classes)
|
239 | 242 | stub_request(:post, scc_activate_url)
|
|
403 | 406 | .to_return(status: 201, body: scc_response_body, headers: {})
|
404 | 407 |
|
405 | 408 | 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) |
407 | 410 | post url, params: payload_no_token, headers: headers
|
408 | 411 | end
|
409 | 412 |
|
|
415 | 418 | end
|
416 | 419 |
|
417 | 420 | 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 | + |
418 | 425 | context "when system doesn't have hw_info" do
|
419 | 426 | let(:system) { FactoryBot.create(:system, :hybrid) }
|
420 | 427 |
|
|
449 | 456 | before do
|
450 | 457 | expect(InstanceVerification::Providers::Example).to receive(:new)
|
451 | 458 | .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) |
452 | 460 | expect(plugin_double).to receive(:instance_valid?).and_return(false)
|
453 | 461 | post url, params: payload, headers: headers
|
454 | 462 | end
|
|
463 | 471 | before do
|
464 | 472 | expect(InstanceVerification::Providers::Example).to receive(:new)
|
465 | 473 | .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) |
466 | 475 | expect(plugin_double).to receive(:instance_valid?).and_raise('Custom plugin error')
|
467 | 476 | post url, params: payload, headers: headers
|
468 | 477 | end
|
|
0 commit comments