puppet 3.6.1-x86-mingw32 → 3.6.2-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (38) hide show
  1. checksums.yaml +7 -0
  2. data/bin/puppet +4 -0
  3. data/ext/debian/puppetmaster-passenger.postinst +91 -41
  4. data/ext/rack/example-passenger-vhost.conf +4 -0
  5. data/lib/puppet/configurer/downloader.rb +3 -3
  6. data/lib/puppet/configurer/plugin_handler.rb +2 -1
  7. data/lib/puppet/defaults.rb +22 -3
  8. data/lib/puppet/indirector/facts/facter.rb +1 -1
  9. data/lib/puppet/network/http/webrick/rest.rb +9 -2
  10. data/lib/puppet/node/environment.rb +2 -0
  11. data/lib/puppet/parser/ast.rb +0 -1
  12. data/lib/puppet/parser/ast/collexpr.rb +1 -1
  13. data/lib/puppet/parser/functions.rb +26 -13
  14. data/lib/puppet/parser/resource.rb +11 -0
  15. data/lib/puppet/resource/catalog.rb +5 -2
  16. data/lib/puppet/settings.rb +53 -16
  17. data/lib/puppet/settings/array_setting.rb +17 -0
  18. data/lib/puppet/settings/base_setting.rb +22 -1
  19. data/lib/puppet/transaction.rb +1 -1
  20. data/lib/puppet/type/user.rb +4 -3
  21. data/lib/puppet/util/logging.rb +1 -0
  22. data/lib/puppet/util/tagging.rb +7 -6
  23. data/lib/puppet/version.rb +1 -1
  24. data/spec/integration/parser/compiler_spec.rb +28 -0
  25. data/spec/integration/parser/future_compiler_spec.rb +29 -0
  26. data/spec/integration/type/user_spec.rb +31 -0
  27. data/spec/unit/configurer/downloader_spec.rb +67 -35
  28. data/spec/unit/configurer/plugin_handler_spec.rb +1 -1
  29. data/spec/unit/indirector/facts/facter_spec.rb +2 -2
  30. data/spec/unit/node/environment_spec.rb +36 -0
  31. data/spec/unit/parser/functions_spec.rb +1 -4
  32. data/spec/unit/settings/array_setting_spec.rb +39 -0
  33. data/spec/unit/settings_spec.rb +69 -76
  34. data/spec/unit/type/user_spec.rb +13 -6
  35. data/spec/unit/util/logging_spec.rb +6 -0
  36. data/spec/unit/util/tagging_spec.rb +31 -0
  37. metadata +3131 -3163
  38. data/lib/puppet/parser/ast/tag.rb +0 -24
@@ -184,11 +184,14 @@ class Puppet::Resource::Catalog < Puppet::Graph::SimpleGraph
184
184
  # The relationship_graph form of the catalog. This contains all of the
185
185
  # dependency edges that are used for determining order.
186
186
  #
187
+ # @param given_prioritizer [Puppet::Graph::Prioritizer] The prioritization
188
+ # strategy to use when constructing the relationship graph. Defaults the
189
+ # being determined by the `ordering` setting.
187
190
  # @return [Puppet::Graph::RelationshipGraph]
188
191
  # @api public
189
- def relationship_graph
192
+ def relationship_graph(given_prioritizer = nil)
190
193
  if @relationship_graph.nil?
191
- @relationship_graph = Puppet::Graph::RelationshipGraph.new(prioritizer)
194
+ @relationship_graph = Puppet::Graph::RelationshipGraph.new(given_prioritizer || prioritizer)
192
195
  @relationship_graph.populate_from(self)
193
196
  end
194
197
  @relationship_graph
@@ -11,6 +11,7 @@ class Puppet::Settings
11
11
  require 'puppet/settings/base_setting'
12
12
  require 'puppet/settings/string_setting'
13
13
  require 'puppet/settings/enum_setting'
14
+ require 'puppet/settings/array_setting'
14
15
  require 'puppet/settings/file_setting'
15
16
  require 'puppet/settings/directory_setting'
