diff options
Diffstat (limited to 'spec/unit/network')
21 files changed, 46 insertions, 44 deletions
diff --git a/spec/unit/network/authconfig_spec.rb b/spec/unit/network/authconfig_spec.rb index e10458b1a..4367e25e6 100755 --- a/spec/unit/network/authconfig_spec.rb +++ b/spec/unit/network/authconfig_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/network/authconfig' diff --git a/spec/unit/network/authstore_spec.rb b/spec/unit/network/authstore_spec.rb index 094352c63..0b4dd21de 100644 --- a/spec/unit/network/authstore_spec.rb +++ b/spec/unit/network/authstore_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/network/authconfig' diff --git a/spec/unit/network/client_spec.rb b/spec/unit/network/client_spec.rb index f42bd78b9..820f10f12 100755 --- a/spec/unit/network/client_spec.rb +++ b/spec/unit/network/client_spec.rb @@ -3,7 +3,7 @@ # Created by Luke Kanies on 2008-3-24. # Copyright (c) 2008. All rights reserved. -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/network/client' diff --git a/spec/unit/network/format_handler_spec.rb b/spec/unit/network/format_handler_spec.rb index 64cca8239..556fada80 100755 --- a/spec/unit/network/format_handler_spec.rb +++ b/spec/unit/network/format_handler_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/network/format_handler' diff --git a/spec/unit/network/format_spec.rb b/spec/unit/network/format_spec.rb index bcb084156..658729e4c 100755 --- a/spec/unit/network/format_spec.rb +++ b/spec/unit/network/format_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/network/format' diff --git a/spec/unit/network/formats_spec.rb b/spec/unit/network/formats_spec.rb index 7c8e7b1f4..26d64188c 100755 --- a/spec/unit/network/formats_spec.rb +++ b/spec/unit/network/formats_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/network/formats' diff --git a/spec/unit/network/handler/fileserver_spec.rb b/spec/unit/network/handler/fileserver_spec.rb index b37d4f551..b1306c69e 100644 --- a/spec/unit/network/handler/fileserver_spec.rb +++ b/spec/unit/network/handler/fileserver_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') require 'puppet/network/handler/fileserver' diff --git a/spec/unit/network/http/compression_spec.rb b/spec/unit/network/http/compression_spec.rb index b46941f46..96d2eaf46 100644 --- a/spec/unit/network/http/compression_spec.rb +++ b/spec/unit/network/http/compression_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') describe "http compression" do diff --git a/spec/unit/network/http/handler_spec.rb b/spec/unit/network/http/handler_spec.rb index 16f1b5349..ff60c78fc 100755 --- a/spec/unit/network/http/handler_spec.rb +++ b/spec/unit/network/http/handler_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') require 'puppet/network/http/handler' require 'puppet/network/rest_authorization' @@ -46,6 +46,8 @@ describe Puppet::Network::HTTP::Handler do @request.stubs(:[]).returns "foo" @response = stub('http response') @model_class = stub('indirected model class') + @indirection = stub('indirection') + @model_class.stubs(:indirection).returns(@indirection) @result = stub 'result', :render => "mytext" @@ -126,7 +128,7 @@ describe Puppet::Network::HTTP::Handler do describe "when finding a model instance" do before do - @model_class.stubs(:find).returns @result + @indirection.stubs(:find).returns @result Puppet::Indirector::Indirection.expects(:instance).with(:my_handler).returns( stub "indirection", :model => @model_class ) @format = stub 'format', :suitable? => true, :mime => "text/format", :name => "format" @@ -141,14 +143,14 @@ describe Puppet::Network::HTTP::Handler do end it "should use the escaped request key" do - @model_class.expects(:find).with do |key, args| + @indirection.expects(:find).with do |key, args| key == "my_result" end.returns @result @handler.do_find("my_handler", "my_result", {}, @request, @response) end it "should use a common method for determining the request parameters" do - @model_class.expects(:find).with do |key, args| + @indirection.expects(:find).with do |key, args| args[:foo] == :baz and args[:bar] == :xyzzy end.returns @result @handler.do_find("my_handler", "my_result", {:foo => :baz, :bar => :xyzzy}, @request, @response) @@ -200,20 +202,20 @@ describe Puppet::Network::HTTP::Handler do @model_instance.expects(:render).returns "my_rendered_object" @handler.expects(:set_response).with { |response, body, status| body == "my_rendered_object" } - @model_class.stubs(:find).returns(@model_instance) + @indirection.stubs(:find).returns(@model_instance) @handler.do_find("my_handler", "my_result", {}, @request, @response) end it "should return a 404 when no model instance can be found" do @model_class.stubs(:name).returns "my name" @handler.expects(:set_response).with { |response, body, status| status == 404 } - @model_class.stubs(:find).returns(nil) + @indirection.stubs(:find).returns(nil) @handler.do_find("my_handler", "my_result", {}, @request, @response) end it "should write a log message when no model instance can be found" do @model_class.stubs(:name).returns "my name" - @model_class.stubs(:find).returns(nil) + @indirection.stubs(:find).returns(nil) Puppet.expects(:info).with("Could not find my_handler for 'my_result'") @@ -226,7 +228,7 @@ describe Puppet::Network::HTTP::Handler do @handler.expects(:format_to_use).returns(@oneformat) @model_instance.expects(:render).with(@oneformat).returns "my_rendered_object" - @model_class.stubs(:find).returns(@model_instance) + @indirection.stubs(:find).returns(@model_instance) @handler.do_find("my_handler", "my_result", {}, @request, @response) end end @@ -240,7 +242,7 @@ describe Puppet::Network::HTTP::Handler do @result = [@result1, @result2] @model_class.stubs(:render_multiple).returns "my rendered instances" - @model_class.stubs(:search).returns(@result) + @indirection.stubs(:search).returns(@result) @format = stub 'format', :suitable? => true, :mime => "text/format", :name => "format" Puppet::Network::FormatHandler.stubs(:format).returns @format @@ -254,14 +256,14 @@ describe Puppet::Network::HTTP::Handler do end it "should use a common method for determining the request parameters" do - @model_class.expects(:search).with do |key, args| + @indirection.expects(:search).with do |key, args| args[:foo] == :baz and args[:bar] == :xyzzy end.returns @result @handler.do_search("my_handler", "my_result", {:foo => :baz, :bar => :xyzzy}, @request, @response) end it "should use the default status when a model search call succeeds" do - @model_class.stubs(:search).returns(@result) + @indirection.stubs(:search).returns(@result) @handler.do_search("my_handler", "my_result", {}, @request, @response) end @@ -275,7 +277,7 @@ describe Puppet::Network::HTTP::Handler do it "should return a list of serialized objects when a model search call succeeds" do @handler.expects(:accept_header).with(@request).returns "one,two" - @model_class.stubs(:search).returns(@result) + @indirection.stubs(:search).returns(@result) @model_class.expects(:render_multiple).with(@oneformat, @result).returns "my rendered instances" @@ -285,7 +287,7 @@ describe Puppet::Network::HTTP::Handler do it "should return [] when searching returns an empty array" do @handler.expects(:accept_header).with(@request).returns "one,two" - @model_class.stubs(:search).returns([]) + @indirection.stubs(:search).returns([]) @model_class.expects(:render_multiple).with(@oneformat, []).returns "[]" @@ -296,7 +298,7 @@ describe Puppet::Network::HTTP::Handler do it "should return a 404 when searching returns nil" do @model_class.stubs(:name).returns "my name" @handler.expects(:set_response).with { |response, body, status| status == 404 } - @model_class.stubs(:search).returns(nil) + @indirection.stubs(:search).returns(nil) @handler.do_search("my_handler", "my_result", {}, @request, @response) end end @@ -306,7 +308,7 @@ describe Puppet::Network::HTTP::Handler do Puppet::Indirector::Indirection.expects(:instance).with(:my_handler).returns( stub "indirection", :model => @model_class ) @result = stub 'result', :render => "the result" - @model_class.stubs(:destroy).returns @result + @indirection.stubs(:destroy).returns @result end it "should use the indirection request to find the model" do @@ -314,14 +316,14 @@ describe Puppet::Network::HTTP::Handler do end it "should use the escaped request key to destroy the instance in the model" do - @model_class.expects(:destroy).with do |key, args| + @indirection.expects(:destroy).with do |key, args| key == "foo bar" end @handler.do_destroy("my_handler", "foo bar", {}, @request, @response) end it "should use a common method for determining the request parameters" do - @model_class.expects(:destroy).with do |key, args| + @indirection.expects(:destroy).with do |key, args| args[:foo] == :baz and args[:bar] == :xyzzy end @handler.do_destroy("my_handler", "my_result", {:foo => :baz, :bar => :xyzzy}, @request, @response) @@ -334,7 +336,7 @@ describe Puppet::Network::HTTP::Handler do it "should return a yaml-encoded result when a model destroy call succeeds" do @result = stub 'result', :to_yaml => "the result" - @model_class.expects(:destroy).returns(@result) + @indirection.expects(:destroy).returns(@result) @handler.expects(:set_response).with { |response, body, status| body == "the result" } @@ -350,8 +352,9 @@ describe Puppet::Network::HTTP::Handler do @result = stub 'result', :render => "the result" - @model_instance = stub('indirected model instance', :save => true) + @model_instance = stub('indirected model instance') @model_class.stubs(:convert_from).returns(@model_instance) + @indirection.stubs(:save) @format = stub 'format', :suitable? => true, :name => "format", :mime => "text/format" Puppet::Network::FormatHandler.stubs(:format).returns @format @@ -377,7 +380,7 @@ describe Puppet::Network::HTTP::Handler do end it "should use a common method for determining the request parameters" do - @model_instance.expects(:save).with('key').once + @indirection.expects(:save).with(@model_instance, 'key').once @handler.do_save("my_handler", "key", {}, @request, @response) end @@ -387,7 +390,7 @@ describe Puppet::Network::HTTP::Handler do end it "should return the yaml-serialized result when a model save call succeeds" do - @model_instance.stubs(:save).returns(@model_instance) + @indirection.stubs(:save).returns(@model_instance) @model_instance.expects(:to_yaml).returns('foo') @handler.do_save("my_handler", "my_result", {}, @request, @response) end diff --git a/spec/unit/network/http/mongrel/rest_spec.rb b/spec/unit/network/http/mongrel/rest_spec.rb index 92a81a10b..42ba2d6c1 100755 --- a/spec/unit/network/http/mongrel/rest_spec.rb +++ b/spec/unit/network/http/mongrel/rest_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../../../spec_helper') require 'puppet/network/http' diff --git a/spec/unit/network/http/mongrel_spec.rb b/spec/unit/network/http/mongrel_spec.rb index ac3d72bae..573c75888 100755 --- a/spec/unit/network/http/mongrel_spec.rb +++ b/spec/unit/network/http/mongrel_spec.rb @@ -3,7 +3,7 @@ # Created by Rick Bradley on 2007-10-15. # Copyright (c) 2007. All rights reserved. -require File.dirname(__FILE__) + '/../../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') require 'puppet/network/http' describe "Puppet::Network::HTTP::Mongrel", "after initializing" do diff --git a/spec/unit/network/http/rack/rest_spec.rb b/spec/unit/network/http/rack/rest_spec.rb index 96cf84c37..31cba5950 100755 --- a/spec/unit/network/http/rack/rest_spec.rb +++ b/spec/unit/network/http/rack/rest_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../../../spec_helper') require 'puppet/network/http/rack' if Puppet.features.rack? require 'puppet/network/http/rack/rest' diff --git a/spec/unit/network/http/rack/xmlrpc_spec.rb b/spec/unit/network/http/rack/xmlrpc_spec.rb index 870438f2c..cc398bf32 100755 --- a/spec/unit/network/http/rack/xmlrpc_spec.rb +++ b/spec/unit/network/http/rack/xmlrpc_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../../../spec_helper') require 'puppet/network/handler' require 'puppet/network/http/rack' if Puppet.features.rack? require 'puppet/network/http/rack/xmlrpc' if Puppet.features.rack? diff --git a/spec/unit/network/http/rack_spec.rb b/spec/unit/network/http/rack_spec.rb index 8be9ccb50..66a845a72 100755 --- a/spec/unit/network/http/rack_spec.rb +++ b/spec/unit/network/http/rack_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') require 'puppet/network/handler' require 'puppet/network/http/rack' if Puppet.features.rack? diff --git a/spec/unit/network/http/webrick/rest_spec.rb b/spec/unit/network/http/webrick/rest_spec.rb index b00c62dc4..b1491e32e 100755 --- a/spec/unit/network/http/webrick/rest_spec.rb +++ b/spec/unit/network/http/webrick/rest_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../../../spec_helper') require 'puppet/network/http' require 'webrick' require 'puppet/network/http/webrick/rest' diff --git a/spec/unit/network/http/webrick_spec.rb b/spec/unit/network/http/webrick_spec.rb index 8e7c92b71..b27a941ea 100755 --- a/spec/unit/network/http/webrick_spec.rb +++ b/spec/unit/network/http/webrick_spec.rb @@ -3,7 +3,7 @@ # Created by Rick Bradley on 2007-10-15. # Copyright (c) 2007. All rights reserved. -require File.dirname(__FILE__) + '/../../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper') require 'puppet/network/handler' require 'puppet/network/http' require 'puppet/network/http/webrick' @@ -282,7 +282,7 @@ describe Puppet::Network::HTTP::WEBrick do @cert = stub 'cert', :content => "mycert" @host = stub 'host', :key => @key, :certificate => @cert, :name => "yay", :ssl_store => "mystore" - Puppet::SSL::Certificate.stubs(:find).with('ca').returns @cert + Puppet::SSL::Certificate.indirection.stubs(:find).with('ca').returns @cert Puppet::SSL::Host.stubs(:localhost).returns @host end @@ -299,7 +299,7 @@ describe Puppet::Network::HTTP::WEBrick do end it "should fail if no CA certificate can be found" do - Puppet::SSL::Certificate.stubs(:find).with('ca').returns nil + Puppet::SSL::Certificate.indirection.stubs(:find).with('ca').returns nil lambda { @server.setup_ssl }.should raise_error(Puppet::Error) end diff --git a/spec/unit/network/http_pool_spec.rb b/spec/unit/network/http_pool_spec.rb index 8fa7de8f9..2cd96cea4 100755 --- a/spec/unit/network/http_pool_spec.rb +++ b/spec/unit/network/http_pool_spec.rb @@ -3,7 +3,7 @@ # Created by Luke Kanies on 2007-11-26. # Copyright (c) 2007. All rights reserved. -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/network/http_pool' describe Puppet::Network::HttpPool do diff --git a/spec/unit/network/http_spec.rb b/spec/unit/network/http_spec.rb index e1d0d2269..8422e2113 100755 --- a/spec/unit/network/http_spec.rb +++ b/spec/unit/network/http_spec.rb @@ -3,7 +3,7 @@ # Created by Rick Bradley on 2007-10-03. # Copyright (c) 2007. All rights reserved. -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/network/http' diff --git a/spec/unit/network/rest_authconfig_spec.rb b/spec/unit/network/rest_authconfig_spec.rb index e81eb41ed..0479c4ea6 100755 --- a/spec/unit/network/rest_authconfig_spec.rb +++ b/spec/unit/network/rest_authconfig_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/network/rest_authconfig' @@ -17,7 +17,6 @@ describe Puppet::Network::RestAuthConfig do { :acl => "/certificate/", :method => :find, :authenticated => false }, { :acl => "/certificate_request", :method => [:find, :save], :authenticated => false }, { :acl => "/status", :method => [:find], :authenticated => true }, - { :acl => "/resource", :method => [:find, :save, :search], :authenticated => true }, ] before :each do diff --git a/spec/unit/network/rights_spec.rb b/spec/unit/network/rights_spec.rb index 969fc189e..fedaae230 100755 --- a/spec/unit/network/rights_spec.rb +++ b/spec/unit/network/rights_spec.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/network/rights' diff --git a/spec/unit/network/server_spec.rb b/spec/unit/network/server_spec.rb index c2496dcca..2a63cd4ec 100755 --- a/spec/unit/network/server_spec.rb +++ b/spec/unit/network/server_spec.rb @@ -3,7 +3,7 @@ # Created by Rick Bradley on 2007-10-03. # Copyright (c) 2007. All rights reserved. -require File.dirname(__FILE__) + '/../../spec_helper' +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') require 'puppet/network/server' require 'puppet/network/handler' |
