rspec-puppet 2.6.11 → 2.6.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 07a2692f77f3f92e4102c513cfafdc76c448b244
4
- data.tar.gz: adb38bf5c070207481b7c57de83f2fee7b467aad
3
+ metadata.gz: d8b38203076b16e77839a929ceecfc693389fa5c
4
+ data.tar.gz: ea68533700285fe1fc3177e96f1552007b1e098b
5
5
  SHA512:
6
- metadata.gz: b7d43a327f6d8756fafcf5f5826a1e61d5f1e0fbe563114dd1f2008162581facc43e01b30176383471b5a773257e86c5b2380eb170b4ef40f11ad2d16b35a55a
7
- data.tar.gz: 471744fbf1af0df7c91d62131fbd421276786e0a8be81e3f70fb885dc7d98963ce7888eb73645e154c4bf3c40cd7974419eb10d5608e8fd9c020f20193875a9a
6
+ metadata.gz: 20dfed8bed477dce75a21d4ba98c41f50e9ba779d44c3c8838eb77b95da69e6430cf56cf57766afc0a253ed0880d4c726e59b4e09d4db08005aa0c49a4efacb7
7
+ data.tar.gz: cbb9f00b6e90493b5934e5cb3acb3cb43ac8ed92e4d9c04e11012aea829beed0b19eedbd8795015d15cb51158016717d35f55a6a07aeb4e2dd9422e1e26810a8
@@ -2,6 +2,35 @@
2
2
  All notable changes to this project will be documented in this file. This
3
3
  project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ## [2.6.12]
6
+
7
+ ### Fixed
8
+
9
+ * Updated `Win32::TaskScheduler` stubs to match the latest release of
10
+ `win32-taskscheduler`.
11
+ * The `os` structured fact is now correctly treated as a Hash when determining
12
+ the platform that rspec-puppet pretends to be.
13
+ * The default resources that Puppet adds to the catalogue (`Class[main]`,
14
+ `Class[Settings]`, etc) are now filtered out of the catalogue when using the
15
+ `have_resource_count` matcher, rather than simply subtracted from the
16
+ resource count. This allows the `have_resource_count` matcher to be used on
17
+ subsects of the catalogue (`exported_resources` for example).
18
+ * When running on Windows, rspec-puppet will now convert Puppet configuration
19
+ settings from `/dev/null` to `NUL`, preventing Puppet from automatically
20
+ creating directories like `C:\dev` when running tests on Windows as an
21
+ Administrator.
22
+ * When overriding fact values, rspec-puppet will now assign the stub facts
23
+ a weight of 1000 to ensure that they override the generated fact values from
24
+ Facter 3.x.
25
+ * `Selinux.is_selinux_enabled` is now automatically stubbed to return 0 to
26
+ disable any SELinux related apply-time validation of resources.
27
+ * When testing against Puppet 3.x, rspec-puppet will now honour the
28
+ `RSpec.configuration.parser` value when determining the module name to set
29
+ up the fixture symlink.
30
+ * When testing for the absence of a parameter using `only_with(:parameter_name
31
+ => nil`), this will no longer incorrectly affect the expected parameter
32
+ count.
33
+
5
34
  ## [2.6.11]
6
35
 
7
36
  ### Fixed
@@ -32,17 +32,17 @@ end
32
32
  require 'rspec-puppet/monkey_patches'
33
33
 
34
34
  RSpec.configure do |c|
35
- c.add_setting :environmentpath, :default => '/etc/puppetlabs/code/environments'
35
+ c.add_setting :environmentpath, :default => Puppet::Util::Platform.actually_windows? ? 'c:/nul/' : '/dev/null'
36
36
  c.add_setting :module_path, :default => nil
37
37
  c.add_setting :manifest_dir, :default => nil
38
38
  c.add_setting :manifest, :default => nil
39
39
  c.add_setting :template_dir, :default => nil
40
40
  c.add_setting :config, :default => nil
41
- c.add_setting :confdir, :default => '/etc/puppet'
41
+ c.add_setting :confdir, :default => Puppet::Util::Platform.actually_windows? ? 'c:/nul/' : '/dev/null'
42
42
  c.add_setting :default_facts, :default => {}
43
43
  c.add_setting :default_node_params, :default => {}
44
44
  c.add_setting :default_trusted_facts, :default => {}
45
- c.add_setting :hiera_config, :default => '/dev/null'
45
+ c.add_setting :hiera_config, :default => Puppet::Util::Platform.actually_windows? ? 'c:/nul/' : '/dev/null'
46
46
  c.add_setting :parser, :default => 'current'
47
47
  c.add_setting :trusted_node_data, :default => false
48
48
  c.add_setting :ordering, :default => 'title-hash'