16
17
  require 'puppet/settings/file_or_directory_setting'
@@ -93,6 +94,8 @@ class Puppet::Settings
93
94
  @used = []
94
95
 
95
96
  @hooks_to_call_on_application_initialization = []
97
+ @deprecated_setting_names = []
98
+ @deprecated_settings_that_have_been_configured = []
96
99
 
97
100
  @translate = Puppet::Settings::ValueTranslator.new
98
101
  @config_file_parser = Puppet::Settings::ConfigFile.new(@translate)
@@ -109,7 +112,9 @@ class Puppet::Settings
109
112
  # @return [Object] the value of the setting
110
113
  # @api private
111
114
  def [](param)
112
- Puppet.deprecation_warning("Accessing '#{param}' as a setting is deprecated. See http://links.puppetlabs.com/env-settings-deprecations") if DEPRECATED_SETTINGS.include?(param)
115
+ if @deprecated_setting_names.include?(param)
116
+ issue_deprecation_warning(setting(param), "Accessing '#{param}' as a setting is deprecated.")
117
+ end
113
118
  value(param)
114
119
  end
115
120
 
@@ -118,7 +123,9 @@ class Puppet::Settings
118
123
  # @param value [Object] the new value of the setting
119
124
  # @api private
120
125
  def []=(param, value)
121
- Puppet.deprecation_warning("Modifying '#{param}' as a setting is deprecated. See http://links.puppetlabs.com/env-settings-deprecations") if DEPRECATED_SETTINGS.include?(param)
126
+ if @deprecated_setting_names.include?(param)
127
+ issue_deprecation_warning(setting(param), "Modifying '#{param}' as a setting is deprecated.")
128
+ end
122
129
  @value_sets[:memory].set(param, value)
123
130
  unsafe_flush_cache
124
131
  end
@@ -315,6 +322,7 @@ class Puppet::Settings
315
322
  end
316
323
  apply_metadata
317
324
  call_hooks_deferred_to_application_initialization
325
+ issue_deprecations
318
326
 
319
327
  @app_defaults_initialized = true
320
328
  end
@@ -392,8 +400,8 @@ class Puppet::Settings
392
400
  end
393
401
  end
394
402
 
395
- if FULLY_DEPRECATED_SETTINGS.include?(str)
396
- Puppet.deprecation_warning("Setting #{str} is deprecated. See http://links.puppetlabs.com/env-settings-deprecations", "setting-#{str}")
403
+ if s = @config[str]
404
+ @deprecated_settings_that_have_been_configured << s if s.completely_deprecated?
397
405
  end
398
406
 
399
407
  @value_sets[:cli].set(str, value)
@@ -533,7 +541,7 @@ class Puppet::Settings
533
541
  # If we get here and don't have any data, we just return and don't muck with the current state of the world.
534
542
  return if data.nil?
535
543
 
536
- issue_deprecations(data)
544
+ record_deprecations_from_puppet_conf(data)
537
545
 
538
546
  # If we get here then we have some data, so we need to clear out any previous settings that may have come from
539
547
  # config files.
@@ -656,6 +664,7 @@ class Puppet::Settings
656
664
  :terminus => TerminusSetting,
657
665
  :duration => DurationSetting,
658
666
  :ttl => TTLSetting,
667
+ :array => ArraySetting,
659
668
  :enum => EnumSetting,
660
669
  :priority => PrioritySetting,
661
670
  :autosign => AutosignSetting,
@@ -863,6 +872,8 @@ class Puppet::Settings
863
872
  @hooks_to_call_on_application_initialization << tryconfig
864
873
  end
865
874
  end
875
+
876
+ @deprecated_setting_names << name if tryconfig.deprecated?
866
877
  end
867
878
 
868
879
  call.each do |setting|
@@ -1053,24 +1064,50 @@ Generated on #{Time.now}.
1053
1064
 
1054
1065
  private
1055
1066
 
