diff options
-rw-r--r-- | lib/puppet/network/http/mongrel.rb | 9 | ||||
-rw-r--r-- | lib/puppet/network/http/mongrel/rest.rb | 4 | ||||
-rw-r--r-- | lib/puppet/network/http/mongrel/xmlrpc.rb | 4 | ||||
-rw-r--r-- | lib/puppet/network/http/webrick.rb | 10 | ||||
-rw-r--r-- | lib/puppet/network/http/webrick/rest.rb | 4 | ||||
-rw-r--r-- | lib/puppet/network/http/webrick/xmlrpc.rb | 4 | ||||
-rw-r--r-- | spec/unit/network/http/mongrel.rb | 15 | ||||
-rw-r--r-- | spec/unit/network/http/webrick.rb | 14 |
8 files changed, 55 insertions, 9 deletions
diff --git a/lib/puppet/network/http/mongrel.rb b/lib/puppet/network/http/mongrel.rb index 5b14d93c9..3efc465ad 100644 --- a/lib/puppet/network/http/mongrel.rb +++ b/lib/puppet/network/http/mongrel.rb @@ -1,4 +1,6 @@ require 'mongrel' +require 'puppet/network/http/mongrel/rest' +require 'puppet/network/http/mongrel/xmlrpc' class Puppet::Network::HTTP::Mongrel def initialize(args = {}) @@ -44,9 +46,8 @@ class Puppet::Network::HTTP::Mongrel # TODO/FIXME: need a spec which forces delegation to the real class def class_for_protocol(protocol) - Class.new do - def initialize(args = {}) - end - end + return Puppet::Network::HTTP::MongrelREST if protocol.to_sym == :rest + return Puppet::Network::HTTP::MongrelXMLRPC if protocol.to_sym == :xmlrpc + raise ArgumentError, "Unknown protocol [#{protocol}]." end end diff --git a/lib/puppet/network/http/mongrel/rest.rb b/lib/puppet/network/http/mongrel/rest.rb new file mode 100644 index 000000000..6e454c7d9 --- /dev/null +++ b/lib/puppet/network/http/mongrel/rest.rb @@ -0,0 +1,4 @@ +class Puppet::Network::HTTP::MongrelREST + def initialize(args = {}) + end +end diff --git a/lib/puppet/network/http/mongrel/xmlrpc.rb b/lib/puppet/network/http/mongrel/xmlrpc.rb new file mode 100644 index 000000000..92acd4f0e --- /dev/null +++ b/lib/puppet/network/http/mongrel/xmlrpc.rb @@ -0,0 +1,4 @@ +class Puppet::Network::HTTP::MongrelXMLRPC + def initialize(args = {}) + end +end diff --git a/lib/puppet/network/http/webrick.rb b/lib/puppet/network/http/webrick.rb index 474f66e4f..6df7804c6 100644 --- a/lib/puppet/network/http/webrick.rb +++ b/lib/puppet/network/http/webrick.rb @@ -1,5 +1,7 @@ require 'webrick' require 'webrick/https' +require 'puppet/network/http/webrick/rest' +require 'puppet/network/http/webrick/xmlrpc' class Puppet::Network::HTTP::WEBrick def initialize(args = {}) @@ -46,11 +48,9 @@ class Puppet::Network::HTTP::WEBrick end end - # TODO/FIXME: need a spec which forces delegation to the real class def class_for_protocol(protocol) - Class.new do - def initialize(args = {}) - end - end + return Puppet::Network::HTTP::WEBrickREST if protocol.to_sym == :rest + return Puppet::Network::HTTP::WEBrickXMLRPC if protocol.to_sym == :xmlrpc + raise ArgumentError, "Unknown protocol [#{protocol}]." end end diff --git a/lib/puppet/network/http/webrick/rest.rb b/lib/puppet/network/http/webrick/rest.rb new file mode 100644 index 000000000..5e9ccfc45 --- /dev/null +++ b/lib/puppet/network/http/webrick/rest.rb @@ -0,0 +1,4 @@ +class Puppet::Network::HTTP::WEBrickREST + def initialize(args = {}) + end +end
\ No newline at end of file diff --git a/lib/puppet/network/http/webrick/xmlrpc.rb b/lib/puppet/network/http/webrick/xmlrpc.rb new file mode 100644 index 000000000..793708f8a --- /dev/null +++ b/lib/puppet/network/http/webrick/xmlrpc.rb @@ -0,0 +1,4 @@ +class Puppet::Network::HTTP::WEBrickXMLRPC + def initialize(args = {}) + end +end diff --git a/spec/unit/network/http/mongrel.rb b/spec/unit/network/http/mongrel.rb index 0990a42d0..161080109 100644 --- a/spec/unit/network/http/mongrel.rb +++ b/spec/unit/network/http/mongrel.rb @@ -73,6 +73,21 @@ describe Puppet::Network::HTTP::Mongrel, "when turning on listening" do end @server.listen(@listen_params) end + + it "should use a Mongrel + REST class to configure Mongrel when REST services are requested" do + Puppet::Network::HTTP::MongrelREST.expects(:new).at_least_once + @server.listen(@listen_params.merge(:protocols => [:rest])) + end + + it "should use a Mongrel + XMLRPC class to configure Mongrel when XMLRPC services are requested" do + Puppet::Network::HTTP::MongrelXMLRPC.expects(:new).at_least_once + @server.listen(@listen_params.merge(:protocols => [:xmlrpc])) + 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(ArgumentError) + end + end describe Puppet::Network::HTTP::Mongrel, "when turning off listening" do diff --git a/spec/unit/network/http/webrick.rb b/spec/unit/network/http/webrick.rb index 4d914dc76..81b2a0fa9 100644 --- a/spec/unit/network/http/webrick.rb +++ b/spec/unit/network/http/webrick.rb @@ -73,6 +73,20 @@ describe Puppet::Network::HTTP::WEBrick, "when turning on listening" do end @server.listen(@listen_params) end + + it "should use a WEBrick + REST class to configure WEBrick when REST services are requested" do + Puppet::Network::HTTP::WEBrickREST.expects(:new).at_least_once + @server.listen(@listen_params.merge(:protocols => [:rest])) + end + + it "should use a WEBrick + XMLRPC class to configure WEBrick when XMLRPC services are requested" do + Puppet::Network::HTTP::WEBrickXMLRPC.expects(:new).at_least_once + @server.listen(@listen_params.merge(:protocols => [:xmlrpc])) + 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(ArgumentError) + end end describe Puppet::Network::HTTP::WEBrick, "when turning off listening" do |