Sha256: 3da8ca3463f9115e36b6e60c8d31510e2620bf0c7adbed9a83cd8f864385e96a

Contents?: true

Size: 1.95 KB

Versions: 18

Compression:

Stored size: 1.95 KB

Contents

# This test verifies that when a fact group is blocked in the config file the
# corresponding facts do not resolve when being run from the puppet facts command.
test_name "C100036: when run from puppet facts, facts can be blocked via a list in the config file" do
  tag 'risk:medium'

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

  agents.each do |agent|
    step "facts should be blocked when Facter is run from Puppet with a configured blocklist" do
      # default facter.conf
      facter_conf_default_dir = get_default_fact_dir(agent['platform'], on(agent, facter('kernelmajversion')).stdout.chomp.to_f)
      facter_conf_default_path = File.join(facter_conf_default_dir, "facter.conf")

      teardown do
        on(agent, "rm -rf '#{facter_conf_default_dir}'", :acceptable_exit_codes => [0, 1])
      end

      step "Agent #{agent}: create default config file" do
        # create the directories
        on(agent, "mkdir -p '#{facter_conf_default_dir}'")
        create_remote_file(agent, facter_conf_default_path, <<-FILE)
        facts : { blocklist : [ "file system", "EC2" ] }
        FILE
      end

      step "blocked facts should not be resolved" do
        on(agent, puppet("facts --debug")) do |puppet_facts_output|
          # every platform attempts to resolve at least EC2 facts
          assert_match(/blocking collection of .+ facts/, puppet_facts_output.stdout, "Expected stderr to contain statement about blocking fact collection")

          # on some platforms, file system facts are never resolved, so this will also be true in those cases
          assert_no_match(/filesystems/, puppet_facts_output.stdout, "filesystems fact should have been blocked")
          assert_no_match(/mountpoints/, puppet_facts_output.stdout, "mountpoints fact should have been blocked")
          assert_no_match(/partitions/, puppet_facts_output.stdout, "partitions fact should have been blocked")
        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/blocklist_from_puppet_facts.rb
facter-4.0.28 acceptance/tests/options/config_file/blocklist_from_puppet_facts.rb
facter-3.12.2.cfacter.20181217 ext/facter/facter/acceptance/tests/options/config_file/blocklist_from_puppet_facts.rb
facter-3.12.1.cfacter.20181031 ext/facter/facter/acceptance/tests/options/config_file/blocklist_from_puppet_facts.rb
facter-3.11.6.cfacter.20181031 ext/facter/facter/acceptance/tests/options/config_file/blocklist_from_puppet_facts.rb
facter-3.12.1.cfacter.20181023 ext/facter/facter/acceptance/tests/options/config_file/blocklist_from_puppet_facts.rb
facter-3.11.5.cfacter.20181022 ext/facter/facter/acceptance/tests/options/config_file/blocklist_from_puppet_facts.rb
facter-3.12.0.cfacter.20181004 ext/facter/facter/acceptance/tests/options/config_file/blocklist_from_puppet_facts.rb
facter-3.12.0.cfacter.20181001 ext/facter/facter/acceptance/tests/options/config_file/blocklist_from_puppet_facts.rb
facter-3.12.0.cfacter.20180918 ext/facter/facter/acceptance/tests/options/config_file/blocklist_from_puppet_facts.rb
facter-3.11.4.cfacter.20180821 ext/facter/facter/acceptance/tests/options/config_file/blocklist_from_puppet_facts.rb
facter-3.11.3.cfacter.20180716 ext/facter/facter/acceptance/tests/options/config_file/blocklist_from_puppet_facts.rb
facter-3.11.2.cfacter.20180612 ext/facter/facter/acceptance/tests/options/config_file/blocklist_from_puppet_facts.rb
facter-3.9.6.cfacter.20180612 ext/facter/facter/acceptance/tests/options/config_file/blocklist_from_puppet_facts.rb
facter-3.11.2.cfacter.20180606 ext/facter/facter/acceptance/tests/options/config_file/blocklist_from_puppet_facts.rb
facter-3.9.6.cfacter.20180606 ext/facter/facter/acceptance/tests/options/config_file/blocklist_from_puppet_facts.rb
facter-3.11.0.cfacter.20180319 ext/facter/facter/acceptance/tests/options/config_file/blocklist_from_puppet_facts.rb
cfacter-3.11.0.rc.20180314 ext/facter/facter/acceptance/tests/options/config_file/blocklist_from_puppet_facts.rb