1056
- DEPRECATED_ENVIRONMENT_SETTINGS = [:manifest, :modulepath, :config_version].freeze
1057
- FULLY_DEPRECATED_SETTINGS = [:templatedir, :manifestdir].freeze
1058
- DEPRECATED_SETTINGS = (DEPRECATED_ENVIRONMENT_SETTINGS + FULLY_DEPRECATED_SETTINGS).freeze
1067
+ DEPRECATION_REFS = {
1068
+ [:manifest, :modulepath, :config_version, :templatedir, :manifestdir] =>
1069
+ "See http://links.puppetlabs.com/env-settings-deprecations"
1070
+ }.freeze
1059
1071
 
1060
- def issue_deprecations(data)
1061
- sections = data.sections.inject([]) do |accum,entry|
1072
+ # Record that we want to issue a deprecation warning later in the application
1073
+ # initialization cycle when we have settings bootstrapped to the point where
1074
+ # we can read the Puppet[:disable_warnings] setting.
1075
+ #
1076
+ # We are only recording warnings applicable to settings set in puppet.conf
1077
+ # itself.
1078
+ def record_deprecations_from_puppet_conf(puppet_conf)
1079
+ conf_sections = puppet_conf.sections.inject([]) do |accum,entry|
1062
1080
  accum << entry[1] if [:main, :master, :agent, :user].include?(entry[0])
1063
1081
  accum
1064
1082
  end
1065
1083
 
1066
- sections.each do |section|
1067
- DEPRECATED_ENVIRONMENT_SETTINGS.each do |s|
1068
- Puppet.deprecation_warning("Setting #{s} is deprecated in puppet.conf. See http://links.puppetlabs.com/env-settings-deprecations", "puppet-conf-setting-#{s}") if !section.setting(s).nil?
1084
+ conf_sections.each do |section|
1085
+ section.settings.each do |conf_setting|
1086
+ if setting = self.setting(conf_setting.name)
1087
+ @deprecated_settings_that_have_been_configured << setting if setting.deprecated?
1088
+ end
1069
1089
  end
1090
+ end
1091
+ end
1070
1092
 
1071
- FULLY_DEPRECATED_SETTINGS.each do |s|
1072
- Puppet.deprecation_warning("Setting #{s} is deprecated. See http://links.puppetlabs.com/env-settings-deprecations", "setting-#{s}") if !section.setting(s).nil?
1073
- end
1093
+ def issue_deprecations
1094
+ @deprecated_settings_that_have_been_configured.each do |setting|
1095
+ issue_deprecation_warning(setting)
1096
+ end
1097
+ end
1098
+
1099
+ def issue_deprecation_warning(setting, msg = nil)
1100
+ name = setting.name
1101
+ ref = DEPRECATION_REFS.find { |params,reference| params.include?(name) }
1102
+ ref = ref[1] if ref
1103
+ case
1104
+ when msg
1105
+ msg << " #{ref}" if ref
1106
+ Puppet.deprecation_warning(msg)
1107
+ when setting.completely_deprecated?
1108
+ Puppet.deprecation_warning("Setting #{name} is deprecated. #{ref}", "setting-#{name}")
1109
+ when setting.allowed_on_commandline?
1110
+ Puppet.deprecation_warning("Setting #{name} is deprecated in puppet.conf. #{ref}", "puppet-conf-setting-#{name}")
1074
1111
  end
1075
1112
  end
1076
1113
 
@@ -0,0 +1,17 @@
1
+ class Puppet::Settings::ArraySetting < Puppet::Settings::BaseSetting
2
+
3
+ def type
4
+ :array
5
+ end
6
+
7
+ def munge(value)
8
+ case value
9
+ when String
10
+ value.split(/\s*,\s*/)
11
+ when Array
12
+ value
13
+ else
14
+ raise ArgumentError, "Expected an Array or String, got a #{value.class}"
15
+ end
16
+ end
17
+ end
@@ -3,7 +3,7 @@ require 'puppet/settings/errors'
3
3
  # The base setting type
4
4
  class Puppet::Settings::BaseSetting
5
5
  attr_accessor :name, :desc, :section, :default, :call_on_define, :call_hook
6
- attr_reader :short
6
+ attr_reader :short, :deprecated
7
7
 
