The idea is that the network handler only need to include this module that will delegate to the correct auth plugin.
Signed-off-by: Brice Figureau <[email protected]> --- lib/puppet/auth/handler.rb | 4 ++++ lib/puppet/auth/handler/mongrel/ssl.rb | 3 +++ spec/unit/auth/handler_spec.rb | 25 +++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 0 deletions(-) create mode 100644 lib/puppet/auth/handler/mongrel/ssl.rb create mode 100644 spec/unit/auth/handler_spec.rb diff --git a/lib/puppet/auth/handler.rb b/lib/puppet/auth/handler.rb index 25ac450..db6cd05 100644 --- a/lib/puppet/auth/handler.rb +++ b/lib/puppet/auth/handler.rb @@ -1,3 +1,7 @@ module Puppet::Auth::Handler + def self.included(mod) + type = mod.name.sub(/Puppet::Network::HTTP::(.*)REST/, '\1').downcase + mod.send(:include, Puppet::Auth::handler(type)) + end end \ No newline at end of file diff --git a/lib/puppet/auth/handler/mongrel/ssl.rb b/lib/puppet/auth/handler/mongrel/ssl.rb new file mode 100644 index 0000000..907540d --- /dev/null +++ b/lib/puppet/auth/handler/mongrel/ssl.rb @@ -0,0 +1,3 @@ + +Puppet::Auth.new_handler(:ssl, :mongrel) do +end \ No newline at end of file diff --git a/spec/unit/auth/handler_spec.rb b/spec/unit/auth/handler_spec.rb new file mode 100644 index 0000000..1c07dc1 --- /dev/null +++ b/spec/unit/auth/handler_spec.rb @@ -0,0 +1,25 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../spec_helper' + +require 'puppet/auth' +require 'puppet/auth/handler' +require 'puppet/network/http' + +class Puppet::Network::HTTP::MongrelREST +end + +describe Puppet::Auth::Handler do + describe "when included" do + it "should include the correct sub-handler" do + handler = Class.new() do + def self.name + "Puppet::Network::HTTP::MongrelREST" + end + end + handler.send(:include, Puppet::Auth::Handler) + + handler.should be_include(Puppet::Auth::MongrelSsl) + end + end +end \ No newline at end of file -- 1.7.2.1 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
