summaryrefslogtreecommitdiffstats
path: root/spec/integration
diff options
context:
space:
mode:
authorMichael Stahnke <stahnma@puppetlabs.com>2011-08-05 09:23:49 -0700
committerMichael Stahnke <stahnma@puppetlabs.com>2011-08-05 09:23:49 -0700
commit3daea902b29cfd8e126ed64247ddf28aa5ad3d76 (patch)
treecda7fff4d06c7f3607a84b260fd71adfd9704e3b /spec/integration
parentc8835ad0275c350b57884b81e485d9fc16699a21 (diff)
parent2185bb2804aeef6b419667951b2157b01404c694 (diff)
Merge branch '2.7.x' into 2.7rc
Diffstat (limited to 'spec/integration')
-rwxr-xr-xspec/integration/defaults_spec.rb2
-rw-r--r--spec/integration/network/rest_authconfig_spec.rb145
-rwxr-xr-xspec/integration/node/facts_spec.rb2
3 files changed, 147 insertions, 2 deletions
diff --git a/spec/integration/defaults_spec.rb b/spec/integration/defaults_spec.rb
index 9bec769ab..8cf0e3e7b 100755
--- a/spec/integration/defaults_spec.rb
+++ b/spec/integration/defaults_spec.rb
@@ -275,6 +275,6 @@ describe "Puppet defaults" do
describe "reporturl" do
subject { Puppet.settings[:reporturl] }
- it { should == "http://localhost:3000/reports" }
+ it { should == "http://localhost:3000/reports/upload" }
end
end
diff --git a/spec/integration/network/rest_authconfig_spec.rb b/spec/integration/network/rest_authconfig_spec.rb
new file mode 100644
index 000000000..d2f539cd4
--- /dev/null
+++ b/spec/integration/network/rest_authconfig_spec.rb
@@ -0,0 +1,145 @@
+require 'spec_helper'
+
+require 'puppet/network/rest_authconfig'
+
+RSpec::Matchers.define :allow do |params|
+
+ match do |auth|
+ begin
+ auth.check_authorization(params[0], params[1], params[2], params[3])
+ true
+ rescue Puppet::Network::AuthorizationError
+ false
+ end
+ end
+
+ failure_message_for_should do |instance|
+ "expected #{params[3][:node]}/#{params[3][:ip]} to be allowed"
+ end
+
+ failure_message_for_should_not do |instance|
+ "expected #{params[3][:node]}/#{params[3][:ip]} to be forbidden"
+ end
+end
+
+describe Puppet::Network::RestAuthConfig do
+ include PuppetSpec::Files
+
+ before(:each) do
+ Puppet[:rest_authconfig] = tmpfile('auth.conf')
+ end
+
+ def add_rule(rule)
+ File.open(Puppet[:rest_authconfig],"w+") do |f|
+ f.print "path /test\n#{rule}\n"
+ end
+ @auth = Puppet::Network::RestAuthConfig.new(Puppet[:rest_authconfig], true)
+ end
+
+ def add_regex_rule(regex, rule)
+ File.open(Puppet[:rest_authconfig],"w+") do |f|
+ f.print "path ~ #{regex}\n#{rule}\n"
+ end
+ @auth = Puppet::Network::RestAuthConfig.new(Puppet[:rest_authconfig], true)
+ end
+
+ def request(args = {})
+ { :ip => '10.1.1.1', :node => 'host.domain.com', :key => 'key', :authenticated => true }.each do |k,v|
+ args[k] ||= v
+ end
+ ['test', :find, args[:key], args]
+ end
+
+ it "should support IPv4 address" do
+ add_rule("allow 10.1.1.1")
+
+ @auth.should allow(request)
+ end
+
+ it "should support CIDR IPv4 address" do
+ add_rule("allow 10.0.0.0/8")
+
+ @auth.should allow(request)
+ end
+
+ it "should support wildcard IPv4 address" do
+ add_rule("allow 10.1.1.*")
+
+ @auth.should allow(request)
+ end
+
+ it "should support IPv6 address" do
+ add_rule("allow 2001:DB8::8:800:200C:417A")
+
+ @auth.should allow(request(:ip => '2001:DB8::8:800:200C:417A'))
+ end
+
+ it "should support hostname" do
+ add_rule("allow host.domain.com")
+
+ @auth.should allow(request)
+ end
+
+ it "should support wildcard host" do
+ add_rule("allow *.domain.com")
+
+ @auth.should allow(request)
+ end
+
+ it "should support hostname backreferences" do
+ add_regex_rule('^/test/([^/]+)$', "allow $1.domain.com")
+
+ @auth.should allow(request(:key => 'host'))
+ end
+
+ it "should support opaque strings" do
+ add_rule("allow this-is-opaque@or-not")
+
+ @auth.should allow(request(:node => 'this-is-opaque@or-not'))
+ end
+
+ it "should support opaque strings and backreferences" do
+ add_regex_rule('^/test/([^/]+)$', "allow $1")
+
+ @auth.should allow(request(:key => 'this-is-opaque@or-not', :node => 'this-is-opaque@or-not'))
+ end
+
+ it "should support hostname ending with '.'" do
+ pending('bug #7589')
+ add_rule("allow host.domain.com.")
+
+ @auth.should allow(request(:node => 'host.domain.com.'))
+ end
+
+ it "should support hostname ending with '.' and backreferences" do
+ pending('bug #7589')
+ add_regex_rule('^/test/([^/]+)$',"allow $1")
+
+ @auth.should allow(request(:node => 'host.domain.com.'))
+ end
+
+ it "should support trailing whitespace" do
+ add_rule('allow host.domain.com ')
+
+ @auth.should allow(request)
+ end
+
+ it "should support inlined comments" do
+ add_rule('allow host.domain.com # will it work?')
+
+ @auth.should allow(request)
+ end
+
+ it "should deny non-matching host" do
+ add_rule("allow inexistant")
+
+ @auth.should_not allow(request)
+ end
+
+ it "should deny denied hosts" do
+ add_rule("deny host.domain.com")
+
+ @auth.should_not allow(request)
+ end
+
+end \ No newline at end of file
diff --git a/spec/integration/node/facts_spec.rb b/spec/integration/node/facts_spec.rb
index f54d7f9aa..e87a0bdeb 100755
--- a/spec/integration/node/facts_spec.rb
+++ b/spec/integration/node/facts_spec.rb
@@ -7,7 +7,7 @@ require 'spec_helper'
describe Puppet::Node::Facts do
describe "when using the indirector" do
- after { Puppet::Util::Cacher.expire }
+ after(:each) { Puppet::Util::Cacher.expire }
it "should expire any cached node instances when it is saved" do
Puppet::Node::Facts.indirection.stubs(:terminus_class).returns :yaml