Sha256: 11c11049f6b8f6f1bd6f1ccb2095c701c39b909b07c43f1bd6530059d4f6529b

Contents?: true

Size: 1.42 KB

Versions: 52

Compression:

Stored size: 1.42 KB

Contents

require 'test_plugin_helper'

class FactHelpersTest < ActiveSupport::TestCase
  class FactsHelpersTestStub
    include ForemanInventoryUpload::Generators::FactHelpers
  end

  setup do
    @instance = FactsHelpersTestStub.new

    @org = FactoryBot.create(:organization)
  end

  test 'golden_ticket uses golden_ticket method when defined' do
    @org.expects(:golden_ticket?).returns(true)

    actual = @instance.golden_ticket?(@org)

    assert actual
  end

  test 'golden_ticket uses content_access_mode method when golden_ticket not defined' do
    @org.expects(:content_access_mode).returns('org_environment')

    actual = @instance.golden_ticket?(@org)

    assert actual
  end

  test 'obfuscates ips with insights-client data' do
    host = mock('host')
    @instance.expects(:fact_value).with(host, 'insights_client::ips').returns(
      '[{"obfuscated": "10.230.230.1", "original": "224.0.0.1"}, {"obfuscated": "10.230.230.2", "original": "224.0.0.251"}]'
    )

    actual = @instance.obfuscated_ips(host)

    assert_equal '10.230.230.1', actual['224.0.0.1']
    assert_equal '10.230.230.3', actual['224.0.0.2']
  end

  test 'obfuscates ips without insights-client data' do
    host = mock('host')
    @instance.expects(:fact_value).with(host, 'insights_client::ips').returns(nil)

    actual = @instance.obfuscated_ips(host)

    assert_equal '10.230.230.1', actual['224.0.0.1']
    assert_equal '10.230.230.2', actual['224.0.0.2']
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
foreman_rh_cloud-2.0.15 test/unit/fact_helpers_test.rb
foreman_rh_cloud-3.0.15 test/unit/fact_helpers_test.rb
foreman_rh_cloud-3.0.14 test/unit/fact_helpers_test.rb
foreman_rh_cloud-2.0.14 test/unit/fact_helpers_test.rb
foreman_rh_cloud-1.0.14 test/unit/fact_helpers_test.rb
foreman_rh_cloud-0.9.14 test/unit/fact_helpers_test.rb
foreman_rh_cloud-0.9.13.1 test/unit/fact_helpers_test.rb
foreman_rh_cloud-1.0.13.1 test/unit/fact_helpers_test.rb
foreman_rh_cloud-2.0.13.1 test/unit/fact_helpers_test.rb
foreman_rh_cloud-0.9.13 test/unit/fact_helpers_test.rb
foreman_rh_cloud-1.0.13 test/unit/fact_helpers_test.rb
foreman_rh_cloud-2.0.13 test/unit/fact_helpers_test.rb