From 7fe18e3ffba0d8f206b0e7aef2dd6684a98802b6 Mon Sep 17 00:00:00 2001 From: Rick Bradley Date: Tue, 2 Oct 2007 14:41:11 -0500 Subject: Fixed a test which was secretly sneaking off and pulling certs from ~ if they were there: Added set_mygroup method, removed duplicate setme method. Included PuppetTest in the XMLRPC servlect test. --- test/lib/puppettest/support/utils.rb | 24 +++++++++++------------- test/network/xmlrpc/webrick_servlet.rb | 7 +++++++ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/test/lib/puppettest/support/utils.rb b/test/lib/puppettest/support/utils.rb index 7f4260e31..b5189202f 100644 --- a/test/lib/puppettest/support/utils.rb +++ b/test/lib/puppettest/support/utils.rb @@ -50,6 +50,7 @@ module PuppetTest # TODO: rewrite this to use the 'etc' module. + # Define a variable that contains the name of my user. def setme # retrieve the user name id = %x{id}.chomp @@ -63,6 +64,16 @@ module PuppetTest end end + # Define a variable that contains a group I'm in. + def set_mygroup + # retrieve the user name + group = %x{groups}.chomp.split(/ /)[0] + unless group + raise "Could not find group to set in @mygroup" + end + @mygroup = group + end + def run_events(type, trans, events, msg) case type when :evaluate, :rollback: # things are hunky-dory @@ -158,19 +169,6 @@ module PuppetTest return config end - - def setme - # retrieve the user name - id = %x{id}.chomp - if id =~ /uid=\d+\(([^\)]+)\)/ - @me = $1 - else - puts id - end - unless defined? @me - raise "Could not retrieve user name; 'id' did not work" - end - end end # $Id$ diff --git a/test/network/xmlrpc/webrick_servlet.rb b/test/network/xmlrpc/webrick_servlet.rb index ce31d9dbe..e7a6af171 100755 --- a/test/network/xmlrpc/webrick_servlet.rb +++ b/test/network/xmlrpc/webrick_servlet.rb @@ -3,11 +3,18 @@ $:.unshift("../../lib") if __FILE__ =~ /\.rb$/ require 'puppettest' +require 'puppettest/support/utils' require 'puppet/network/xmlrpc/webrick_servlet' require 'mocha' class TestXMLRPCWEBrickServlet < Test::Unit::TestCase + include PuppetTest def test_basics + # Make sure we're doing things as our user info, rather than puppet/puppet + setme + set_mygroup + Puppet[:user] = @me + Puppet[:group] = @mygroup servlet = nil ca = Puppet::Network::Handler.ca.new -- cgit From 1174d99acb5505b8de577b7f71cee0d32a4cf05f Mon Sep 17 00:00:00 2001 From: Rick Bradley Date: Tue, 2 Oct 2007 14:49:38 -0500 Subject: Fixed a failing test where we presumed that non-string Fact values would have type preserved across a P::N::Client.master.facts call, which is not true. --- test/network/client/master.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/network/client/master.rb b/test/network/client/master.rb index 169a1de5f..0a3b75b91 100755 --- a/test/network/client/master.rb +++ b/test/network/client/master.rb @@ -379,7 +379,7 @@ end facts = Puppet::Network::Client.master.facts end Facter.to_hash.each do |fact, value| - assert_equal(facts[fact.downcase], value, "%s is not equal" % fact.inspect) + assert_equal(facts[fact.downcase], value.to_s, "%s is not equal" % fact.inspect) end # Make sure the puppet version got added -- cgit