@@ -120,6 +120,7 @@ RSpec.configure do |c|
120
120
  if RSpec::Puppet.rspec_puppet_example?
121
121
  Puppet::Util::Platform.pretend_to_be RSpec.configuration.platform
122
122
  stub_file_consts(example) if self.respond_to?(:stub_file_consts)
123
+ allow(Selinux).to receive(:is_selinux_enabled).and_return(0) if defined?(Selinux)
123
124
  end
124
125
  end
125
126
 
@@ -47,6 +47,7 @@ module RSpec::Puppet
47
47
  default_hash.merge!(Puppet::Test::TestHelper.send(:app_defaults_for_tests))
48
48
  end
49
49
  settings_hash = default_hash.merge(Hash[*settings])
50
+ settings_hash.inject(settings_hash) { |h, (k, v)| h[k] = (v == '/dev/null') ? 'c:/nul/' : v; h } if Gem.win_platform?
50
51
 
51
52
  if Puppet.settings.respond_to?(:initialize_app_defaults)
52
53
  Puppet.settings.initialize_app_defaults(settings_hash)
@@ -1,6 +1,12 @@
1
1
  module RSpec::Puppet
2
2
  module ManifestMatchers
3
3
  class CountGeneric
4
+ DEFAULT_RESOURCES = [
5
+ 'Class[main]',
6
+ 'Class[Settings]',
7
+ 'Stage[main]',
8
+ ].freeze
9
+
4
10
  def initialize(type, count, *method)
5
11
  if type.nil?
6
12
  @type = method[0].to_s.gsub(/^have_(.+)_resource_count$/, '\1')
@@ -14,22 +20,20 @@ module RSpec::Puppet
14
20
  def matches?(catalogue)
15
21
  @catalogue = catalogue.call
16
22
 
17
- if @type == "resource"
18
- @actual_number = @catalogue.resources.count do |res|
19
- !(['Class', 'Node'].include? res.type)
20
- end
21
-
22
- # Puppet automatically adds Stage[main]
23
- @actual_number = @actual_number - 1
24
- else
25
- @actual_number = @catalogue.resources.count do |res|
26
- res.type == @referenced_type
27
- end
28
-
29
- # Puppet automatically adds Class[main] and Class[Settings]
30
- @actual_number = @actual_number - 2 if @type == "class"
23
+ resources = @catalogue.resources.reject do |res|
24
+ DEFAULT_RESOURCES.include?(res.ref)
31
25
  end
32
26
 
27
+ @actual_number = if @type == 'resource'
28
+ resources.count do |res|
29
+ !['Class', 'Node'].include?(res.type)
30
+ end
31
+ else
32
+ resources.count do |res|
33
+ res.type == @referenced_type
34
+ end
35
+ end
36
+
33
37
  @actual_number == @expected_number
34
38
  end
35
39
 
@@ -30,7 +30,7 @@ module RSpec::Puppet
30
30
 
31
31
  def only_with(*args, &block)
32
32
  params = args.shift
33
- @expected_params_count = (@expected_params_count || 0) + params.size
33
+ @expected_params_count = (@expected_params_count || 0) + params.select { |_, v| !v.nil? }.size
34
34
  self.with(params, &block)
35
35
  end
36
36
 
