diff options
| author | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-06 16:37:29 -0700 |
|---|---|---|
| committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-06 16:37:29 -0700 |
| commit | 91069f36bcfe5b67f2ef0189360d55b607438c92 (patch) | |
| tree | 66eebc03390c427db1a1579e7093b3e014edb012 /spec | |
| parent | f732d69552969698fdae7905284f01682bfd3441 (diff) | |
| parent | 27bd1adb7cc43bfdeb8fb941418cfce3a7f694ef (diff) | |
| download | puppet-91069f36bcfe5b67f2ef0189360d55b607438c92.tar.gz puppet-91069f36bcfe5b67f2ef0189360d55b607438c92.tar.xz puppet-91069f36bcfe5b67f2ef0189360d55b607438c92.zip | |
Merge branch 'bug/master/6972-setting-CA-location-for-cert-string-no-longer-works'
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/unit/application/certificate_spec.rb | 16 | ||||
| -rwxr-xr-x | spec/unit/application/string_base_spec.rb | 29 | ||||
| -rwxr-xr-x | spec/unit/string/certificate_spec.rb | 14 |
3 files changed, 50 insertions, 9 deletions
diff --git a/spec/unit/application/certificate_spec.rb b/spec/unit/application/certificate_spec.rb index 6666f54f7..3d2215ded 100755 --- a/spec/unit/application/certificate_spec.rb +++ b/spec/unit/application/certificate_spec.rb @@ -4,13 +4,17 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') require 'puppet/application/certificate' describe Puppet::Application::Certificate do - it "should be a subclass of Puppet::Application::IndirectionBase" do - Puppet::Application::Certificate.superclass.should equal( - Puppet::Application::IndirectionBase - ) + it "should have a 'ca-location' option" do + # REVISIT: This is delegated from the string, and we will have a test + # there, so is this actually a valuable test? + subject.command_line.stubs(:args).returns %w{list} + subject.preinit + subject.should respond_to(:handle_ca_location) end - it "should have a 'ca' option" do - Puppet::Application::Certificate.new.should respond_to(:handle_ca_location) + it "should accept the ca-location option" do + subject.command_line.stubs(:args).returns %w{--ca-location local list} + subject.preinit and subject.parse_options and subject.setup + subject.arguments.should == [{ :ca_location => "local" }] end end diff --git a/spec/unit/application/string_base_spec.rb b/spec/unit/application/string_base_spec.rb index cd24b6c49..3f8ae73b6 100755 --- a/spec/unit/application/string_base_spec.rb +++ b/spec/unit/application/string_base_spec.rb @@ -42,6 +42,15 @@ describe Puppet::Application::StringBase do app end + describe "#find_global_settings_argument" do + it "should not match --ca to --ca-location" do + option = mock('ca option', :optparse_args => ["--ca"]) + Puppet.settings.expects(:each).yields(:ca, option) + + app.find_global_settings_argument("--ca-location").should be_nil + end + end + describe "#preinit" do before :each do app.command_line.stubs(:args).returns %w{} @@ -118,6 +127,26 @@ describe Puppet::Application::StringBase do expect { app.preinit }. should raise_error ArgumentError, /Unknown option "--bar"/ end + + { "boolean options before" => %w{--trace foo}, + "boolean options after" => %w{foo --trace} + }.each do |name, args| + it "should accept global boolean settings #{name} the action" do + app.command_line.stubs(:args).returns args + app.preinit && app.parse_options + Puppet[:trace].should be_true + end + end + + { "before" => %w{--syslogfacility user1 foo}, + " after" => %w{foo --syslogfacility user1} + }.each do |name, args| + it "should accept global settings with arguments #{name} the action" do + app.command_line.stubs(:args).returns args + app.preinit && app.parse_options + Puppet[:syslogfacility].should == "user1" + end + end end end diff --git a/spec/unit/string/certificate_spec.rb b/spec/unit/string/certificate_spec.rb index f6d53688b..9fdc5aab8 100755 --- a/spec/unit/string/certificate_spec.rb +++ b/spec/unit/string/certificate_spec.rb @@ -1,6 +1,14 @@ -#!/usr/bin/env ruby - -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb') +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 "#6983: This is broken in the actual string..." + Puppet::SSL::Host.expects(:ca_location=).with(:foo) + Puppet::SSL::Host.indirection.expects(:save) + subject.sign :ca_location => :foo + end end |
