Sha256: 02155fd31bc85bc5434172915fcb5529e0e3c24acd9580726eb3167c3634ab6d

Contents?: true

Size: 1.53 KB

Versions: 41

Compression:

Stored size: 1.53 KB

Contents

require 'test_plugin_helper'

class CloudStatusControllerTest < ActionController::TestCase
  include MockCerts
  tests ForemanInventoryUpload::CloudStatusController

  test 'return ping status hash for each organization' do
    organizations = FactoryBot.create_list(:organization, 2)
    user = users(:admin)
    User.stubs(:current).returns(user)
    user.stubs(:my_organizations).returns(organizations)

    setup_certs_expectation do
      ForemanRhCloud::CloudPingService::CertPing.any_instance.expects(:candlepin_id_cert).with { |actual| actual.id == organizations[0].id }
    end
    ForemanRhCloud::CloudPingService::CertPing.any_instance.expects(:execute_cloud_request).returns(
      RestClient::Response.new('TEST RESPONSE ORG 0')
    )

    setup_certs_expectation do
      ForemanRhCloud::CloudPingService::CertPing.any_instance.expects(:candlepin_id_cert).with { |actual| actual.id == organizations[1].id }
    end

    ForemanRhCloud::CloudPingService::CertPing.any_instance.expects(:execute_cloud_request).returns(
      RestClient::Response.new('TEST RESPONSE ORG 1')
    )

    Katello::UpstreamConnectionChecker.any_instance.expects(:assert_connection).twice.returns(true)

    get :index, session: set_session_user

    assert_response :success
    actual = JSON.parse(response.body)
    assert_not_nil (actual_ping = actual['ping'])
    assert actual_ping['cert_auth'][0]['success']
    assert_nil actual_ping['cert_auth'][0]['error']
    assert actual_ping['cert_auth'][1]['success']
    assert_nil actual_ping['cert_auth'][1]['error']
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
foreman_rh_cloud-9.0.59 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-11.0.2 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-11.0.1 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-11.0.0 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-9.0.58 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-10.0.2 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-9.0.57 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-10.0.1 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-9.0.56 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-9.0.55 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-9.0.54 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-9.0.53 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-9.0.52 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-8.0.52 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-9.0.51 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-8.0.51 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-7.0.48 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-7.0.47 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-8.0.50 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-8.0.49 test/controllers/inventory_upload/cloud_status_controller_test.rb