@@ -54,6 +54,7 @@ RSpec.configuration.reporter.register_listener(RSpec::Puppet::EventListener, :ex
54
54
 
55
55
  require 'rspec-puppet/monkey_patches/win32/taskscheduler'
56
56
  require 'rspec-puppet/monkey_patches/win32/registry'
57
+ require 'rspec-puppet/monkey_patches/windows/taskschedulerconstants'
57
58
 
58
59
  module Puppet
59
60
  # Allow rspec-puppet to prevent Puppet::Type from automatically picking
@@ -177,6 +178,11 @@ module Puppet
177
178
  end
178
179
  module_function :actual_platform
179
180
 
181
+ def actually_windows?
182
+ actual_platform == :windows
183
+ end
184
+ module_function :actually_windows?
185
+
180
186
  def pretend_windows?
181
187
  pretend_platform == :windows
182
188
  end
@@ -1,33 +1,37 @@
1
1
  # Create our dummy Win32::TaskScheduler with the consts defined from
2
2
  # https://github.com/djberg96/win32-taskscheduler/blob/ole/lib/win32/taskscheduler.rb
3
+
4
+ require 'rspec-puppet/monkey_patches/windows/taskschedulerconstants'
5
+
3
6
  module RSpec
4
7
  module Puppet
5
8
  module Win32
6
9
  class TaskScheduler
7
- TASK_TIME_TRIGGER_ONCE = 0
8
- TASK_TIME_TRIGGER_DAILY = 1
9
- TASK_TIME_TRIGGER_WEEKLY = 2
10
- TASK_TIME_TRIGGER_MONTHLYDATE = 3
11
- TASK_TIME_TRIGGER_MONTHLYDOW = 4
12
- TASK_EVENT_TRIGGER_ON_IDLE = 5
13
- TASK_EVENT_TRIGGER_AT_SYSTEMSTART = 6
14
- TASK_EVENT_TRIGGER_AT_LOGON = 7
10
+ include Windows::TaskSchedulerConstants
11
+
12
+ DAYS_IN_A_MONTH = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
13
+
14
+ IDLE = IDLE_PRIORITY_CLASS
15
+ NORMAL = NORMAL_PRIORITY_CLASS
16
+ HIGH = HIGH_PRIORITY_CLASS
17
+ REALTIME = REALTIME_PRIORITY_CLASS
18
+ BELOW_NORMAL = BELOW_NORMAL_PRIORITY_CLASS
19
+ ABOVE_NORMAL = ABOVE_NORMAL_PRIORITY_CLASS
20
+
15
21
  ONCE = TASK_TIME_TRIGGER_ONCE
16
22
  DAILY = TASK_TIME_TRIGGER_DAILY
17
23
  WEEKLY = TASK_TIME_TRIGGER_WEEKLY
18
24
  MONTHLYDATE = TASK_TIME_TRIGGER_MONTHLYDATE
19
25
  MONTHLYDOW = TASK_TIME_TRIGGER_MONTHLYDOW
26
+
20
27
  ON_IDLE = TASK_EVENT_TRIGGER_ON_IDLE
21
28
  AT_SYSTEMSTART = TASK_EVENT_TRIGGER_AT_SYSTEMSTART
22
29
  AT_LOGON = TASK_EVENT_TRIGGER_AT_LOGON
23
-
24
- TASK_SUNDAY = 0x1
25
- TASK_MONDAY = 0x2
26
- TASK_TUESDAY = 0x4
27
- TASK_WEDNESDAY = 0x8
28
- TASK_THURSDAY = 0x10
29
- TASK_FRIDAY = 0x20
30
- TASK_SATURDAY = 0x40
30
+ FIRST_WEEK = TASK_FIRST_WEEK
31
+ SECOND_WEEK = TASK_SECOND_WEEK
32
+ THIRD_WEEK = TASK_THIRD_WEEK
33
+ FOURTH_WEEK = TASK_FOURTH_WEEK
34
+ LAST_WEEK = TASK_LAST_WEEK
31
35
  SUNDAY = TASK_SUNDAY
32
36
  MONDAY = TASK_MONDAY
33
37
  TUESDAY = TASK_TUESDAY
@@ -35,30 +39,6 @@ module RSpec
35
39
  THURSDAY = TASK_THURSDAY
36
40
  FRIDAY = TASK_FRIDAY
37
41
  SATURDAY = TASK_SATURDAY
38
-
39
- TASK_FIRST_WEEK = 1
40
- TASK_SECOND_WEEK = 2
41
- TASK_THIRD_WEEK = 3
42
- TASK_FOURTH_WEEK = 4
43
- TASK_LAST_WEEK = 5
44
- FIRST_WEEK = TASK_FIRST_WEEK
45
- SECOND_WEEK = TASK_SECOND_WEEK
46
- THIRD_WEEK = TASK_THIRD_WEEK
47
- FOURTH_WEEK = TASK_FOURTH_WEEK
48
- LAST_WEEK = TASK_LAST_WEEK
49
-
50
- TASK_JANUARY = 0x1
51
- TASK_FEBRUARY = 0x2
52
- TASK_MARCH = 0x4
53
- TASK_APRIL = 0x8
54
- TASK_MAY = 0x10
55
- TASK_JUNE = 0x20
56
- TASK_JULY = 0x40
57
- TASK_AUGUST = 0x80
58
- TASK_SEPTEMBER = 0x100
59
- TASK_OCTOBER = 0x200
60
- TASK_NOVEMBER = 0x400
61
- TASK_DECEMBER = 0x800
62
42
  JANUARY = TASK_JANUARY
63
43
  FEBRUARY = TASK_FEBRUARY
64
44
  MARCH = TASK_MARCH
@@ -72,19 +52,6 @@ module RSpec
72
52
  NOVEMBER = TASK_NOVEMBER
73
53
  DECEMBER = TASK_DECEMBER
74
54
 
75
- TASK_FLAG_INTERACTIVE = 0x1
76
- TASK_FLAG_DELETE_WHEN_DONE = 0x2
77
- TASK_FLAG_DISABLED = 0x4
78
- TASK_FLAG_START_ONLY_IF_IDLE = 0x10
79
- TASK_FLAG_KILL_ON_IDLE_END = 0x20
80
- TASK_FLAG_DONT_START_IF_ON_BATTERIES = 0x40
81
- TASK_FLAG_KILL_IF_GOING_ON_BATTERIES = 0x80
82
- TASK_FLAG_RUN_ONLY_IF_DOCKED = 0x100
83
- TASK_FLAG_HIDDEN = 0x200
84
- TASK_FLAG_RUN_IF_CONNECTED_TO_INTERNET = 0x400
85
- TASK_FLAG_RESTART_ON_IDLE_RESUME = 0x800
86
- TASK_FLAG_SYSTEM_REQUIRED = 0x1000
87
- TASK_FLAG_RUN_ONLY_IF_LOGGED_ON = 0x2000
88
55
  INTERACTIVE = TASK_FLAG_INTERACTIVE
89
56
  DELETE_WHEN_DONE = TASK_FLAG_DELETE_WHEN_DONE
90
57
  DISABLED = TASK_FLAG_DISABLED
@@ -99,52 +66,44 @@ module RSpec
99
66
  SYSTEM_REQUIRED = TASK_FLAG_SYSTEM_REQUIRED
100
67
  RUN_ONLY_IF_LOGGED_ON = TASK_FLAG_RUN_ONLY_IF_LOGGED_ON
101
68
 
102
- TASK_TRIGGER_FLAG_HAS_END_DATE = 0x1
103
- TASK_TRIGGER_FLAG_KILL_AT_DURATION_END = 0x2
104
- TASK_TRIGGER_FLAG_DISABLED = 0x4
105
69
  FLAG_HAS_END_DATE = TASK_TRIGGER_FLAG_HAS_END_DATE
106
70
  FLAG_KILL_AT_DURATION_END = TASK_TRIGGER_FLAG_KILL_AT_DURATION_END
107
71
  FLAG_DISABLED = TASK_TRIGGER_FLAG_DISABLED
108
72
 
109
- TASK_MAX_RUN_TIMES = 1440
110
- TASKS_TO_RETRIEVE = 5
111
73
  MAX_RUN_TIMES = TASK_MAX_RUN_TIMES
112
74
 
113
- TASK_VALIDATE_ONLY = 0x1
114
- TASK_CREATE = 0x2
115
- TASK_UPDATE = 0x4
116
- TASK_CREATE_OR_UPDATE = 0x6
117
- TASK_DISABLE = 0x8
118
- TASK_DONT_ADD_PRINCIPAL_ACE = 0x10
119
- TASK_IGNORE_REGISTRATION_TRIGGERS = 0x20
120
-
121
- TASK_LOGON_NONE = 0
122
- TASK_LOGON_PASSWORD = 1
123
- TASK_LOGON_S4U = 2
124
- TASK_LOGON_INTERACTIVE_TOKEN = 3
125
- TASK_LOGON_GROUP = 4
126
- TASK_LOGON_SERVICE_ACCOUNT = 5
127
- TASK_LOGON_INTERACTIVE_TOKEN_OR_PASSWORD = 6
128
-
129
- REALTIME_PRIORITY_CLASS = 0
130
- HIGH_PRIORITY_CLASS = 1
131
- ABOVE_NORMAL_PRIORITY_CLASS = 2
132
- NORMAL_PRIORITY_CLASS = 4
133
- BELOW_NORMAL_PRIORITY_CLASS = 7
134
- IDLE_PRIORITY_CLASS = 9
135
- REALTIME = REALTIME_PRIORITY_CLASS
136
- HIGH = HIGH_PRIORITY_CLASS
137
- ABOVE_NORMAL = ABOVE_NORMAL_PRIORITY_CLASS
138
- NORMAL = NORMAL_PRIORITY_CLASS
139
- BELOW_NORMAL = BELOW_NORMAL_PRIORITY_CLASS
140
- IDLE = IDLE_PRIORITY_CLASS
141
-
142
- CLSCTX_INPROC_SERVER = 0x1
143
- CLSID_CTask = [0x148BD520,0xA2AB,0x11CE,0xB1,0x1F,0x00,0xAA,0x00,0x53,0x05,0x03].pack('LSSC8')
144
- CLSID_CTaskScheduler = [0x148BD52A,0xA2AB,0x11CE,0xB1,0x1F,0x00,0xAA,0x00,0x53,0x05,0x03].pack('LSSC8')
145
- IID_ITaskScheduler = [0x148BD527,0xA2AB,0x11CE,0xB1,0x1F,0x00,0xAA,0x00,0x53,0x05,0x03].pack('LSSC8')
146
- IID_ITask = [0x148BD524,0xA2AB,0x11CE,0xB1,0x1F,0x00,0xAA,0x00,0x53,0x05,0x03].pack('LSSC8')
147
- IID_IPersistFile = [0x0000010b,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46].pack('LSSC8')
75
+ FIRST = TASK_FIRST
76
+ SECOND = TASK_SECOND
77
+ THIRD = TASK_THIRD
78
+ FOURTH = TASK_FOURTH
79
+ FIFTH = TASK_FIFTH
80
+ SIXTH = TASK_SIXTH
81
+ SEVENTH = TASK_SEVENTH
82
+ EIGHTH = TASK_EIGHTH
83
+ NINETH = TASK_NINETH
84
+ TENTH = TASK_TENTH
85
+ ELEVENTH = TASK_ELEVENTH
86
+ TWELFTH = TASK_TWELFTH
87
+ THIRTEENTH = TASK_THIRTEENTH
88
+ FOURTEENTH = TASK_FOURTEENTH
89
+ FIFTEENTH = TASK_FIFTEENTH
90
+ SIXTEENTH = TASK_SIXTEENTH
91
+ SEVENTEENTH = TASK_SEVENTEENTH
92
+ EIGHTEENTH = TASK_EIGHTEENTH
93
+ NINETEENTH = TASK_NINETEENTH
94
+ TWENTIETH = TASK_TWENTIETH
95
+ TWENTY_FIRST = TASK_TWENTY_FIRST
96
+ TWENTY_SECOND = TASK_TWENTY_SECOND
97
+ TWENTY_THIRD = TASK_TWENTY_THIRD
98
+ TWENTY_FOURTH = TASK_TWENTY_FOURTH
99
+ TWENTY_FIFTH = TASK_TWENTY_FIFTH
100
+ TWENTY_SIXTH = TASK_TWENTY_SIXTH
101
+ TWENTY_SEVENTH = TASK_TWENTY_SEVENTH
102
+ TWENTY_EIGHTH = TASK_TWENTY_EIGHTH
103
+ TWENTY_NINTH = TASK_TWENTY_NINTH
104
+ THIRTYETH = TASK_THIRTYETH
105
+ THIRTY_FIRST = TASK_THIRTY_FIRST
106
+ LAST = TASK_LAST
148
107
  end
149
108
  end
150
109
  end
@@ -0,0 +1,271 @@
1
+ module RSpec
2
+ module Puppet
3
+ module Windows
4
+ module TaskSchedulerConstants
5
+ SYSTEM_USERS = ['NT AUTHORITY\SYSTEM', "SYSTEM", 'NT AUTHORITY\LOCALSERVICE', 'NT AUTHORITY\NETWORKSERVICE', 'BUILTIN\USERS', "USERS"].freeze
6
+
7
+ # Triggers
8
+
9
+ # Trigger is set to run the task a single time
10
+ TASK_TIME_TRIGGER_ONCE = 1
11
+
12
+ # Trigger is set to run the task on a daily interval
13
+ TASK_TIME_TRIGGER_DAILY = 2
14
+
15
+ # Trigger is set to run the task on specific days of a specific week & month
16
+ TASK_TIME_TRIGGER_WEEKLY = 3
17
+
18
+ # Trigger is set to run the task on specific day(s) of the month
19
+ TASK_TIME_TRIGGER_MONTHLYDATE = 4
20
+
21
+ # Trigger is set to run the task on specific day(s) of the month
22
+ TASK_TIME_TRIGGER_MONTHLYDOW = 5
23
+
24
+ # Trigger is set to run the task if the system remains idle for the amount
25
+ # of time specified by the idle wait time of the task
26
+ TASK_EVENT_TRIGGER_ON_IDLE = 6
27
+
28
+ TASK_TRIGGER_REGISTRATION = 7
29
+
30
+ # Trigger is set to run the task at system startup
31
+ TASK_EVENT_TRIGGER_AT_SYSTEMSTART = 8
32
+
33
+ # Trigger is set to run the task when a user logs on
34
+ TASK_EVENT_TRIGGER_AT_LOGON = 9
35
+
36
+ TASK_TRIGGER_SESSION_STATE_CHANGE = 11
37
+
38
+ # Daily Tasks
39
+
40
+ # The task will run on Sunday
41
+ TASK_SUNDAY = 0x1
42
+
43
+ # The task will run on Monday
44
+ TASK_MONDAY = 0x2
45
+
46
+ # The task will run on Tuesday
47
+ TASK_TUESDAY = 0x4
48
+
49
+ # The task will run on Wednesday
50
+ TASK_WEDNESDAY = 0x8
51
+
52
+ # The task will run on Thursday
53
+ TASK_THURSDAY = 0x10
54
+
55
+ # The task will run on Friday
56
+ TASK_FRIDAY = 0x20
57
+
58
+ # The task will run on Saturday
59
+ TASK_SATURDAY = 0x40
60
+
61
+ # Weekly tasks
62
+
63
+ # The task will run between the 1st and 7th day of the month
64
+ TASK_FIRST_WEEK = 0x01
65
+
66
+ # The task will run between the 8th and 14th day of the month
67
+ TASK_SECOND_WEEK = 0x02
68
+
69
+ # The task will run between the 15th and 21st day of the month
70
+ TASK_THIRD_WEEK = 0x04
71
+
72
+ # The task will run between the 22nd and 28th day of the month
73
+ TASK_FOURTH_WEEK = 0x08
74
+
75
+ # The task will run the last seven days of the month
76
+ TASK_LAST_WEEK = 0x10
77
+
78
+ # Monthly tasks
79
+
80
+ # The task will run in January
81
+ TASK_JANUARY = 0x1
82
+
83
+ # The task will run in February
84
+ TASK_FEBRUARY = 0x2
85
+
86
+ # The task will run in March
87
+ TASK_MARCH = 0x4
88
+
89
+ # The task will run in April
90
+ TASK_APRIL = 0x8
91
+
92
+ # The task will run in May
93
+ TASK_MAY = 0x10
94
+
95
+ # The task will run in June
96
+ TASK_JUNE = 0x20
97
+
98
+ # The task will run in July
99
+ TASK_JULY = 0x40
100
+
101
+ # The task will run in August
102
+ TASK_AUGUST = 0x80
103
+
104
+ # The task will run in September
105
+ TASK_SEPTEMBER = 0x100
106
+
107
+ # The task will run in October
108
+ TASK_OCTOBER = 0x200
109
+
110
+ # The task will run in November
111
+ TASK_NOVEMBER = 0x400
112
+
113
+ # The task will run in December
114
+ TASK_DECEMBER = 0x800
115
+
116
+ # Flags
117
+
118
+ # Used when converting AT service jobs into work items
119
+ TASK_FLAG_INTERACTIVE = 0x1
120
+
121
+ # The work item will be deleted when there are no more scheduled run times
122
+ TASK_FLAG_DELETE_WHEN_DONE = 0x2
123
+
124
+ # The work item is disabled. Useful for temporarily disabling a task
125
+ TASK_FLAG_DISABLED = 0x4
126
+
127
+ # The work item begins only if the computer is not in use at the scheduled
128
+ # start time
129
+ TASK_FLAG_START_ONLY_IF_IDLE = 0x10
130
+
131
+ # The work item terminates if the computer makes an idle to non-idle
132
+ # transition while the work item is running
133
+ TASK_FLAG_KILL_ON_IDLE_END = 0x20
134
+
135
+ # The work item does not start if the computer is running on battery power
136
+ TASK_FLAG_DONT_START_IF_ON_BATTERIES = 0x40
137
+
138
+ # The work item ends, and the associated application quits, if the computer
139
+ # switches to battery power
140
+ TASK_FLAG_KILL_IF_GOING_ON_BATTERIES = 0x80
141
+
142
+ # The work item starts only if the computer is in a docking station
143
+ TASK_FLAG_RUN_ONLY_IF_DOCKED = 0x100
144
+
145
+ # The work item created will be hidden
146
+ TASK_FLAG_HIDDEN = 0x200
147
+
148
+ # The work item runs only if there is a valid internet connection
149
+ TASK_FLAG_RUN_IF_CONNECTED_TO_INTERNET = 0x400
150
+
151
+ # The work item starts again if the computer makes a non-idle to idle
152
+ # transition
153
+ TASK_FLAG_RESTART_ON_IDLE_RESUME = 0x800
154
+
155
+ # The work item causes the system to be resumed, or awakened, if the
156
+ # system is running on batter power
157
+ TASK_FLAG_SYSTEM_REQUIRED = 0x1000
158
+
159
+ # The work item runs only if a specified account is logged on interactively
160
+ TASK_FLAG_RUN_ONLY_IF_LOGGED_ON = 0x2000
161
+
162
+ # Triggers
163
+
164
+ # The task will stop at some point in time
165
+ TASK_TRIGGER_FLAG_HAS_END_DATE = 0x1
166
+
167
+ # The task can be stopped at the end of the repetition period
168
+ TASK_TRIGGER_FLAG_KILL_AT_DURATION_END = 0x2
169
+
170
+ # The task trigger is disabled
171
+ TASK_TRIGGER_FLAG_DISABLED = 0x4
172
+
173
+ # Run Level Types
174
+ # Tasks will be run with the least privileges
175
+ TASK_RUNLEVEL_LUA = 0
176
+ # Tasks will be run with the highest privileges
177
+ TASK_RUNLEVEL_HIGHEST = 1
178
+
179
+ # Logon Types
180
+ # Used for non-NT credentials
181
+ TASK_LOGON_NONE = 0
182
+ # Use a password for logging on the user
183
+ TASK_LOGON_PASSWORD = 1
184
+ # The service will log the user on using Service For User
185
+ TASK_LOGON_S4U = 2
186
+ # Task will be run only in an existing interactive session
187
+ TASK_LOGON_INTERACTIVE_TOKEN = 3
188
+ # Group activation. The groupId field specifies the group
189
+ TASK_LOGON_GROUP = 4
190
+ # When Local System, Local Service, or Network Service account is
191
+ # being used as a security context to run the task
192
+ TASK_LOGON_SERVICE_ACCOUNT = 5
193
+ # Not in use; currently identical to TASK_LOGON_PASSWORD
194
+ TASK_LOGON_INTERACTIVE_TOKEN_OR_PASSWORD = 6
195
+
196
+
197
+ TASK_MAX_RUN_TIMES = 1440
198
+ TASKS_TO_RETRIEVE = 5
199
+
200
+ # Task creation
201
+
202
+ TASK_VALIDATE_ONLY = 0x1
203
+ TASK_CREATE = 0x2
204
+ TASK_UPDATE = 0x4
205
+ TASK_CREATE_OR_UPDATE = 0x6
206
+ TASK_DISABLE = 0x8
207
+ TASK_DONT_ADD_PRINCIPAL_ACE = 0x10
208
+ TASK_IGNORE_REGISTRATION_TRIGGERS = 0x20
209
+
210
+ # Priority classes
211
+
212
+ REALTIME_PRIORITY_CLASS = 0
213
+ HIGH_PRIORITY_CLASS = 1
214
+ ABOVE_NORMAL_PRIORITY_CLASS = 2 # Or 3
215
+ NORMAL_PRIORITY_CLASS = 4 # Or 5, 6
216
+ BELOW_NORMAL_PRIORITY_CLASS = 7 # Or 8
217
+ IDLE_PRIORITY_CLASS = 9 # Or 10
218
+
219
+ CLSCTX_INPROC_SERVER = 0x1
220
+ CLSID_CTask = [0x148BD520,0xA2AB,0x11CE,0xB1,0x1F,0x00,0xAA,0x00,0x53,0x05,0x03].pack('LSSC8')
221
+ CLSID_CTaskScheduler = [0x148BD52A,0xA2AB,0x11CE,0xB1,0x1F,0x00,0xAA,0x00,0x53,0x05,0x03].pack('LSSC8')
222
+ IID_ITaskScheduler = [0x148BD527,0xA2AB,0x11CE,0xB1,0x1F,0x00,0xAA,0x00,0x53,0x05,0x03].pack('LSSC8')
223
+ IID_ITask = [0x148BD524,0xA2AB,0x11CE,0xB1,0x1F,0x00,0xAA,0x00,0x53,0x05,0x03].pack('LSSC8')
224
+ IID_IPersistFile = [0x0000010b,0x0000,0x0000,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46].pack('LSSC8')
225
+
226
+ # Days of month
227
+
228
+ TASK_FIRST = 0x01
229
+ TASK_SECOND = 0x02
230
+ TASK_THIRD = 0x04
231
+ TASK_FOURTH = 0x08
232
+ TASK_FIFTH = 0x10
233
+ TASK_SIXTH = 0x20
234
+ TASK_SEVENTH = 0x40
235
+ TASK_EIGHTH = 0x80
236
+ TASK_NINETH = 0x100
237
+ TASK_TENTH = 0x200
238
+ TASK_ELEVENTH = 0x400
239
+ TASK_TWELFTH = 0x800
240
+ TASK_THIRTEENTH = 0x1000
241
+ TASK_FOURTEENTH = 0x2000
242
+ TASK_FIFTEENTH = 0x4000
243
+ TASK_SIXTEENTH = 0x8000
244
+ TASK_SEVENTEENTH = 0x10000
245
+ TASK_EIGHTEENTH = 0x20000
246
+ TASK_NINETEENTH = 0x40000
247
+ TASK_TWENTIETH = 0x80000
248
+ TASK_TWENTY_FIRST = 0x100000
249
+ TASK_TWENTY_SECOND = 0x200000
250
+ TASK_TWENTY_THIRD = 0x400000
251
+ TASK_TWENTY_FOURTH = 0x800000
252
+ TASK_TWENTY_FIFTH = 0x1000000
253
+ TASK_TWENTY_SIXTH = 0x2000000
254
+ TASK_TWENTY_SEVENTH = 0x4000000
255
+ TASK_TWENTY_EIGHTH = 0x8000000
256
+ TASK_TWENTY_NINTH = 0x10000000
257
+ TASK_THIRTYETH = 0x20000000
258
+ TASK_THIRTY_FIRST = 0x40000000
259
+ TASK_LAST = 0x80000000
260
+ end
261
+ end
262
+ end
263
+ end
264
+
265
+ begin
266
+ require 'win32/windows/constants'
267
+ rescue LoadError
268
+ module Windows
269
+ TaskSchedulerConstants = RSpec::Puppet::Windows::TaskSchedulerConstants
270
+ end
271
+ end
@@ -1,7 +1,4 @@
1
1
  require 'puppet'
2
- if Puppet.version.to_f >= 4.0
3
- require 'puppet/pops'
4
- end
5
2
  require 'fileutils'
6
3
 
7
4
  module RSpec::Puppet
@@ -87,7 +84,8 @@ END
87
84
  def self.get_module_name_from_file(file)
88
85
  # FIXME: see discussion at
89
86
  # https://github.com/rodjek/rspec-puppet/issues/290
90
- if Puppet.version.to_f >= 4.0
87
+ if Puppet.version.to_f >= 4.0 || RSpec.configuration.parser == 'future'
88
+ require 'puppet/pops'
91
89
  p = Puppet::Pops::Parser::Lexer2.new
92
90
  else
93
91
  p = Puppet::Parser::Lexer.new
@@ -63,7 +63,7 @@ module RSpec::Puppet
63
63
  value.to_s.downcase == 'windows' ? :windows : :posix
64
64
  }