8
8
  def self.available_call_hook_values
9
9
  [:on_define_and_write, :on_initialize_and_write, :on_write_only]
@@ -165,4 +165,25 @@ class Puppet::Settings::BaseSetting
165
165
  def set_meta(meta)
166
166
  Puppet.notice("#{name} does not support meta data. Ignoring.")
167
167
  end
168
+
169
+ def deprecated=(deprecation)
170
+ raise(ArgumentError, "'#{deprecation}' is an unknown setting deprecation state. Must be either :completely or :allowed_on_commandline") unless [:completely, :allowed_on_commandline].include?(deprecation)
171
+ @deprecated = deprecation
172
+ end
173
+
174
+ def deprecated?
175
+ !!@deprecated
176
+ end
177
+
178
+ # True if we should raise a deprecation_warning if the setting is submitted
179
+ # on the commandline or is set in puppet.conf.
180
+ def completely_deprecated?
181
+ @deprecated == :completely
182
+ end
183
+
184
+ # True if we should raise a deprecation_warning if the setting is found in
185
+ # puppet.conf, but not if the user sets it on the commandline
186
+ def allowed_on_commandline?
187
+ @deprecated == :allowed_on_commandline
188
+ end
168
189
  end
@@ -138,7 +138,7 @@ class Puppet::Transaction
138
138
  end
139
139
 
140
140
  def relationship_graph
141
- catalog.relationship_graph
141
+ catalog.relationship_graph(@prioritizer)
142
142
  end
143
143
 
144
144
  def resource_status(resource)
@@ -572,7 +572,7 @@ module Puppet
572
572
  defaultto false
573
573
  end
574
574
 
575
- def eval_generate
575
+ def generate
576
576
  return [] if self[:purge_ssh_keys].empty?
577
577
  find_unmanaged_keys
578
578
  end
@@ -639,7 +639,7 @@ module Puppet
639
639
  #
640
640
  # @return [Array<Puppet::Type::Ssh_authorized_key] a list of resources
641
641
  # representing the found keys
642
- # @see eval_generate
642
+ # @see generate
643
643
  # @api private
644
644
  def find_unmanaged_keys
645
645
  self[:purge_ssh_keys].
@@ -647,6 +647,7 @@ module Puppet
647
647
  map { |f| unknown_keys_in_file(f) }.
648
648
  flatten.each do |res|
649
649
  res[:ensure] = :absent
650
+ res[:user] = self[:name]
650
651
  @parameters.each do |name, param|
651
652
  res[name] = param.value if param.metaparam?
652
653
  end
@@ -657,7 +658,7 @@ module Puppet
657
658
  # on the keys. These are considered names of possible ssh_authorized_keys
658
659
  # resources. Keys that are managed by the present catalog are ignored.
659
660
  #
660
- # @see eval_generate
661
+ # @see generate
661
662
  # @api private
662
663
  # @return [Array<Puppet::Type::Ssh_authorized_key] a list of resources
663
664
  # representing the found keys
@@ -65,6 +65,7 @@ module Puppet::Util::Logging
65
65
  # @param [String] key Optional key to mark the message as unique. If not
66
66
  # passed in, the originating call line will be used instead.
67
67
  def deprecation_warning(message, key = nil)
68
+ return if Puppet[:disable_warnings].include?('deprecations')
68
69
  $deprecation_warnings ||= {}
69
70
  if $deprecation_warnings.length < 100 then
70
71
  key ||= (offender = get_deprecation_offender)
@@ -3,12 +3,14 @@ require 'puppet/util/tag_set'
3
3
  module Puppet::Util::Tagging
4
4
  ValidTagRegex = /^\w[-\w:.]*$/
5
5
 
6
- # Add a tag to our current list. These tags will be added to all
7
- # of the objects contained in this scope.
6
+ # Add a tag to the current tag set.
7
+ # When a tag set is used for a scope, these tags will be added to all of
8
+ # the objects contained in this scope when the objects are finished.
9
+ #
8
10
  def tag(*ary)
9
11
  @tags ||= new_tags
10
12
 
