summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-07-08 15:03:13 -0500
committerLuke Kanies <luke@madstop.com>2008-07-08 15:03:13 -0500
commitc1dc92b9a14c04096e0bed0f2c4acc4dfe1ed7d2 (patch)
treeb3269b4e76edbcb3458fcdf1832421fb11e57890 /spec
parentb0febd263c0cb8e61d512898f7c79868ea77e619 (diff)
parentedf99c508dabb58342eeff251ad5701d2755426d (diff)
downloadpuppet-c1dc92b9a14c04096e0bed0f2c4acc4dfe1ed7d2.tar.gz
puppet-c1dc92b9a14c04096e0bed0f2c4acc4dfe1ed7d2.tar.xz
puppet-c1dc92b9a14c04096e0bed0f2c4acc4dfe1ed7d2.zip
Merge branch '0.24.x'
Conflicts: CHANGELOG
Diffstat (limited to 'spec')
-rwxr-xr-xspec/integration/node.rb7
-rwxr-xr-xspec/integration/node/catalog.rb6
-rwxr-xr-xspec/integration/node/facts.rb6
-rwxr-xr-xspec/unit/provider/group/ldap.rb25
-rw-r--r--spec/unit/provider/package/gem.rb87
-rwxr-xr-xspec/unit/provider/user/ldap.rb11
6 files changed, 133 insertions, 9 deletions
diff --git a/spec/integration/node.rb b/spec/integration/node.rb
index b0375e743..de95d0e79 100755
--- a/spec/integration/node.rb
+++ b/spec/integration/node.rb
@@ -31,10 +31,11 @@ describe Puppet::Node do
Puppet::Node.indirection.stubs(:terminus_class).returns :yaml
# Load now, before we stub the exists? method.
- Puppet::Node.indirection.terminus(:yaml)
+ terminus = Puppet::Node.indirection.terminus(:yaml)
- file = File.join(Puppet[:yamldir], "node", "me.yaml")
- FileTest.expects(:exist?).with(file).returns false
+ terminus.expects(:path).with(@name).returns "/my/yaml/file"
+
+ FileTest.expects(:exist?).with("/my/yaml/file").returns false
Puppet::Node.find(@name).should be_nil
end
diff --git a/spec/integration/node/catalog.rb b/spec/integration/node/catalog.rb
index 285b85869..87d62ea6a 100755
--- a/spec/integration/node/catalog.rb
+++ b/spec/integration/node/catalog.rb
@@ -19,10 +19,10 @@ describe Puppet::Node::Catalog do
Puppet::Node::Catalog.indirection.stubs(:terminus_class).returns :yaml
# Load now, before we stub the exists? method.
- Puppet::Node::Catalog.indirection.terminus(:yaml)
+ terminus = Puppet::Node::Catalog.indirection.terminus(:yaml)
+ terminus.expects(:path).with("me").returns "/my/yaml/file"
- file = File.join(Puppet[:yamldir], "catalog", "me.yaml")
- FileTest.expects(:exist?).with(file).returns false
+ FileTest.expects(:exist?).with("/my/yaml/file").returns false
Puppet::Node::Catalog.find("me").should be_nil
end
diff --git a/spec/integration/node/facts.rb b/spec/integration/node/facts.rb
index cef3d79d4..5a54a6e49 100755
--- a/spec/integration/node/facts.rb
+++ b/spec/integration/node/facts.rb
@@ -26,10 +26,10 @@ describe Puppet::Node::Facts do
Puppet::Node::Facts.indirection.stubs(:terminus_class).returns :yaml
# Load now, before we stub the exists? method.
- Puppet::Node::Facts.indirection.terminus(:yaml)
+ terminus = Puppet::Node::Facts.indirection.terminus(:yaml)
- file = File.join(Puppet[:yamldir], "facts", "me.yaml")
- FileTest.expects(:exist?).with(file).returns false
+ terminus.expects(:path).with("me").returns "/my/yaml/file"
+ FileTest.expects(:exist?).with("/my/yaml/file").returns false
Puppet::Node::Facts.find("me").should be_nil
end
diff --git a/spec/unit/provider/group/ldap.rb b/spec/unit/provider/group/ldap.rb
index 53d9e8bfc..ab2bd72aa 100755
--- a/spec/unit/provider/group/ldap.rb
+++ b/spec/unit/provider/group/ldap.rb
@@ -77,4 +77,29 @@ describe provider_class do
end
end
end
+
+ it "should have a method for converting group names to GIDs" do
+ provider_class.should respond_to(:name2id)
+ end
+
+ describe "when converting from a group name to GID" do
+ it "should use the ldap manager to look up the GID" do
+ provider_class.manager.expects(:search).with("cn=foo")
+ provider_class.name2id("foo")
+ end
+
+ it "should return nil if no group is found" do
+ provider_class.manager.expects(:search).with("cn=foo").returns nil
+ provider_class.name2id("foo").should be_nil
+ provider_class.manager.expects(:search).with("cn=bar").returns []
+ provider_class.name2id("bar").should be_nil
+ end
+
+ # We shouldn't ever actually have more than one gid, but it doesn't hurt
+ # to test for the possibility.
+ it "should return the first gid from the first returned group" do
+ provider_class.manager.expects(:search).with("cn=foo").returns [{:name => "foo", :gid => [10, 11]}, {:name => :bar, :gid => [20, 21]}]
+ provider_class.name2id("foo").should == 10
+ end
+ end
end
diff --git a/spec/unit/provider/package/gem.rb b/spec/unit/provider/package/gem.rb
new file mode 100644
index 000000000..3dc1fa347
--- /dev/null
+++ b/spec/unit/provider/package/gem.rb
@@ -0,0 +1,87 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+provider_class = Puppet::Type.type(:package).provider(:gem)
+
+describe provider_class do
+ it "should have an install method" do
+ @provider = provider_class.new
+ @provider.should respond_to(:install)
+ end
+
+ describe "when installing" do
+ before do
+ # Create a mock resource
+ @resource = stub 'resource'
+
+ # A catch all; no parameters set
+ @resource.stubs(:[]).returns nil
+
+ # We have to set a name, though
+ @resource.stubs(:[]).with(:name).returns "myresource"
+ @resource.stubs(:[]).with(:ensure).returns :installed
+
+ @provider = provider_class.new
+ @provider.stubs(:resource).returns @resource
+ end
+
+ it "should use the path to the gem" do
+ provider_class.stubs(:command).with(:gemcmd).returns "/my/gem"
+ @provider.expects(:execute).with { |args| args[0] == "/my/gem" }.returns ""
+ @provider.install
+ end
+
+ it "should specify that the gem is being installed" do
+ @provider.expects(:execute).with { |args| args[1] == "install" }.returns ""
+ @provider.install
+ end
+
+ it "should specify that dependencies should be included" do
+ @provider.expects(:execute).with { |args| args[2] == "--include-dependencies" }.returns ""
+ @provider.install
+ end
+
+ it "should specify the package name" do
+ @provider.expects(:execute).with { |args| args[3] == "myresource" }.returns ""
+ @provider.install
+ end
+
+ describe "when a source is specified" do
+ describe "as a normal file" do
+ it "should use the file name instead of the gem name" do
+ @resource.stubs(:[]).with(:source).returns "/my/file"
+ @provider.expects(:execute).with { |args| args[3] == "/my/file" }.returns ""
+ @provider.install
+ end
+ end
+ describe "as a file url" do
+ it "should use the file name instead of the gem name" do
+ @resource.stubs(:[]).with(:source).returns "file:///my/file"
+ @provider.expects(:execute).with { |args| args[3] == "/my/file" }.returns ""
+ @provider.install
+ end
+ end
+ describe "as a puppet url" do
+ it "should fail" do
+ @resource.stubs(:[]).with(:source).returns "puppet://my/file"
+ lambda { @provider.install }.should raise_error(Puppet::Error)
+ end
+ end
+ describe "as a non-file and non-puppet url" do
+ it "should treat the source as a gem repository" do
+ @resource.stubs(:[]).with(:source).returns "http://host/my/file"
+ @provider.expects(:execute).with { |args| args[3..5] == ["--source", "http://host/my/file", "myresource"] }.returns ""
+ @provider.install
+ end
+ end
+ describe "with an invalid uri" do
+ it "should fail" do
+ URI.expects(:parse).raises(ArgumentError)
+ @resource.stubs(:[]).with(:source).returns "http:::::uppet:/:/my/file"
+ lambda { @provider.install }.should raise_error(Puppet::Error)
+ end
+ end
+ end
+ end
+end
diff --git a/spec/unit/provider/user/ldap.rb b/spec/unit/provider/user/ldap.rb
index 90fc7423f..7e039d582 100755
--- a/spec/unit/provider/user/ldap.rb
+++ b/spec/unit/provider/user/ldap.rb
@@ -24,6 +24,17 @@ describe provider_class do
provider_class.manager.rdn.should == :uid
end
+ it "should be able to manage passwords" do
+ provider_class.should be_manages_passwords
+
+ it "should use the ldap group provider to convert group names to numbers" do
+ provider = provider_class.new(:name => "foo")
+ Puppet::Type.type(:group).provider(:ldap).expects(:name2id).with("bar").returns 10
+
+ provider.gid = 'bar'
+ provider.gid.should == 10
+ end
+
{:name => "uid",
:password => "userPassword",
:comment => "cn",