Sha256: 4ae6b1b1467dd30319cdeb82f431b18557e3afbfa026bb3082a865c1ba4534be

Contents?: true

Size: 1.81 KB

Versions: 35

Compression:

Stored size: 1.81 KB

Contents

#!/usr/bin/env ruby

require File.expand_path(File.dirname(__FILE__) + '/../lib/puppettest')

require 'puppettest'

require 'puppet/network/authconfig'

class TestAuthConfig < Test::Unit::TestCase
  include PuppetTest

  def request(call, client, ip)
    r = Puppet::Network::ClientRequest.new(client, ip, false)
    h, m = call.split(".")
    r.handler = h
    r.method = m
    r
  end

  def test_parsingconfigfile
    file = tempfile
    assert(Puppet[:authconfig], "No config path")

    Puppet[:authconfig] = file

    File.open(file, "w") { |f|
      f.puts "[pelementserver.describe]
  allow *.madstop.com
  deny 10.10.1.1

[fileserver]
  allow *.madstop.com
  deny 10.10.1.1

[fileserver.list]
  allow 10.10.1.1
"
    }

    config = nil
    assert_nothing_raised {
      config = Puppet::Network::AuthConfig.new(file)
    }

    assert_nothing_raised {
      assert(config.allowed?(request("pelementserver.describe", "culain.madstop.com", "1.1.1.1")), "Did not allow host")
      assert(! config.allowed?(request("pelementserver.describe", "culain.madstop.com", "10.10.1.1")), "Allowed host")
      assert(config.allowed?(request("fileserver.yay", "culain.madstop.com", "10.1.1.1")), "Did not allow host to fs")
      assert(! config.allowed?(request("fileserver.yay", "culain.madstop.com", "10.10.1.1")), "Allowed host to fs")
      assert(config.allowed?(request("fileserver.list", "culain.madstop.com", "10.10.1.1")), "Did not allow host to fs.list")
    }
  end

  def test_singleton
    auth = nil
    assert_nothing_raised { auth = Puppet::Network::AuthConfig.main }
    assert(auth, "did not get main authconfig")

    other = nil
    assert_nothing_raised { other = Puppet::Network::AuthConfig.main }

          assert_equal(
        auth.object_id, other.object_id,
        
      "did not get same authconfig from class")
  end
end


Version data entries

35 entries across 35 versions & 3 rubygems

Version Path
puppet-2.7.26 test/network/authconfig.rb
puppet-2.7.25 test/network/authconfig.rb
puppet-2.7.24 test/network/authconfig.rb
puppet-2.7.23 test/network/authconfig.rb
puppet-2.7.22 test/network/authconfig.rb
puppet-2.7.21 test/network/authconfig.rb
puppet-2.7.20 test/network/authconfig.rb
puppet-2.7.20.rc1 test/network/authconfig.rb
librarian-puppet-0.9.4 vendor/gems/ruby/1.8/gems/puppet-2.7.18/test/network/authconfig.rb
puppet-2.7.19 test/network/authconfig.rb
supply_drop-0.11.0 examples/vendored-puppet/vendor/puppet-2.7.8/test/network/authconfig.rb
librarian-puppet-0.9.3 vendor/gems/ruby/1.8/gems/puppet-2.7.18/test/network/authconfig.rb
supply_drop-0.10.2 examples/vendored-puppet/vendor/puppet-2.7.8/test/network/authconfig.rb
puppet-2.7.18 test/network/authconfig.rb
supply_drop-0.10.1 examples/vendored-puppet/vendor/puppet-2.7.8/test/network/authconfig.rb
supply_drop-0.10.0 examples/vendored-puppet/vendor/puppet-2.7.8/test/network/authconfig.rb
puppet-2.7.17 test/network/authconfig.rb
puppet-2.7.16 test/network/authconfig.rb
puppet-2.7.14 test/network/authconfig.rb
puppet-2.7.13 test/network/authconfig.rb