summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorFrancois Deppierraz <francois.deppierraz@camptocamp.com>2008-07-11 14:39:52 +0200
committerFrancois Deppierraz <francois.deppierraz@camptocamp.com>2008-07-11 14:39:52 +0200
commit4c5293b837807f61002365114fd7004d2f74ad57 (patch)
tree79682bd83dd18ccfca8a909da611f725edebbc89 /spec
parent80436550a1e3040399e410be3edf7c44d29fc320 (diff)
downloadpuppet-4c5293b837807f61002365114fd7004d2f74ad57.tar.gz
puppet-4c5293b837807f61002365114fd7004d2f74ad57.tar.xz
puppet-4c5293b837807f61002365114fd7004d2f74ad57.zip
Fix #1409, Move path expansion from the type into the provider
This avoid exceptions during type instanciation when a user does not yet exist. The drawback is that we cannot use generated resources anymore and have to mkdir, chown and chmod directly in the provided which is somewhat hackish.
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/provider/ssh_authorized_key/parsed.rb21
-rwxr-xr-xspec/unit/type/ssh_authorized_key.rb41
2 files changed, 21 insertions, 41 deletions
diff --git a/spec/unit/provider/ssh_authorized_key/parsed.rb b/spec/unit/provider/ssh_authorized_key/parsed.rb
index c35ddc513..16efc5b58 100755
--- a/spec/unit/provider/ssh_authorized_key/parsed.rb
+++ b/spec/unit/provider/ssh_authorized_key/parsed.rb
@@ -71,4 +71,25 @@ 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 "should prefetch ~user/.ssh/authorized_keys when user is given" do
+ key = Puppet::Type.type(:ssh_authorized_key).create(
+ :name => "Test",
+ :key => "AA",
+ :type => "rsa",
+ :ensure => :present,
+ :user => "root")
+ prov = @provider.new key
+
+ prov.prefetch
+ prov.target.should == File.expand_path("~root/.ssh/authorized_keys")
+ end
+
+ it "should create destination dir" do
+ # No idea how to test the flush method
+ end
+
+ it "should set correct default permissions" do
+ # No idea how to test the flush method
+ end
end
diff --git a/spec/unit/type/ssh_authorized_key.rb b/spec/unit/type/ssh_authorized_key.rb
index 0b41af40a..e21478479 100755
--- a/spec/unit/type/ssh_authorized_key.rb
+++ b/spec/unit/type/ssh_authorized_key.rb
@@ -77,47 +77,6 @@ describe ssh_authorized_key do
@class.attrtype(:target).should == :property
end
- 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
-
it "should raise an error when neither user nor target is given" do
proc do
@class.create(