11
- ary.each do |tag|
13
+ ary.flatten.each do |tag|
12
14
  name = tag.to_s.downcase
13
15
  if name =~ ValidTagRegex
14
16
  @tags << name
@@ -16,12 +18,12 @@ module Puppet::Util::Tagging
16
18
  @tags << section
17
19
  end
18
20
  else
19
- fail(Puppet::ParseError, "Invalid tag #{name}")
21
+ fail(Puppet::ParseError, "Invalid tag '#{name}'")
20
22
  end
21
23
  end
22
24
  end
23
25
 
24
- # Are we tagged with the provided tag?
26
+ # Is the receiver tagged with the given tags?
25
27
  def tagged?(*tags)
26
28
  not ( self.tags & tags.flatten.collect { |t| t.to_s } ).empty?
27
29
  end
@@ -39,7 +41,6 @@ module Puppet::Util::Tagging
39
41
  return if tags.nil? or tags == ""
40
42
 
41
43
  tags = tags.strip.split(/\s*,\s*/) if tags.is_a?(String)
42
-
43
44
  tags.each {|t| tag(t) }
44
45
  end
45
46
 
@@ -7,7 +7,7 @@
7
7
 
8
8
 
9
9
  module Puppet
10
- PUPPETVERSION = '3.6.1'
10
+ PUPPETVERSION = '3.6.2'
11
11
 
12
12
  ##
13
13
  # version is a public API method intended to always provide a fast and
@@ -501,6 +501,34 @@ describe "Puppet::Parser::Compiler" do
501
501
  end
502
502
  end
503
503
  end
504
+
505
+ context 'when evaluating collection' do
506
+ it 'matches on container inherited tags' do
507
+ Puppet[:code] = <<-MANIFEST
508
+ class xport_test {
509
+ tag 'foo_bar'
510
+ @notify { 'nbr1':
511
+ message => 'explicitly tagged',
512
+ tag => 'foo_bar'
513
+ }
514
+
515
+ @notify { 'nbr2':
516
+ message => 'implicitly tagged'
517
+ }
518
+
519
+ Notify <| tag == 'foo_bar' |> {
520
+ message => 'overridden'
521
+ }
522
+ }
523
+ include xport_test
524
+ MANIFEST
525
+
526
+ catalog = Puppet::Parser::Compiler.compile(Puppet::Node.new("mynode"))
527
+
528
+ expect(catalog).to have_resource("Notify[nbr1]").with_parameter(:message, 'overridden')
529
+ expect(catalog).to have_resource("Notify[nbr2]").with_parameter(:message, 'overridden')
530
+ end
531
+ end
504
532
  end
505
533
 
506
534
  describe 'using classic parser' do
@@ -367,4 +367,33 @@ describe "Puppet::Parser::Compiler" do
367
367
  end
368
368
  end
369
369
  end
370
+
371
+ context 'when evaluating collection' do
372
+ it 'matches on container inherited tags' do
373
+ Puppet[:code] = <<-MANIFEST
374
+ class xport_test {
375
+ tag('foo_bar')
376
+ @notify { 'nbr1':
377
+ message => 'explicitly tagged',
378
+ tag => 'foo_bar'
379
+ }
380
+
381
+ @notify { 'nbr2':
382
+ message => 'implicitly tagged'
383
+ }
384
+
385
+ Notify <| tag == 'foo_bar' |> {
386
+ message => 'overridden'
387
+ }
388
+ }
389
+ include xport_test
390
+ MANIFEST
391
+
392
+ catalog = Puppet::Parser::Compiler.compile(Puppet::Node.new("mynode"))
393
+
394
+ expect(catalog).to have_resource("Notify[nbr1]").with_parameter(:message, 'overridden')
395
+ expect(catalog).to have_resource("Notify[nbr2]").with_parameter(:message, 'overridden')
396
+ end
397
+ end
398
+
370
399
  end
