Sha256: 9a800451ca2a5a5949f3423c148582d088572a12c92dd9d2f3079a028858381f

Contents?: true

Size: 1010 Bytes

Versions: 18

Compression:

Stored size: 1010 Bytes

Contents

test_name 'C92060: Custom facts should not hang Facter when using win32ole' do
  tag 'risk:high'

  confine :to, :platform => /windows/
  require 'timeout'

  content = <<-EOM
    Facter.add('custom_fact') do
      setcode do
        require 'win32ole'
        locator = WIN32OLE.new('WbemScripting.SWbemLocator')
        locator.ConnectServer('', "root/CIMV2", '', '', nil, nil, nil, nil).to_s
      end
    end
  EOM

  agents.each do |agent|
    custom_dir  = agent.tmpdir('arbitrary_dir')
    custom_fact = File.join(custom_dir, 'custom_fact.rb')
    create_remote_file(agent, custom_fact, content)

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

    # Test is assumed to have hung if it takes longer than 5 seconds.
    Timeout::timeout(5) do
      on agent, facter('--custom-dir', custom_dir, 'custom_fact') do |facter_result|
        assert_match(/#<WIN32OLE:0x[0-9a-f]+>/, facter_result.stdout.chomp, 'Custom fact output does not match expected output')
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

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