diff options
-rw-r--r-- | lib/puppet/application/cert.rb | 10 | ||||
-rwxr-xr-x[-rw-r--r--] | spec/unit/application/cert_spec.rb | 28 |
2 files changed, 19 insertions, 19 deletions
diff --git a/lib/puppet/application/cert.rb b/lib/puppet/application/cert.rb index 219129bb9..68d1f78fa 100644 --- a/lib/puppet/application/cert.rb +++ b/lib/puppet/application/cert.rb @@ -5,17 +5,17 @@ class Puppet::Application::Cert < Puppet::Application should_parse_config mode :server - attr_accessor :mode, :all, :ca, :digest, :signed + attr_accessor :cert_mode, :all, :ca, :digest, :signed def find_mode(opt) require 'puppet/ssl/certificate_authority' modes = Puppet::SSL::CertificateAuthority::Interface::INTERFACE_METHODS tmp = opt.sub("--", '').to_sym - @mode = modes.include?(tmp) ? tmp : nil + @cert_mode = modes.include?(tmp) ? tmp : nil end option("--clean", "-c") do - @mode = :destroy + @cert_mode = :destroy end option("--all", "-a") do @@ -54,8 +54,8 @@ class Puppet::Application::Cert < Puppet::Application hosts = command_line.args.collect { |h| puts h; h.downcase } end begin - @ca.apply(:revoke, :to => hosts) if @mode == :destroy - @ca.apply(@mode, :to => hosts, :digest => @digest) + @ca.apply(:revoke, :to => hosts) if @cert_mode == :destroy + @ca.apply(@cert_mode, :to => hosts, :digest => @digest) rescue => detail puts detail.backtrace if Puppet[:trace] puts detail.to_s diff --git a/spec/unit/application/cert_spec.rb b/spec/unit/application/cert_spec.rb index ba6ba1d2d..871c9d17d 100644..100755 --- a/spec/unit/application/cert_spec.rb +++ b/spec/unit/application/cert_spec.rb @@ -45,9 +45,9 @@ describe Puppet::Application::Cert do @cert_app.digest.should == :digest end - it "should set mode to :destroy for --clean" do + it "should set cert_mode to :destroy for --clean" do @cert_app.handle_clean(0) - @cert_app.mode.should == :destroy + @cert_app.cert_mode.should == :destroy end it "should set all to true for --all" do @@ -61,10 +61,10 @@ describe Puppet::Application::Cert do end Puppet::SSL::CertificateAuthority::Interface::INTERFACE_METHODS.reject { |m| m == :destroy }.each do |method| - it "should set mode to #{method} with option --#{method}" do + it "should set cert_mode to #{method} with option --#{method}" do @cert_app.send("handle_#{method}".to_sym, nil) - @cert_app.mode.should == method + @cert_app.cert_mode.should == method end end @@ -127,7 +127,7 @@ describe Puppet::Application::Cert do it "should delegate with :all if option --all was given" do @cert_app.handle_all(0) - @ca.expects(:apply).with { |mode,to| to[:to] == :all } + @ca.expects(:apply).with { |cert_mode,to| to[:to] == :all } @cert_app.main end @@ -135,7 +135,7 @@ describe Puppet::Application::Cert do it "should delegate to ca.apply with the hosts given on command line" do @cert_app.command_line.stubs(:args).returns(["host"]) - @ca.expects(:apply).with { |mode,to| to[:to] == ["host"]} + @ca.expects(:apply).with { |cert_mode,to| to[:to] == ["host"]} @cert_app.main end @@ -144,26 +144,26 @@ describe Puppet::Application::Cert do @cert_app.command_line.stubs(:args).returns(["host"]) @cert_app.handle_digest(:digest) - @ca.expects(:apply).with { |mode,to| to[:digest] == :digest} + @ca.expects(:apply).with { |cert_mode,to| to[:digest] == :digest} @cert_app.main end - it "should delegate to ca.apply with current set mode" do - @cert_app.mode = "currentmode" + it "should delegate to ca.apply with current set cert_mode" do + @cert_app.cert_mode = "currentmode" @cert_app.command_line.stubs(:args).returns(["host"]) - @ca.expects(:apply).with { |mode,to| mode == "currentmode" } + @ca.expects(:apply).with { |cert_mode,to| cert_mode == "currentmode" } @cert_app.main end - it "should revoke cert if mode is clean" do - @cert_app.mode = :destroy + it "should revoke cert if cert_mode is clean" do + @cert_app.cert_mode = :destroy @cert_app.command_line.stubs(:args).returns(["host"]) - @ca.expects(:apply).with { |mode,to| mode == :revoke } - @ca.expects(:apply).with { |mode,to| mode == :destroy } + @ca.expects(:apply).with { |cert_mode,to| cert_mode == :revoke } + @ca.expects(:apply).with { |cert_mode,to| cert_mode == :destroy } @cert_app.main end |