~ubuntu-branches/ubuntu/lucid/puppet/lucid-security

« back to all changes in this revision

Viewing changes to spec/unit/other/selinux.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-12-23 00:48:10 UTC
  • mfrom: (1.1.10 upstream) (3.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091223004810-3i4oryds922g5n59
Tags: 0.25.1-3ubuntu1
* Merge from debian testing.  Remaining changes:
  - debian/rules:
    + Don't start puppet when first installing puppet.
  - debian/puppet.conf, lib/puppet/defaults.rb:
    + Move templates to /etc/puppet
  - lib/puppet/defaults.rb:
    + Fix /var/lib/puppet/state ownership.
  - man/man8/puppet.conf.8: 
    + Fix broken URL in manpage.
  - debian/control:
    + Update maintainer accordint to spec.
    + Puppetmaster Recommends -> Suggests
    + Created puppet-testsuite as a seperate. Allow the users to run puppet's 
      testsuite.
  - tests/Rakefile: Fix rakefile so that the testsuite can acutally be ran.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env ruby
 
2
 
 
3
require File.dirname(__FILE__) + '/../../spec_helper'
 
4
 
 
5
require 'puppet/type/selboolean'
 
6
require 'puppet/type/selmodule'
 
7
 
 
8
describe Puppet::Type.type(:file), " when manipulating file contexts" do
 
9
    before :each do
 
10
        @file = Puppet::Type::File.new(
 
11
            :name => "/tmp/foo",
 
12
            :ensure => "file",
 
13
            :seluser => "user_u",
 
14
            :selrole => "role_r",
 
15
            :seltype => "type_t" )
 
16
    end
 
17
    it "should use :seluser to get/set an SELinux user file context attribute" do
 
18
        @file.property(:seluser).should == "user_u"
 
19
    end
 
20
    it "should use :selrole to get/set an SELinux role file context attribute" do
 
21
        @file.property(:selrole).should == "role_r"
 
22
    end
 
23
    it "should use :seltype to get/set an SELinux user file context attribute" do
 
24
        @file.property(:seltype).should == "type_t"
 
25
    end
 
26
end
 
27
 
 
28
describe Puppet::Type.type(:selboolean), " when manipulating booleans" do
 
29
    before :each do
 
30
        provider_class = Puppet::Type::Selboolean.provider(Puppet::Type::Selboolean.providers[0])
 
31
        Puppet::Type::Selboolean.expects(:defaultprovider).returns provider_class
 
32
 
 
33
        @bool = Puppet::Type::Selboolean.new(
 
34
            :name => "foo",
 
35
            :value => "on",
 
36
            :persistent => true )
 
37
    end
 
38
    it "should be able to access :name" do
 
39
        @bool[:name].should == "foo"
 
40
    end
 
41
    it "should be able to access :value" do
 
42
        @bool.property(:value).should == :on
 
43
    end
 
44
    it "should set :value to off" do
 
45
        @bool[:value] = :off
 
46
        @bool.property(:value).should == :off
 
47
    end
 
48
    it "should be able to access :persistent" do
 
49
        @bool[:persistent].should == :true
 
50
    end
 
51
    it "should set :persistent to false" do
 
52
        @bool[:persistent] = false
 
53
        @bool[:persistent].should == :false
 
54
    end
 
55
end
 
56
 
 
57
describe Puppet::Type.type(:selmodule), " when checking policy modules" do
 
58
    before :each do
 
59
        provider_class = Puppet::Type::Selmodule.provider(Puppet::Type::Selmodule.providers[0])
 
60
        Puppet::Type::Selmodule.expects(:defaultprovider).returns provider_class
 
61
 
 
62
        @module = Puppet::Type::Selmodule.new(
 
63
            :name => "foo",
 
64
            :selmoduledir => "/some/path",
 
65
            :selmodulepath => "/some/path/foo.pp",
 
66
            :syncversion => true)
 
67
    end
 
68
    it "should be able to access :name" do
 
69
        @module[:name].should == "foo"
 
70
    end
 
71
    it "should be able to access :selmoduledir" do
 
72
        @module[:selmoduledir].should == "/some/path"
 
73
    end
 
74
    it "should be able to access :selmodulepath" do
 
75
        @module[:selmodulepath].should == "/some/path/foo.pp"
 
76
    end
 
77
    it "should be able to access :syncversion" do
 
78
        @module.property(:syncversion).should == :true
 
79
    end
 
80
    it "should set the syncversion value to false" do
 
81
        @module[:syncversion] = :false
 
82
        @module.property(:syncversion).should == :false
 
83
    end
 
84
end
 
85