summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2008-07-03 13:41:11 +1000
committerJames Turnbull <james@lovedthanlost.net>2008-07-03 13:41:11 +1000
commitd851a16a3af9dd24f675ad5fcf6dfeba6d6273a2 (patch)
tree1763a30c9a9a7e161ce3967d493d69ea7b2854a9 /spec
parentda912fce870745e9e1bc600ae6c9c91cbbd60283 (diff)
parent5156230b434adbe6de6606f6bcd8843264b8dab4 (diff)
downloadpuppet-d851a16a3af9dd24f675ad5fcf6dfeba6d6273a2.tar.gz
puppet-d851a16a3af9dd24f675ad5fcf6dfeba6d6273a2.tar.xz
puppet-d851a16a3af9dd24f675ad5fcf6dfeba6d6273a2.zip
Merge branch 'tickets/0.24.x/1384' of git://github.com/ctrlaltdel/puppet into 0.24.x
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/type/ssh_authorized_key.rb59
1 files changed, 52 insertions, 7 deletions
diff --git a/spec/unit/type/ssh_authorized_key.rb b/spec/unit/type/ssh_authorized_key.rb
index 0e869747d..3c87decf1 100755
--- a/spec/unit/type/ssh_authorized_key.rb
+++ b/spec/unit/type/ssh_authorized_key.rb
@@ -14,6 +14,7 @@ describe ssh_authorized_key do
@provider = stub 'provider', :class => @provider_class, :file_path => "/tmp/whatever", :clear => nil
@provider_class.stubs(:new).returns(@provider)
+ @catalog = Puppet::Node::Catalog.new
end
it "should have a name parameter" do
@@ -33,27 +34,27 @@ describe ssh_authorized_key do
end
it "should support :present as a value for :ensure" do
- proc { @class.create(:name => "whev", :ensure => :present) }.should_not raise_error
+ proc { @class.create(:name => "whev", :ensure => :present, :user => "nobody") }.should_not raise_error
end
it "should support :absent as a value for :ensure" do
- proc { @class.create(:name => "whev", :ensure => :absent) }.should_not raise_error
+ proc { @class.create(:name => "whev", :ensure => :absent, :user => "nobody") }.should_not raise_error
end
it "should have an type property" do
@class.attrtype(:type).should == :property
end
it "should support ssh-dss as an type value" do
- proc { @class.create(:name => "whev", :type => "ssh-dss") }.should_not raise_error
+ proc { @class.create(:name => "whev", :type => "ssh-dss", :user => "nobody") }.should_not raise_error
end
it "should support ssh-rsa as an type value" do
- proc { @class.create(:name => "whev", :type => "ssh-rsa") }.should_not raise_error
+ proc { @class.create(:name => "whev", :type => "ssh-rsa", :user => "nobody") }.should_not raise_error
end
it "should support :dsa as an type value" do
- proc { @class.create(:name => "whev", :type => :dsa) }.should_not raise_error
+ proc { @class.create(:name => "whev", :type => :dsa, :user => "nobody") }.should_not raise_error
end
it "should support :rsa as an type value" do
- proc { @class.create(:name => "whev", :type => :rsa) }.should_not raise_error
+ proc { @class.create(:name => "whev", :type => :rsa, :user => "nobody") }.should_not raise_error
end
it "should not support values other than ssh-dss, ssh-rsa, dsa, rsa in the ssh_authorized_key_type" do
@@ -76,5 +77,49 @@ describe ssh_authorized_key do
@class.attrtype(:target).should == :property
end
- after { @class.clear }
+ it "should autorequire parent directories when user is given" do
+ @catalog.add_resource @class.create(
+ :name => "Test",
+ :key => "AAA",
+ :type => "ssh-rsa",
+ :ensure => :present,
+ :user => "root")
+ @catalog.apply
+
+ target = File.expand_path("~root/.ssh")
+ @catalog.resource(:file, target).should be_an_instance_of(Puppet::Type.type(:file))
+ end
+
+ it "should set target when user is given" do
+ @catalog.add_resource @class.create(
+ :name => "Test",
+ :key => "AAA",
+ :type => "ssh-rsa",
+ :ensure => :present,
+ :user => "root")
+ @catalog.apply
+
+ target = File.expand_path("~root/.ssh/authorized_keys")
+ @catalog.resource(:file, target).should be_an_instance_of(Puppet::Type.type(:file))
+ end
+
+
+ it "should autorequire parent directories when target is given" do
+ target = "/tmp/home/foo/bar/.ssh/authorized_keys"
+
+ @catalog.add_resource @class.create(
+ :name => "Test",
+ :key => "AAA",
+ :type => "ssh-rsa",
+ :ensure => :present,
+ :target => target)
+ @catalog.apply
+
+ @catalog.resource(:file, target).should be_an_instance_of(Puppet::Type.type(:file))
+ end
+
+ after do
+ @class.clear
+ @catalog.clear
+ end
end