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-9.0.59 test/unit/fact_helpers_test.rb
foreman_rh_cloud-11.0.2 test/unit/fact_helpers_test.rb
foreman_rh_cloud-11.0.1 test/unit/fact_helpers_test.rb
foreman_rh_cloud-11.0.0 test/unit/fact_helpers_test.rb
foreman_rh_cloud-9.0.58 test/unit/fact_helpers_test.rb
foreman_rh_cloud-10.0.2 test/unit/fact_helpers_test.rb
foreman_rh_cloud-9.0.57 test/unit/fact_helpers_test.rb
foreman_rh_cloud-10.0.1 test/unit/fact_helpers_test.rb
foreman_rh_cloud-9.0.56 test/unit/fact_helpers_test.rb
foreman_rh_cloud-9.0.55 test/unit/fact_helpers_test.rb
foreman_rh_cloud-9.0.54 test/unit/fact_helpers_test.rb
foreman_rh_cloud-9.0.53 test/unit/fact_helpers_test.rb
foreman_rh_cloud-9.0.52 test/unit/fact_helpers_test.rb
foreman_rh_cloud-8.0.52 test/unit/fact_helpers_test.rb
foreman_rh_cloud-9.0.51 test/unit/fact_helpers_test.rb
foreman_rh_cloud-8.0.51 test/unit/fact_helpers_test.rb
foreman_rh_cloud-7.0.48 test/unit/fact_helpers_test.rb
foreman_rh_cloud-7.0.47 test/unit/fact_helpers_test.rb
foreman_rh_cloud-8.0.50 test/unit/fact_helpers_test.rb
foreman_rh_cloud-8.0.49 test/unit/fact_helpers_test.rb