diff --git a/lib/puppet/string/certificate.rb b/lib/puppet/string/certificate.rb index fdb0bc9f4..e8773ae2e 100644 --- a/lib/puppet/string/certificate.rb +++ b/lib/puppet/string/certificate.rb @@ -1,47 +1,46 @@ require 'puppet/string/indirector' require 'puppet/ssl/host' Puppet::String::Indirector.define(:certificate, '0.0.1') do # REVISIT: This should use a pre-invoke hook to run the common code that # needs to happen before we invoke any action; that would be much nicer than # the "please repeat yourself" stuff found in here right now. # # option "--ca-location LOCATION" do # type [:whatever, :location, :symbols] # hook :before do |value| # Puppet::SSL::Host.ca_location = value # end # end # # ...but should I pass the arguments as well? # --daniel 2011-04-05 option "--ca-location LOCATION" action :generate do when_invoked do |name, options| Puppet::SSL::Host.ca_location = options[:ca_location].to_sym host = Puppet::SSL::Host.new(name) host.generate_certificate_request host.certificate_request.class.indirection.save(host.certificate_request) end end action :list do when_invoked do |options| Puppet::SSL::Host.ca_location = options[:ca_location].to_sym Puppet::SSL::Host.indirection.search("*", { :for => :certificate_request, }).map { |h| h.inspect } end end action :sign do when_invoked do |name, options| Puppet::SSL::Host.ca_location = options[:ca_location].to_sym host = Puppet::SSL::Host.new(name) host.desired_state = 'signed' Puppet::SSL::Host.indirection.save(host) end end - end diff --git a/spec/unit/string/certificate_spec.rb b/spec/unit/string/certificate_spec.rb index 4afd581bf..9fdc5aab8 100755 --- a/spec/unit/string/certificate_spec.rb +++ b/spec/unit/string/certificate_spec.rb @@ -1,14 +1,14 @@ require 'puppet/ssl/host' describe Puppet::String[:certificate, '0.0.1'] do it "should have a ca-location option" do subject.should be_option :ca_location end it "should set the ca location when invoked" do - pending "The string itself is broken in this release." + pending "#6983: This is broken in the actual string..." Puppet::SSL::Host.expects(:ca_location=).with(:foo) - Puppet::SSL::Host.indirection.expects(:search) - subject.list :ca_location => :foo + Puppet::SSL::Host.indirection.expects(:save) + subject.sign :ca_location => :foo end end