[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35
Luke Kanies
luke at puppetlabs.com
Wed Jul 14 10:32:22 UTC 2010
The following commit has been merged in the upstream branch:
commit 797f4122c525c2ff30912a49e1c6887d997054de
Author: Luke Kanies <luke at puppetlabs.com>
Date: Mon Apr 12 10:12:57 2010 -0700
Making SshAuthorizedKeys tests less brittle
Also making them less likely to try to modify
the local filesystem in any way.
Signed-off-by: Luke Kanies <luke at puppetlabs.com>
diff --git a/lib/puppet/provider/ssh_authorized_key/parsed.rb b/lib/puppet/provider/ssh_authorized_key/parsed.rb
index b435c51..6265c6b 100644
--- a/lib/puppet/provider/ssh_authorized_key/parsed.rb
+++ b/lib/puppet/provider/ssh_authorized_key/parsed.rb
@@ -89,7 +89,7 @@ Puppet::Type.type(:ssh_authorized_key).provide(:parsed,
end
end
- if target
+ if target and FileTest.exist?(target)
File.chmod(file_perm, target)
end
end
diff --git a/spec/unit/provider/ssh_authorized_key/parsed.rb b/spec/unit/provider/ssh_authorized_key/parsed.rb
index 9abcda5..584ac7c 100755
--- a/spec/unit/provider/ssh_authorized_key/parsed.rb
+++ b/spec/unit/provider/ssh_authorized_key/parsed.rb
@@ -2,6 +2,7 @@
require File.dirname(__FILE__) + '/../../../spec_helper'
+require 'puppet_spec/files'
require 'puppettest'
require 'puppettest/support/utils'
require 'puppettest/fileparsing'
@@ -9,12 +10,18 @@ require 'puppettest/fileparsing'
provider_class = Puppet::Type.type(:ssh_authorized_key).provider(:parsed)
describe provider_class do
+ include PuppetSpec::Files
include PuppetTest
include PuppetTest::FileParsing
before :each do
@sshauthkey_class = Puppet::Type.type(:ssh_authorized_key)
@provider = @sshauthkey_class.provider(:parsed)
+
+ @keyfile = tmpfile("ssh_key")
+ #@provider.stubs(:default_target).returns @keyfile
+ #@provider.stubs(:flush)
+ @provider.any_instance.stubs(:target).returns @keyfile
end
after :each do
@@ -43,7 +50,6 @@ describe provider_class do
PuppetTest.fakedata("data/providers/ssh_authorized_key/parsed").each { |file|
it "should be able to parse example data in #{file}" do
- puts "Parsing %s" % file
fakedataparse(file)
end
}
@@ -72,7 +78,7 @@ describe provider_class do
genkey(key).should == "from=\"192.168.1.1\",no-pty,no-X11-forwarding ssh-rsa AAAAfsfddsjldjgksdflgkjsfdlgkj root at localhost\n"
end
- it "'s parse_options method should be able to parse options containing commas" do
+ it "should be able to parse options containing commas via its parse_options method" do
options = %w{from="host1.reductlivelabs.com,host.reductivelabs.com" command="/usr/local/bin/run" ssh-pty}
optionstr = options.join(", ")
@@ -130,6 +136,7 @@ describe provider_class do
end
it "should chmod the key file to 0600" do
+ FileTest.expects(:exist?).with("/tmp/.ssh_dir/place_to_put_authorized_keys").returns true
File.expects(:chmod).with(0600, "/tmp/.ssh_dir/place_to_put_authorized_keys")
@provider.flush
end
@@ -168,6 +175,7 @@ describe provider_class do
end
it "should chmod the key file to 0600" do
+ FileTest.expects(:exist?).with(File.expand_path("~nobody/.ssh/authorized_keys")).returns true
File.expects(:chmod).with(0600, File.expand_path("~nobody/.ssh/authorized_keys"))
@provider.flush
end
@@ -186,6 +194,7 @@ describe provider_class do
end
it "should chmod the key file to 0644" do
+ FileTest.expects(:exist?).with("/tmp/.ssh_dir/place_to_put_authorized_keys").returns true
File.expects(:chmod).with(0644, "/tmp/.ssh_dir/place_to_put_authorized_keys")
@provider.flush
end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list