Sha256: 1720a394717edeaf3cd868b59b10fa650537fb7fb10fd208fab3cbe9c7898626

Contents?: true

Size: 1.43 KB

Versions: 51

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

51 entries across 51 versions & 1 rubygems

Version Path
foreman_rh_cloud-5.0.39 test/unit/fact_helpers_test.rb
foreman_rh_cloud-5.0.38 test/unit/fact_helpers_test.rb
foreman_rh_cloud-4.0.35 test/unit/fact_helpers_test.rb
foreman_rh_cloud-5.0.37 test/unit/fact_helpers_test.rb
foreman_rh_cloud-5.0.36 test/unit/fact_helpers_test.rb
foreman_rh_cloud-5.0.35 test/unit/fact_helpers_test.rb
foreman_rh_cloud-5.0.34 test/unit/fact_helpers_test.rb
foreman_rh_cloud-5.0.33 test/unit/fact_helpers_test.rb
foreman_rh_cloud-3.0.32 test/unit/fact_helpers_test.rb
foreman_rh_cloud-4.0.32 test/unit/fact_helpers_test.rb
foreman_rh_cloud-5.0.32 test/unit/fact_helpers_test.rb