summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorLuke Kanies <luke@puppetlabs.com>2010-04-12 10:12:57 -0700
committerLuke Kanies <luke@puppetlabs.com>2010-04-12 10:12:57 -0700
commit797f4122c525c2ff30912a49e1c6887d997054de (patch)
treec34845bf2198f286581b5c5755294884253a4158 /spec
parent622bb70c20aaa79523ce8715d45ac103a270f8d7 (diff)
downloadpuppet-797f4122c525c2ff30912a49e1c6887d997054de.tar.gz
puppet-797f4122c525c2ff30912a49e1c6887d997054de.tar.xz
puppet-797f4122c525c2ff30912a49e1c6887d997054de.zip
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@puppetlabs.com>
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/provider/ssh_authorized_key/parsed.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/spec/unit/provider/ssh_authorized_key/parsed.rb b/spec/unit/provider/ssh_authorized_key/parsed.rb
index 9abcda54f..584ac7c88 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@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