Sha256: 2467a479c3e68d9ab90312f7f46921b8e0eb40c1b4d201ea0cf2927cc3d54793

Contents?: true

Size: 1.78 KB

Versions: 7

Compression:

Stored size: 1.78 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)

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

    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['token_auth']['success']
    assert_nil actual_ping['token_auth']['error']
    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

7 entries across 7 versions & 1 rubygems

Version Path
foreman_rh_cloud-4.0.36 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-4.0.35 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-5.0.35 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-5.0.34 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-5.0.33 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-4.0.32 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-5.0.32 test/controllers/inventory_upload/cloud_status_controller_test.rb