65
65
 
66
- ['operatingsystem', 'osfamily', 'os'].each do |os_fact|
66
+ ['operatingsystem', 'osfamily'].each do |os_fact|
67
67
  return from_value.call(test_facts[os_fact]) if test_facts.key?(os_fact)
68
68
  end
69
69
 
@@ -410,7 +410,7 @@ module RSpec::Puppet
410
410
  def stub_facts!(facts)
411
411
  Puppet.settings[:autosign] = false
412
412
  Facter.clear
413
- facts.each { |k, v| Facter.add(k) { setcode { v } } }
413
+ facts.each { |k, v| Facter.add(k, :weight => 999) { setcode { v } } }
414
414
  end
415
415
 
416
416
  def build_catalog(*args)
@@ -51,7 +51,7 @@ task :release_test do
51
51
 
52
52
  Dir.chdir(module_dir) do
53
53
  print ' Installing dependencies... '
54
- bundle_install_output, status = Open3.capture2e('bundle', 'install', '--path', 'vendor/gems')
54
+ bundle_install_output, status = Open3.capture2e('bundle', 'install', '--path', '../vendor/gems')
55
55
  if status.success?
56
56
  puts 'Done'
57
57
  else
@@ -90,7 +90,7 @@ task :release_test do
90
90
  puts 'Done'
