| | 1 | #!/usr/bin/env ruby |
|---|
| | 2 | |
|---|
| | 3 | require File.dirname(__FILE__) + '/../lib/puppettest' |
|---|
| | 4 | |
|---|
| | 5 | require 'puppet' |
|---|
| | 6 | require 'puppettest' |
|---|
| | 7 | |
|---|
| | 8 | class TestSELinux < Test::Unit::TestCase |
|---|
| | 9 | include PuppetTest |
|---|
| | 10 | |
|---|
| | 11 | def test_filecontext |
|---|
| | 12 | path = tempfile() |
|---|
| | 13 | file = nil |
|---|
| | 14 | context = nil |
|---|
| | 15 | |
|---|
| | 16 | file = Puppet.type(:file).create( |
|---|
| | 17 | :path => path, |
|---|
| | 18 | :ensure => "file" |
|---|
| | 19 | ) |
|---|
| | 20 | |
|---|
| | 21 | assert_nothing_raised() { |
|---|
| | 22 | file[:seluser] = "foo_u" |
|---|
| | 23 | } |
|---|
| | 24 | assert_nothing_raised() { |
|---|
| | 25 | file[:selrole] = "bar_r" |
|---|
| | 26 | } |
|---|
| | 27 | assert_nothing_raised() { |
|---|
| | 28 | file[:seltype] = "baz_t" |
|---|
| | 29 | } |
|---|
| | 30 | end |
|---|
| | 31 | |
|---|
| | 32 | def test_seboolean |
|---|
| | 33 | bool = nil |
|---|
| | 34 | assert( |
|---|
| | 35 | bool = Puppet::Type.type(:selboolean) |
|---|
| | 36 | ) |
|---|
| | 37 | assert( |
|---|
| | 38 | bool = { |
|---|
| | 39 | :name => 'foo', |
|---|
| | 40 | :value => 'off', |
|---|
| | 41 | :persistent => true |
|---|
| | 42 | } |
|---|
| | 43 | ) |
|---|
| | 44 | assert( |
|---|
| | 45 | bool = { |
|---|
| | 46 | :name => 'bar', |
|---|
| | 47 | :value => 'on', |
|---|
| | 48 | :persistent => false |
|---|
| | 49 | } |
|---|
| | 50 | ) |
|---|
| | 51 | end |
|---|
| | 52 | |
|---|
| | 53 | def test_semodule |
|---|
| | 54 | mod = nil |
|---|
| | 55 | assert( |
|---|
| | 56 | mod = Puppet::Type.type(:selmodule).create( |
|---|
| | 57 | :name => 'foo', |
|---|
| | 58 | :selmoduledir => '/some/path/here', |
|---|
| | 59 | :selmodulepath => '/some/path/here/foo.pp', |
|---|
| | 60 | :syncversion => 'true' |
|---|
| | 61 | ) |
|---|
| | 62 | ) |
|---|
| | 63 | |
|---|
| | 64 | assert(mod[:name] = 'bar') |
|---|
| | 65 | assert(mod[:selmoduledir] = '/some/other/path') |
|---|
| | 66 | assert(mod[:selmodulepath] = '/some/other/path/bar.pp') |
|---|
| | 67 | assert(mod[:syncversion] = 'false') #XXX: Bug here. False is not currently a valid value. |
|---|
| | 68 | end |
|---|
| | 69 | end |