diff options
| author | Luke Kanies <luke@madstop.com> | 2009-03-19 23:58:19 -0500 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-03-20 18:27:08 +1100 |
| commit | 0179e945a7d402c90a333c8207243882af362e06 (patch) | |
| tree | e977d49f50c7907a67799bd8d445f833f9c823ee /spec/unit/network/http/webrick.rb | |
| parent | a497263d97229489dcc4341cc98ca3c75f116374 (diff) | |
| download | puppet-0179e945a7d402c90a333c8207243882af362e06.tar.gz puppet-0179e945a7d402c90a333c8207243882af362e06.tar.xz puppet-0179e945a7d402c90a333c8207243882af362e06.zip | |
Fixing #1557 - Environments are now in REST URIs
This commit includes multiple, related changes, all
in one commit because the whole thing was necessary to
reach a functional tree again:
* The URI starts with the environment, so:
/production/certificate/foo
/development/file_content/path/to/your/file
* All REST handling is done by a single instance mounted
at / for webrick and Mongrel, rather than having individual
instances mounted at, say, /certificate.
* All REST URI translation is done by an API module. Currently
only the 'v1' module exists with no support for additional modules,
but it's well-separated and will be easy to expand as we need it.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec/unit/network/http/webrick.rb')
| -rwxr-xr-x | spec/unit/network/http/webrick.rb | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/spec/unit/network/http/webrick.rb b/spec/unit/network/http/webrick.rb index e02d5c213..a6fbfc83f 100755 --- a/spec/unit/network/http/webrick.rb +++ b/spec/unit/network/http/webrick.rb @@ -20,9 +20,7 @@ describe Puppet::Network::HTTP::WEBrick, "when turning on listening" do WEBrick::HTTPServer.stubs(:new).returns(@mock_webrick) @server = Puppet::Network::HTTP::WEBrick.new [:setup_logger, :setup_ssl].each {|meth| @server.stubs(meth).returns({})} # the empty hash is required because of how we're merging - @listen_params = { :address => "127.0.0.1", :port => 31337, - :handlers => [ :node, :catalog ], :xmlrpc_handlers => [], :protocols => [ :rest ] - } + @listen_params = { :address => "127.0.0.1", :port => 31337, :xmlrpc_handlers => [], :protocols => [ :rest ] } end it "should fail if already listening" do @@ -30,10 +28,6 @@ describe Puppet::Network::HTTP::WEBrick, "when turning on listening" do Proc.new { @server.listen(@listen_params) }.should raise_error(RuntimeError) end - it "should require at least one handler" do - Proc.new { @server.listen(@listen_params.delete_if {|k,v| :handlers == k}) }.should raise_error(ArgumentError) - end - it "should require at least one protocol" do Proc.new { @server.listen(@listen_params.delete_if {|k,v| :protocols == k}) }.should raise_error(ArgumentError) end @@ -84,18 +78,11 @@ describe Puppet::Network::HTTP::WEBrick, "when turning on listening" do end describe "when the REST protocol is requested" do - it "should use a WEBrick + REST class to configure WEBrick" do - Puppet::Network::HTTP::WEBrick.expects(:class_for_protocol).with(:rest).at_least_once - @server.listen(@listen_params.merge(:protocols => [:rest])) - end + it "should register the REST handler at /" do + # We don't care about the options here. + @mock_webrick.expects(:mount).with { |path, klass, options| path == "/" and klass == Puppet::Network::HTTP::WEBrickREST } - it "should instantiate a handler for each protocol+handler pair to configure web server routing" do - @listen_params[:protocols].each do |protocol| - @listen_params[:handlers].each do |handler| - @mock_webrick.expects(:mount) - end - end - @server.listen(@listen_params) + @server.listen(@listen_params.merge(:protocols => [:rest])) end end @@ -150,10 +137,6 @@ describe Puppet::Network::HTTP::WEBrick, "when turning on listening" do @server.listen(@listen_params.merge(:protocols => [:xmlrpc], :xmlrpc_handlers => [:master, :fileserver])) end end - - it "should fail if services from an unknown protocol are requested" do - Proc.new { @server.listen(@listen_params.merge(:protocols => [ :foo ]))}.should raise_error - end end |
