summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2009-04-21 23:53:17 +0200
committerBrice Figureau <brice-puppet@daysofwonder.com>2009-04-23 20:52:02 +0200
commit15abe1709aa52bb45fe228139f4c0352dc8905df (patch)
treee9c625c3ac780a3d263e4a324bcd2539c240d0a6
parent86c79777bd190bab425be036ec01378793d059b5 (diff)
downloadpuppet-15abe1709aa52bb45fe228139f4c0352dc8905df.tar.gz
puppet-15abe1709aa52bb45fe228139f4c0352dc8905df.tar.xz
puppet-15abe1709aa52bb45fe228139f4c0352dc8905df.zip
Add RSpec unit tests for network rights
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
-rwxr-xr-xspec/unit/network/rights.rb54
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/unit/network/rights.rb b/spec/unit/network/rights.rb
new file mode 100755
index 000000000..5fe8e51f4
--- /dev/null
+++ b/spec/unit/network/rights.rb
@@ -0,0 +1,54 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../spec_helper'
+
+require 'puppet/network/rights'
+
+describe Puppet::Network::Rights do
+ before do
+ @right = Puppet::Network::Rights.new
+ end
+
+ [:allow, :allowed?, :deny].each do |m|
+ it "should have a #{m} method" do
+ @right.should respond_to(m)
+ end
+
+ describe "when using #{m}" do
+ it "should delegate to the correct acl" do
+ acl = stub 'acl'
+ @right.stubs(:right).returns(acl)
+
+ acl.expects(m).with("me")
+
+ @right.send(m, 'thisacl', "me")
+ end
+ end
+ end
+
+ describe "when creating new ACLs" do
+ it "should throw an error if the ACL already exists" do
+ @right.newright("name")
+
+ lambda { @right.newright("name")}.should raise_error
+ end
+
+ it "should create a new ACL with the correct name" do
+ @right.newright("name")
+
+ @right["name"].name.should == :name
+ end
+
+ it "should create an ACL of type Puppet::Network::AuthStore" do
+ @right.newright("name")
+
+ @right["name"].should be_a_kind_of(Puppet::Network::AuthStore)
+ end
+
+ it "should create an ACL with a shortname" do
+ @right.newright("name")
+
+ @right["name"].shortname.should == "n"
+ end
+ end
+end