Sha256: dff3deac4e9e82eb87ff3c69e70010652e0a9ae5127f1cb10b79a54a64b26442

Contents?: true

Size: 1.8 KB

Versions: 18

Compression:

Stored size: 1.8 KB

Contents

test_name 'C100202: Facter identity facts resolve on all platforms' do
  tag 'risk:high'

  require 'json'

  agents.each do |agent|
    step 'Ensure the identity fact resolves as expected' do
      if agent['platform'] =~ /windows/
        # Regular expression to validate the username from facter in the form of '<domain>\<username>'
        # Reference - https://msdn.microsoft.com/en-us/library/bb726984.aspx
        # - The domain name can be any character or empty
        # - Must contain a backslash between the domain and username
        # - Username must be at least one character and not contain the following charaters; " / \ [ ] : ; | = , + * ? < >
        expected_identity = {
            'user'       => /.*\\[^\\\/\"\[\]:|<>+=;,?*@]+$/,
            'privileged' => 'true'
        }
      elsif agent['platform'] =~ /aix-/
        expected_identity = {
            'gid'        => '0',
            'group'      => 'system',
            'uid'        => '0',
            'user'       => 'root',
            'privileged' => 'true'
        }
      elsif agent['platform'] =~ /osx-/
        expected_identity = {
            'gid'        => '0',
            'group'      => 'wheel',
            'uid'        => '0',
            'user'       => 'root',
            'privileged' => 'true'
        }
      else
        expected_identity = {
            'gid'        => '0',
            'group'      => 'root',
            'uid'        => '0',
            'user'       => 'root',
            'privileged' => 'true'
        }
      end

      on(agent, facter('--json')) do |facter_result|
        results = JSON.parse(facter_result.stdout)
        expected_identity.each do |fact, value|
          assert_match(value, results['identity'][fact].to_s, "Incorrect fact value for identity.#{fact}")
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

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