|
562 | 562 | expect(response.body).to eq(serialized_service_json) |
563 | 563 | end |
564 | 564 | end |
| 565 | + |
| 566 | + context 'when the extension is Live-Patching for SLES' do |
| 567 | + let(:payload_no_token) do |
| 568 | + { |
| 569 | + identifier: product.identifier, |
| 570 | + version: product.version, |
| 571 | + arch: product.arch, |
| 572 | + instance_data: 'dummy_instance_data', |
| 573 | + proxy_byos_mode: system.proxy_byos_mode, |
| 574 | + hwinfo: |
| 575 | + { |
| 576 | + hostname: 'test', |
| 577 | + cpus: '1', |
| 578 | + sockets: '1', |
| 579 | + hypervisor: 'Xen', |
| 580 | + arch: 'x86_64', |
| 581 | + uuid: 'ec235f7d-b435-e27d-86c6-c8fef3180a01', |
| 582 | + cloud_provider: 'amazon' |
| 583 | + } |
| 584 | + } |
| 585 | + end |
| 586 | + |
| 587 | + let(:base_product) { FactoryBot.create(:product, :product_sles, :with_mirrored_repositories) } |
| 588 | + let(:product) do |
| 589 | + FactoryBot.create( |
| 590 | + :product, :product_live_patch, :with_mirrored_repositories, base_products: [base_product] |
| 591 | + ) |
| 592 | + end |
| 593 | + let(:product_classes) { [base_product.product_class] } |
| 594 | + let(:fake_subscription) { instance_double(Subscription, id: 1, products: [base_product]) } |
| 595 | + let(:fake_subscription_prod_class) { FactoryBot.create(:subscription_product_class) } |
| 596 | + |
| 597 | + before do |
| 598 | + allow(InstanceVerification::Providers::Example).to receive(:new).and_return(plugin_double) |
| 599 | + allow(plugin_double).to receive(:instance_identifier).and_return('foo') |
| 600 | + allow(plugin_double).to receive(:parse_instance_data).and_return({ InstanceId: 'foo' }) |
| 601 | + allow(plugin_double).to receive(:allowed_extension?).and_return(true) |
| 602 | + allow(plugin_double).to receive(:add_on).and_return(nil) |
| 603 | + allow_any_instance_of(described_class).to receive(:find_subscription).and_return(fake_subscription) |
| 604 | + allow(fake_subscription).to receive(:product_classes).and_return([{ product_class: 'foo' }]) |
| 605 | + # stub the fake announcement call PAYG has to do to SCC |
| 606 | + # to create the system before activate product (and skip validation) |
| 607 | + stub_request(:post, 'https://scc.suse.com/connect/subscriptions/systems') |
| 608 | + .to_return(status: 201, body: scc_response_body, headers: {}) |
| 609 | + |
| 610 | + headers['X-Instance-Data'] = Base64.strict_encode64(instance_data) |
| 611 | + post url, params: payload_no_token, headers: headers |
| 612 | + end |
| 613 | + |
| 614 | + it 'allow the extension' do |
| 615 | + expect(response.body).to eq(serialized_service_json) |
| 616 | + data = JSON.parse(response.body) |
| 617 | + expect(data['name']).to include('Live_Patch') |
| 618 | + expect(data['product']['product_class']).to eq('SLE-LP') |
| 619 | + end |
| 620 | + end |
565 | 621 | end |
566 | 622 | end |
567 | 623 |
|
|
0 commit comments