summaryrefslogtreecommitdiffstats
path: root/spec/unit/network
diff options
context:
space:
mode:
authorDominic Maraglia <dominic@puppetlabs.com>2011-08-03 15:43:20 -0700
committerDominic Maraglia <dominic@puppetlabs.com>2011-08-03 15:43:20 -0700
commite45f08bf1fef8842554ca0d8cb6fb13711e888e7 (patch)
tree9bb476a0fe381d53060abc1f1c240cf1291b2ee4 /spec/unit/network
parenta97c86e7d01384aa06f5d4d69da427fc355aebe7 (diff)
parentc833fde370d43023f52c8f2e11fd77e720d0f577 (diff)
Merge branch 'master' of github.com:puppetlabs/puppet
Diffstat (limited to 'spec/unit/network')
-rwxr-xr-xspec/unit/network/authconfig_spec.rb23
-rwxr-xr-xspec/unit/network/client_spec.rb45
-rwxr-xr-xspec/unit/network/handler/fileserver_spec.rb10
-rwxr-xr-xspec/unit/network/http/webrick_spec.rb10
-rwxr-xr-xspec/unit/network/http_pool_spec.rb75
-rwxr-xr-xspec/unit/network/rest_authconfig_spec.rb2
6 files changed, 38 insertions, 127 deletions
diff --git a/spec/unit/network/authconfig_spec.rb b/spec/unit/network/authconfig_spec.rb
index c47b2e0c5..ca94cc1ab 100755
--- a/spec/unit/network/authconfig_spec.rb
+++ b/spec/unit/network/authconfig_spec.rb
@@ -184,6 +184,29 @@ describe Puppet::Network::AuthConfig do
@authconfig.read
end
+ it "should strip whitespace around ACE" do
+ acl = stub 'acl', :info
+
+ @fd.stubs(:each).multiple_yields('[puppetca]', ' allow 127.0.0.1 , 172.16.10.0 ')
+ @rights.stubs(:newright).with("[puppetca]", 1, 'dummy').returns(acl)
+
+ acl.expects(:allow).with('127.0.0.1')
+ acl.expects(:allow).with('172.16.10.0')
+
+ @authconfig.read
+ end
+
+ it "should allow ACE inline comments" do
+ acl = stub 'acl', :info
+
+ @fd.stubs(:each).multiple_yields('[puppetca]', ' allow 127.0.0.1 # will it work?')
+ @rights.stubs(:newright).with("[puppetca]", 1, 'dummy').returns(acl)
+
+ acl.expects(:allow).with('127.0.0.1')
+
+ @authconfig.read
+ end
+
it "should create an allow ACE on each subsequent allow" do
acl = stub 'acl', :info
diff --git a/spec/unit/network/client_spec.rb b/spec/unit/network/client_spec.rb
deleted file mode 100755
index 102a053c0..000000000
--- a/spec/unit/network/client_spec.rb
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/env rspec
-#
-# Created by Luke Kanies on 2008-3-24.
-# Copyright (c) 2008. All rights reserved.
-
-require 'spec_helper'
-
-require 'puppet/network/client'
-
-describe Puppet::Network::Client do
- before do
- Puppet.settings.stubs(:use).returns(true)
- Puppet::Network::HttpPool.stubs(:cert_setup)
- end
-
- describe "when keep-alive is enabled" do
- before do
- Puppet::Network::HttpPool.stubs(:keep_alive?).returns true
- end
- it "should start the http client up on creation" do
- http = mock 'http'
- http.stub_everything
- http.expects(:start)
- Net::HTTP.stubs(:new).returns http
-
- # Pick a random subclass...
- Puppet::Network::Client.runner.new :Server => Puppet[:server]
- end
- end
-
- describe "when keep-alive is disabled" do
- before do
- Puppet::Network::HttpPool.stubs(:keep_alive?).returns false
- end
- it "should not start the http client up on creation" do
- http = mock 'http'
- http.stub_everything
- http.expects(:start).never
- Net::HTTP.stubs(:new).returns http
-
- # Pick a random subclass...
- Puppet::Network::Client.runner.new :Server => Puppet[:server]
- end
- end
-end
diff --git a/spec/unit/network/handler/fileserver_spec.rb b/spec/unit/network/handler/fileserver_spec.rb
index 08852634d..93f124882 100755
--- a/spec/unit/network/handler/fileserver_spec.rb
+++ b/spec/unit/network/handler/fileserver_spec.rb
@@ -41,12 +41,12 @@ describe Puppet::Network::Handler::FileServer do
@mount.list("/no_such_file", false, false).should be(nil)
end
- it "should list a symbolic link as a file when given the link path" do
+ it "should list a symbolic link as a file when given the link path", :unless => Puppet.features.microsoft_windows? do
File.symlink(@file, @link)
@mount.list("/aLink", false, false).should == [["/", "file"]]
end
- it "should return nil for a dangling symbolic link when given the link path" do
+ it "should return nil for a dangling symbolic link when given the link path", :unless => Puppet.features.microsoft_windows? do
File.symlink("/some/where", @link)
@mount.list("/aLink", false, false).should be(nil)
end
@@ -106,18 +106,18 @@ describe Puppet::Network::Handler::FileServer do
list.sort.should == [ ["/aFile", "file"], ["/", "directory"] , ["/nested_dir", "directory"], ["/nested_dir/nested_dir_file", "file"]].sort
end
- it "should list a valid symbolic link as a file when recursing base dir" do
+ it "should list a valid symbolic link as a file when recursing base dir", :unless => Puppet.features.microsoft_windows? do
File.symlink(@file, @link)
list = @mount.list("/", true, false)
list.sort.should == [ ["/", "directory"], ["/aFile", "file"], ["/aLink", "file"] ].sort
end
- it "should not error when a dangling symlink is present" do
+ it "should not error when a dangling symlink is present", :unless => Puppet.features.microsoft_windows? do
File.symlink("/some/where", @link)
lambda { @mount.list("/", true, false) }.should_not raise_error
end
- it "should return the directory contents of valid entries when a dangling symlink is present" do
+ it "should return the directory contents of valid entries when a dangling symlink is present", :unless => Puppet.features.microsoft_windows? do
File.symlink("/some/where", @link)
list = @mount.list("/", true, false)
list.sort.should == [ ["/aFile", "file"], ["/", "directory"] ].sort
diff --git a/spec/unit/network/http/webrick_spec.rb b/spec/unit/network/http/webrick_spec.rb
index be74a1052..8504b02e3 100755
--- a/spec/unit/network/http/webrick_spec.rb
+++ b/spec/unit/network/http/webrick_spec.rb
@@ -8,13 +8,13 @@ require 'puppet/network/handler'
require 'puppet/network/http'
require 'puppet/network/http/webrick'
-describe Puppet::Network::HTTP::WEBrick, "after initializing" do
+describe Puppet::Network::HTTP::WEBrick, "after initializing", :unless => Puppet.features.microsoft_windows? do
it "should not be listening" do
Puppet::Network::HTTP::WEBrick.new.should_not be_listening
end
end
-describe Puppet::Network::HTTP::WEBrick, "when turning on listening" do
+describe Puppet::Network::HTTP::WEBrick, "when turning on listening", :unless => Puppet.features.microsoft_windows? do
before do
@mock_webrick = stub('webrick', :[] => {}, :listeners => [], :status => :Running)
[:mount, :start, :shutdown].each {|meth| @mock_webrick.stubs(meth)}
@@ -143,7 +143,7 @@ describe Puppet::Network::HTTP::WEBrick, "when turning on listening" do
end
-describe Puppet::Network::HTTP::WEBrick, "when looking up the class to handle a protocol" do
+describe Puppet::Network::HTTP::WEBrick, "when looking up the class to handle a protocol", :unless => Puppet.features.microsoft_windows? do
it "should require a protocol" do
lambda { Puppet::Network::HTTP::WEBrick.class_for_protocol }.should raise_error(ArgumentError)
end
@@ -161,7 +161,7 @@ describe Puppet::Network::HTTP::WEBrick, "when looking up the class to handle a
end
end
-describe Puppet::Network::HTTP::WEBrick, "when turning off listening" do
+describe Puppet::Network::HTTP::WEBrick, "when turning off listening", :unless => Puppet.features.microsoft_windows? do
before do
@mock_webrick = stub('webrick', :[] => {}, :listeners => [], :status => :Running)
[:mount, :start, :shutdown].each {|meth| @mock_webrick.stubs(meth)}
@@ -188,7 +188,7 @@ describe Puppet::Network::HTTP::WEBrick, "when turning off listening" do
end
end
-describe Puppet::Network::HTTP::WEBrick do
+describe Puppet::Network::HTTP::WEBrick, :unless => Puppet.features.microsoft_windows? do
before do
@mock_webrick = stub('webrick', :[] => {})
[:mount, :start, :shutdown].each {|meth| @mock_webrick.stubs(meth)}
diff --git a/spec/unit/network/http_pool_spec.rb b/spec/unit/network/http_pool_spec.rb
index c5d3e0470..1961f3029 100755
--- a/spec/unit/network/http_pool_spec.rb
+++ b/spec/unit/network/http_pool_spec.rb
@@ -8,15 +8,9 @@ require 'puppet/network/http_pool'
describe Puppet::Network::HttpPool do
after do
- Puppet::Util::Cacher.expire
- Puppet::Network::HttpPool.clear_http_instances
Puppet::Network::HttpPool.instance_variable_set("@ssl_host", nil)
end
- it "should have keep-alive disabled" do
- Puppet::Network::HttpPool::HTTP_KEEP_ALIVE.should be_false
- end
-
it "should use the global SSL::Host instance to get its certificate information" do
host = mock 'host'
Puppet::SSL::Host.expects(:localhost).with.returns host
@@ -58,71 +52,10 @@ describe Puppet::Network::HttpPool do
Puppet::Network::HttpPool.http_instance("me", 54321).open_timeout.should == 120
end
- describe "and http keep-alive is enabled" do
- before do
- Puppet::Network::HttpPool.stubs(:keep_alive?).returns true
- end
-
- it "should cache http instances" do
- stub_settings :http_proxy_host => "myhost", :http_proxy_port => 432, :configtimeout => 120
- old = Puppet::Network::HttpPool.http_instance("me", 54321)
- Puppet::Network::HttpPool.http_instance("me", 54321).should equal(old)
- end
-
- it "should have a mechanism for getting a new http instance instead of the cached instance" do
- stub_settings :http_proxy_host => "myhost", :http_proxy_port => 432, :configtimeout => 120
- old = Puppet::Network::HttpPool.http_instance("me", 54321)
- Puppet::Network::HttpPool.http_instance("me", 54321, true).should_not equal(old)
- end
-
- it "should close existing, open connections when requesting a new connection" do
- stub_settings :http_proxy_host => "myhost", :http_proxy_port => 432, :configtimeout => 120
- old = Puppet::Network::HttpPool.http_instance("me", 54321)
- old.expects(:started?).returns(true)
- old.expects(:finish)
- Puppet::Network::HttpPool.http_instance("me", 54321, true)
- end
-
- it "should have a mechanism for clearing the http cache" do
- stub_settings :http_proxy_host => "myhost", :http_proxy_port => 432, :configtimeout => 120
- old = Puppet::Network::HttpPool.http_instance("me", 54321)
- Puppet::Network::HttpPool.http_instance("me", 54321).should equal(old)
- old = Puppet::Network::HttpPool.http_instance("me", 54321)
- Puppet::Network::HttpPool.clear_http_instances
- Puppet::Network::HttpPool.http_instance("me", 54321).should_not equal(old)
- end
-
- it "should close open http connections when clearing the cache" do
- stub_settings :http_proxy_host => "myhost", :http_proxy_port => 432, :configtimeout => 120
- one = Puppet::Network::HttpPool.http_instance("me", 54321)
- one.expects(:started?).returns(true)
- one.expects(:finish).returns(true)
- Puppet::Network::HttpPool.clear_http_instances
- end
-
- it "should not close unopened http connections when clearing the cache" do
- stub_settings :http_proxy_host => "myhost", :http_proxy_port => 432, :configtimeout => 120
- one = Puppet::Network::HttpPool.http_instance("me", 54321)
- one.expects(:started?).returns(false)
- one.expects(:finish).never
- Puppet::Network::HttpPool.clear_http_instances
- end
- end
-
- describe "and http keep-alive is disabled" do
- before do
- Puppet::Network::HttpPool.stubs(:keep_alive?).returns false
- end
-
- it "should not cache http instances" do
- stub_settings :http_proxy_host => "myhost", :http_proxy_port => 432, :configtimeout => 120
- old = Puppet::Network::HttpPool.http_instance("me", 54321)
- Puppet::Network::HttpPool.http_instance("me", 54321).should_not equal(old)
- end
- end
-
- after do
- Puppet::Network::HttpPool.clear_http_instances
+ it "should not cache http instances" do
+ stub_settings :http_proxy_host => "myhost", :http_proxy_port => 432, :configtimeout => 120
+ old = Puppet::Network::HttpPool.http_instance("me", 54321)
+ Puppet::Network::HttpPool.http_instance("me", 54321).should_not equal(old)
end
end
diff --git a/spec/unit/network/rest_authconfig_spec.rb b/spec/unit/network/rest_authconfig_spec.rb
index e1403997f..bebbb874f 100755
--- a/spec/unit/network/rest_authconfig_spec.rb
+++ b/spec/unit/network/rest_authconfig_spec.rb
@@ -29,7 +29,7 @@ describe Puppet::Network::RestAuthConfig do
params = {:ip => "127.0.0.1", :node => "me", :environment => :env, :authenticated => true}
@acl.expects(:is_request_forbidden_and_why?).with("path", :save, "to/resource", params).returns(nil)
- @authconfig.allowed?("path", :save, "to/resource", params)
+ @authconfig.check_authorization("path", :save, "to/resource", params)
end
describe "when defining an acl with mk_acl" do