Sha256: 1720a394717edeaf3cd868b59b10fa650537fb7fb10fd208fab3cbe9c7898626

Contents?: true

Size: 1.43 KB

Versions: 50

Compression:

Stored size: 1.43 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.255", "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.231.0', 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

50 entries across 50 versions & 1 rubygems

Version Path
foreman_rh_cloud-8.0.48 test/unit/fact_helpers_test.rb
foreman_rh_cloud-8.0.47 test/unit/fact_helpers_test.rb
foreman_rh_cloud-8.0.46 test/unit/fact_helpers_test.rb
foreman_rh_cloud-6.0.45 test/unit/fact_helpers_test.rb
foreman_rh_cloud-5.0.46 test/unit/fact_helpers_test.rb
foreman_rh_cloud-5.0.45 test/unit/fact_helpers_test.rb
foreman_rh_cloud-7.0.46 test/unit/fact_helpers_test.rb
foreman_rh_cloud-5.0.44 test/unit/fact_helpers_test.rb
foreman_rh_cloud-7.0.45 test/unit/fact_helpers_test.rb
foreman_rh_cloud-6.0.44 test/unit/fact_helpers_test.rb
foreman_rh_cloud-5.0.43 test/unit/fact_helpers_test.rb
foreman_rh_cloud-4.0.36 test/unit/fact_helpers_test.rb
foreman_rh_cloud-3.0.33 test/unit/fact_helpers_test.rb
foreman_rh_cloud-6.0.42.2 test/unit/fact_helpers_test.rb
foreman_rh_cloud-6.0.42.1 test/unit/fact_helpers_test.rb
foreman_rh_cloud-6.0.43 test/unit/fact_helpers_test.rb
foreman_rh_cloud-5.0.42 test/unit/fact_helpers_test.rb
foreman_rh_cloud-6.0.42 test/unit/fact_helpers_test.rb
foreman_rh_cloud-5.0.41 test/unit/fact_helpers_test.rb
foreman_rh_cloud-5.0.39 test/unit/fact_helpers_test.rb