@@ -0,0 +1,31 @@
1
+ #! /usr/bin/env ruby
2
+ require 'spec_helper'
3
+ require 'puppet_spec/files'
4
+ require 'puppet_spec/compiler'
5
+
6
+ describe Puppet::Type.type(:user), '(integration)', :unless => Puppet.features.microsoft_windows? do
7
+ include PuppetSpec::Files
8
+ include PuppetSpec::Compiler
9
+
10
+ context "when set to purge ssh keys from a file" do
11
+ let(:tempfile) { file_containing('user_spec', "# comment\nssh-rsa KEY-DATA key-name") }
12
+ # must use an existing user, or the generated key resource
13
+ # will fail on account of an invalid user for the key
14
+ # - root should be a safe default
15
+ let(:manifest) { "user { 'root': purge_ssh_keys => '#{tempfile}' }" }
16
+
17
+ it "should purge authorized ssh keys" do
18
+ apply_compiled_manifest(manifest, Puppet::Graph::RandomPrioritizer.new)
19
+ File.read(tempfile).should_not =~ /key-name/
20
+ end
21
+
22
+ context "with other prefetching resources evaluated first" do
23
+ let(:manifest) { "host { 'test': before => User[root] } user { 'root': purge_ssh_keys => '#{tempfile}' }" }
24
+
25
+ it "should purge authorized ssh keys" do
26
+ apply_compiled_manifest(manifest, Puppet::Graph::RandomPrioritizer.new)
27
+ File.read(tempfile).should_not =~ /key-name/
28
+ end
29
+ end
30
+ end
31
+ end
@@ -6,6 +6,10 @@ require 'puppet/configurer/downloader'
6
6
  describe Puppet::Configurer::Downloader do
7
7
  require 'puppet_spec/files'
8
8
  include PuppetSpec::Files
9
+
10
+ let(:path) { Puppet[:plugindest] }
11
+ let(:source) { 'puppet://puppet/plugins' }
12
+
9
13
  it "should require a name" do
10
14
  lambda { Puppet::Configurer::Downloader.new }.should raise_error(ArgumentError)
11
15
  end
@@ -21,87 +25,115 @@ describe Puppet::Configurer::Downloader do
21
25
  dler.source.should == "source"
22
26
  end
23
27
 
24
- describe "when creating the file that does the downloading" do
25
- before do
26
- @dler = Puppet::Configurer::Downloader.new("foo", "path", "source")
27
- end
28
+ def downloader(options = {})
29
+ options[:name] ||= "facts"
30
+ options[:path] ||= path
31
+ options[:source_permissions] ||= :ignore
32
+ Puppet::Configurer::Downloader.new(options[:name], options[:path], source, options[:ignore], options[:environment], options[:source_permissions])
33
+ end
28
34
 
35
+ def generate_file_resource(options = {})
36
+ dler = downloader(options)
37
+ dler.file
38
+ end
39
+
40
+ describe "when creating the file that does the downloading" do
29
41
  it "should create a file instance with the right path and source" do
30
- Puppet::Type.type(:file).expects(:new).with { |opts| opts[:path] == "path" and opts[:source] == "source" }
31
- @dler.file
42
+ file = generate_file_resource(:path => path, :source => source)
43
+
44
+ expect(file[:path]).to eq(path)
45
+ expect(file[:source]).to eq([source])
32
46
  end
33
47
 
34
48
  it "should tag the file with the downloader name" do
35
- Puppet::Type.type(:file).expects(:new).with { |opts| opts[:tag] == "foo" }
36
- @dler.file
49
+ name = "mydownloader"
50
+ file = generate_file_resource(:name => name)
51
+
52
+ expect(file[:tag]).to eq([name])
37
53
  end
38
54
 
39
55
  it "should always recurse" do
40
- Puppet::Type.type(:file).expects(:new).with { |opts| opts[:recurse] == true }
41
- @dler.file
56
+ file = generate_file_resource
57
+
58
+ expect(file[:recurse]).to be_true
42
59
  end
43
60
 
44
61
  it "should always purge" do
45
- Puppet::Type.type(:file).expects(:new).with { |opts| opts[:purge] == true }
46
- @dler.file
62
+ file = generate_file_resource
63
+
64
+ expect(file[:purge]).to be_true
47
65
  end
