~lynxman/ubuntu/precise/puppet/puppetlabsfixbug12844

« back to all changes in this revision

Viewing changes to spec/unit/application/apply_spec.rb

  • Committer: Package Import Robot
  • Author(s): Micah Anderson
  • Date: 2012-02-23 18:24:48 UTC
  • mfrom: (1.1.28) (3.1.36 sid)
  • Revision ID: package-import@ubuntu.com-20120223182448-belun93murza4w99
Tags: 2.7.11-1
* New upstream release
* Urgency set to high due to regressions in previous release
  and security vulnerabilities
* Execs when run with a user specified, but no group, get the root
  group. Similarly unexpected privileges are given to providers and
  types (egid remains as root), this is fixed with a patch from
  upstream (CVE-2012-1053)
* Fix Klogin write through symlink (CVE-2012-1054)

Show diffs side-by-side

added added

removed removed

Lines of Context:
210
210
        expect { @apply.main }.to exit_with 0
211
211
      end
212
212
 
213
 
      it "should set the facts name based on the node_name_fact" do
214
 
        @facts = Puppet::Node::Facts.new(Puppet[:node_name_value], 'my_name_fact' => 'other_node_name')
215
 
        Puppet::Node::Facts.indirection.save(@facts)
216
 
 
217
 
        node = Puppet::Node.new('other_node_name')
218
 
        Puppet::Node.indirection.save(node)
219
 
 
220
 
        Puppet[:node_name_fact] = 'my_name_fact'
221
 
 
222
 
        expect { @apply.main }.to exit_with 0
223
 
 
224
 
        @facts.name.should == 'other_node_name'
225
 
      end
226
 
 
227
 
      it "should set the node_name_value based on the node_name_fact" do
228
 
        facts = Puppet::Node::Facts.new(Puppet[:node_name_value], 'my_name_fact' => 'other_node_name')
229
 
        Puppet::Node::Facts.indirection.save(facts)
230
 
        node = Puppet::Node.new('other_node_name')
231
 
        Puppet::Node.indirection.save(node)
232
 
        Puppet[:node_name_fact] = 'my_name_fact'
233
 
 
234
 
        expect { @apply.main }.to exit_with 0
235
 
 
236
 
        Puppet[:node_name_value].should == 'other_node_name'
237
 
      end
238
 
 
239
 
      it "should raise an error if we can't find the facts" do
240
 
        Puppet::Node::Facts.indirection.expects(:find).returns(nil)
241
 
 
242
 
        lambda { @apply.main }.should raise_error
243
 
      end
244
 
 
245
213
      it "should raise an error if we can't find the node" do
246
214
        Puppet::Node.indirection.expects(:find).returns(nil)
247
215
 
248
216
        lambda { @apply.main }.should raise_error
249
217
      end
250
218
 
251
 
      it "should merge in our node the loaded facts" do
252
 
        @facts.values = {'key' => 'value'}
253
 
 
254
 
        expect { @apply.main }.to exit_with 0
255
 
 
256
 
        @node.parameters['key'].should == 'value'
257
 
      end
258
 
 
259
219
      it "should load custom classes if loadclasses" do
260
220
        @apply.options[:loadclasses] = true
261
221
        classfile = tmpfile('classfile')
308
268
        expect { @apply.main }.to exit_with 0
309
269
      end
310
270
 
 
271
      describe "when using node_name_fact" do
 
272
        before :each do
 
273
          @facts = Puppet::Node::Facts.new(Puppet[:node_name_value], 'my_name_fact' => 'other_node_name')
 
274
          Puppet::Node::Facts.indirection.save(@facts)
 
275
          @node = Puppet::Node.new('other_node_name')
 
276
          Puppet::Node.indirection.save(@node)
 
277
          Puppet[:node_name_fact] = 'my_name_fact'
 
278
        end
 
279
 
 
280
        it "should set the facts name based on the node_name_fact" do
 
281
          expect { @apply.main }.to exit_with 0
 
282
          @facts.name.should == 'other_node_name'
 
283
        end
 
284
 
 
285
        it "should set the node_name_value based on the node_name_fact" do
 
286
          expect { @apply.main }.to exit_with 0
 
287
          Puppet[:node_name_value].should == 'other_node_name'
 
288
        end
 
289
 
 
290
        it "should merge in our node the loaded facts" do
 
291
          @facts.values.merge!('key' => 'value')
 
292
 
 
293
          expect { @apply.main }.to exit_with 0
 
294
 
 
295
          @node.parameters['key'].should == 'value'
 
296
        end
 
297
 
 
298
        it "should raise an error if we can't find the facts" do
 
299
          Puppet::Node::Facts.indirection.expects(:find).returns(nil)
 
300
 
 
301
          lambda { @apply.main }.should raise_error
 
302
        end
 
303
      end
 
304
 
311
305
      describe "with detailed_exitcodes" do
312
306
        before :each do
313
307
          @apply.options[:detailed_exitcodes] = true