91
91
 
92
92
  print ' Installing dependencies... '
93
- _, status = Open3.capture2e('bundle', 'install', '--path', 'vendor/gems')
93
+ _, status = Open3.capture2e('bundle', 'install', '--path', '../vendor/gems')
94
94
  if status.success?
95
95
  puts 'Done'
96
96
  else
@@ -115,8 +115,8 @@ task :release_test do
115
115
  end
116
116
 
117
117
  json_regex = %r{\{(?:[^{}]|(?:\g<0>))*\}}x
118
- baseline_results = JSON.parse(baseline_output.scan(json_regex).last)
119
- head_results = JSON.parse(head_output.scan(json_regex).last)
118
+ baseline_results = JSON.parse(baseline_output.scan(json_regex).find { |r| r.include?('summary_line') })
119
+ head_results = JSON.parse(head_output.scan(json_regex).find { |r| r.include?('summary_line') })
120
120
  if head_results['summary_line'] == baseline_results['summary_line']
121
121
  puts " PASS: #{head_results['summary_line']}"
122
122
  else
@@ -128,7 +128,7 @@ task :release_test do
128
128
  end
129
129
  end
130
130
 
131
- class GemfileRewrite < Parser::Rewriter
131
+ class GemfileRewrite < Parser::TreeRewriter
132
132
  def on_send(node)
133
133
  _, method_name, *args = *node
134
134
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.11
4
+ version: 2.6.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Sharpe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-07 00:00:00.000000000 Z
11
+ date: 2018-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -62,6 +62,7 @@ files:
62
62
  - lib/rspec-puppet/monkey_patches.rb
63
63
  - lib/rspec-puppet/monkey_patches/win32/registry.rb
64
64
  - lib/rspec-puppet/monkey_patches/win32/taskscheduler.rb
65
+ - lib/rspec-puppet/monkey_patches/windows/taskschedulerconstants.rb
65
66
  - lib/rspec-puppet/rake_task.rb
66
67
  - lib/rspec-puppet/raw_string.rb
67
68
  - lib/rspec-puppet/setup.rb
@@ -88,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
89
  version: '0'
89
90
  requirements: []
90
91
  rubyforge_project:
91
- rubygems_version: 2.6.13
92
+ rubygems_version: 2.6.14.1
92
93
  signing_key:
93
94
  specification_version: 4
94
95
  summary: RSpec tests for your Puppet manifests