48
66
 
49
67
  it "should never be in noop" do
50
- Puppet::Type.type(:file).expects(:new).with { |opts| opts[:noop] == false }
51
- @dler.file
68
+ file = generate_file_resource
69
+
70
+ expect(file[:noop]).to be_false
52
71
  end
53
72
 
54
- it "should set source_permissions to ignore" do
55
- Puppet::Type.type(:file).expects(:new).with { |opts| opts[:source_permissions] == :ignore }
56
- @dler.file
73
+ it "should set source_permissions to ignore by default" do
74
+ file = generate_file_resource
75
+
76
+ expect(file[:source_permissions]).to eq(:ignore)
77
+ end
78
+
79
+ it "should allow source_permissions to be overridden" do
80
+ file = generate_file_resource(:source_permissions => :use)
81
+
82
+ expect(file[:source_permissions]).to eq(:use)
57
83
  end
58
84
 
59
85
  describe "on POSIX", :as_platform => :posix do
60
86
  it "should always set the owner to the current UID" do
61
87
  Process.expects(:uid).returns 51
62
- Puppet::Type.type(:file).expects(:new).with { |opts| opts[:owner] == 51 }
63
- @dler.file
88
+
89
+ file = generate_file_resource(:path => '/path')
90
+ expect(file[:owner]).to eq(51)
64
91
  end
65
92
 
66
93
  it "should always set the group to the current GID" do
67
94
  Process.expects(:gid).returns 61
68
- Puppet::Type.type(:file).expects(:new).with { |opts| opts[:group] == 61 }
69
- @dler.file
95
+
96
+ file = generate_file_resource(:path => '/path')
97
+ expect(file[:group]).to eq(61)
70
98
  end
71
99
  end
72
100
 
73
101
  describe "on Windows", :as_platform => :windows do
74
102
  it "should omit the owner" do
75
- Puppet::Type.type(:file).expects(:new).with { |opts| opts[:owner] == nil }
76
- @dler.file
103
+ file = generate_file_resource(:path => 'C:/path')
104
+
105
+ expect(file[:owner]).to be_nil
77
106
  end
78
107
 
79
108
  it "should omit the group" do
80
- Puppet::Type.type(:file).expects(:new).with { |opts| opts[:group] == nil }
81
- @dler.file
109
+ file = generate_file_resource(:path => 'C:/path')
110
+
111
+ expect(file[:group]).to be_nil
82
112
  end
83
113
  end
84
114
 
85
115
  it "should always force the download" do
86
- Puppet::Type.type(:file).expects(:new).with { |opts| opts[:force] == true }
87
- @dler.file
116
+ file = generate_file_resource
117
+
118
+ expect(file[:force]).to be_true
88
119
  end
89
120
 
90
121
  it "should never back up when downloading" do
91
- Puppet::Type.type(:file).expects(:new).with { |opts| opts[:backup] == false }
92
- @dler.file
122
+ file = generate_file_resource
123
+
124
+ expect(file[:backup]).to be_false
93
125
  end
94
126
 
95
127
  it "should support providing an 'ignore' parameter" do
96
- Puppet::Type.type(:file).expects(:new).with { |opts| opts[:ignore] == [".svn"] }
97
- @dler = Puppet::Configurer::Downloader.new("foo", "path", "source", ".svn")
98
- @dler.file
128
+ file = generate_file_resource(:ignore => '.svn')
129
+
130
+ expect(file[:ignore]).to eq(['.svn'])
99
131
  end
100
132
 
101
133
  it "should split the 'ignore' parameter on whitespace" do
102
- Puppet::Type.type(:file).expects(:new).with { |opts| opts[:ignore] == %w{.svn CVS} }
103
- @dler = Puppet::Configurer::Downloader.new("foo", "path", "source", ".svn CVS")
104
- @dler.file
134
+ file = generate_file_resource(:ignore => '.svn CVS')
135
+
136
+ expect(file[:ignore]).to eq(['.svn', 'CVS'])
105
137
  end
106
138
  end
107
139