Sha256: d7b703ea72ddd0eb0ecd3985b07d813e09fd401373deb0b1c376a1850f87aeb2

Contents?: true

Size: 1.75 KB

Versions: 18

Compression:

Stored size: 1.75 KB

Contents

# This test verifies that setting no-custom-facts in the config file disables the
# the loading of custom facts in facter directories under the $LOAD_PATH
test_name "C100004: config file option no-custom-facts : true does not load $LOAD_PATH facter directories" do
  confine :except, :platform => 'cisco_nexus' # see BKR-749
  tag 'risk:low'

  require 'puppet/acceptance/common_utils'
  extend Puppet::Acceptance::CommandUtils

  require 'facter/acceptance/user_fact_utils'
  extend Facter::Acceptance::UserFactUtils

  content = <<EOM
Facter.add('custom_fact') do
  setcode do
    "testvalue"
  end
end
EOM

  agents.each do |agent|
    step("Agent #{agent}: determine the load path and create a custom facter directory on it and a config file") do
      ruby_path = on(agent, "#{ruby_command(agent)} -e 'puts $LOAD_PATH[0]'").stdout.chomp
      load_path_facter_dir = File.join(ruby_path, 'facter')
      on(agent, "mkdir -p \"#{load_path_facter_dir}\"")
      custom_fact = File.join(load_path_facter_dir, 'custom_fact.rb')
      create_remote_file(agent, custom_fact, content)

      config_dir = agent.tmpdir("config_dir")
      config_file = File.join(config_dir, "facter.conf")
      config_content = <<EOM
global : {
    no-custom-facts : true,
}
EOM
      create_remote_file(agent, config_file, config_content)

      teardown do
        on(agent, "rm -rf '#{load_path_facter_dir}' '#{config_dir}'")
      end

      step("Agent #{agent}: using config no-custom-facts : true should not resolve facts in facter directories on the $LOAD_PATH") do
        on(agent, facter("--config '#{config_file}' custom_fact")) do |facter_output|
          assert_equal("", facter_output.stdout.chomp, "Custom fact in $LOAD_PATH/facter should not have resolved")
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
facter-4.0.29 acceptance/tests/options/config_file/no_custom_facts_and_load_path.rb
facter-4.0.28 acceptance/tests/options/config_file/no_custom_facts_and_load_path.rb
facter-3.12.2.cfacter.20181217 ext/facter/facter/acceptance/tests/options/config_file/no_custom_facts_and_load_path.rb
facter-3.12.1.cfacter.20181031 ext/facter/facter/acceptance/tests/options/config_file/no_custom_facts_and_load_path.rb
facter-3.11.6.cfacter.20181031 ext/facter/facter/acceptance/tests/options/config_file/no_custom_facts_and_load_path.rb
facter-3.12.1.cfacter.20181023 ext/facter/facter/acceptance/tests/options/config_file/no_custom_facts_and_load_path.rb
facter-3.11.5.cfacter.20181022 ext/facter/facter/acceptance/tests/options/config_file/no_custom_facts_and_load_path.rb
facter-3.12.0.cfacter.20181004 ext/facter/facter/acceptance/tests/options/config_file/no_custom_facts_and_load_path.rb
facter-3.12.0.cfacter.20181001 ext/facter/facter/acceptance/tests/options/config_file/no_custom_facts_and_load_path.rb
facter-3.12.0.cfacter.20180918 ext/facter/facter/acceptance/tests/options/config_file/no_custom_facts_and_load_path.rb
facter-3.11.4.cfacter.20180821 ext/facter/facter/acceptance/tests/options/config_file/no_custom_facts_and_load_path.rb
facter-3.11.3.cfacter.20180716 ext/facter/facter/acceptance/tests/options/config_file/no_custom_facts_and_load_path.rb
facter-3.11.2.cfacter.20180612 ext/facter/facter/acceptance/tests/options/config_file/no_custom_facts_and_load_path.rb
facter-3.9.6.cfacter.20180612 ext/facter/facter/acceptance/tests/options/config_file/no_custom_facts_and_load_path.rb
facter-3.11.2.cfacter.20180606 ext/facter/facter/acceptance/tests/options/config_file/no_custom_facts_and_load_path.rb
facter-3.9.6.cfacter.20180606 ext/facter/facter/acceptance/tests/options/config_file/no_custom_facts_and_load_path.rb
facter-3.11.0.cfacter.20180319 ext/facter/facter/acceptance/tests/options/config_file/no_custom_facts_and_load_path.rb
cfacter-3.11.0.rc.20180314 ext/facter/facter/acceptance/tests/options/config_file/no_custom_facts_and_load_path.rb