Sha256: 03121d99883684fe97a5dede824ba8e50b6b2a4e1eaa958c0c91d64d7fe2c690

Contents?: true

Size: 1.68 KB

Versions: 10

Compression:

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

    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

10 entries across 10 versions & 1 rubygems

Version Path
foreman_rh_cloud-4.0.31 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-5.0.31 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-5.0.30 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-4.0.30 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-4.0.29 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-5.0.29 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-5.0.28 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-4.0.27 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-4.0.26 test/controllers/inventory_upload/cloud_status_controller_test.rb
foreman_rh_cloud-4.0.25.1 test/controllers/inventory_upload/cloud_status_controller_test.rb