From 2f983bc4253bf5ca7ee641c8db9e8ccd96c0401d Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Wed, 2 Jun 2010 11:45:37 -0500 Subject: Committing all of the tests that I ran to validate the behavior of the sudoers type. I understand they are not proper unit tests. sorry :( --- tests/sudoers/all.pp | 22 +++++++++++++++++++++ tests/sudoers/blah.pp | 10 ++++++++++ tests/sudoers/default.pp | 9 +++++++++ tests/sudoers/sudo-bad.pp | 18 +++++++++++++++++ tests/sudoers/sudo-dep.pp | 20 +++++++++++++++++++ tests/sudoers/sudoers-break-test.pp | 7 +++++++ tests/sudoers/sudoers-create.pp | 22 +++++++++++++++++++++ tests/sudoers/sudoers-delete.pp | 22 +++++++++++++++++++++ tests/sudoers/sudoers.pp | 39 +++++++++++++++++++++++++++++++++++++ tests/sudoers/test-alias-user.pp | 12 ++++++++++++ tests/sudoers/test2.pp | 20 +++++++++++++++++++ 11 files changed, 201 insertions(+) create mode 100644 tests/sudoers/all.pp create mode 100644 tests/sudoers/blah.pp create mode 100644 tests/sudoers/default.pp create mode 100644 tests/sudoers/sudo-bad.pp create mode 100644 tests/sudoers/sudo-dep.pp create mode 100644 tests/sudoers/sudoers-break-test.pp create mode 100644 tests/sudoers/sudoers-create.pp create mode 100644 tests/sudoers/sudoers-delete.pp create mode 100644 tests/sudoers/sudoers.pp create mode 100644 tests/sudoers/test-alias-user.pp create mode 100644 tests/sudoers/test2.pp diff --git a/tests/sudoers/all.pp b/tests/sudoers/all.pp new file mode 100644 index 0000000..7ac44de --- /dev/null +++ b/tests/sudoers/all.pp @@ -0,0 +1,22 @@ +Sudoers{type => 'user_spec'} +resources { 'sudoers': + purge => true, +} +sudoers{ 'ID1': + users => 'mike', + commands => '(ALL) ALL', + hosts => 'ALL', + comment => 'pimp my comment', + #ensure => absent, +} +sudoers{ 'ID2': + users => 'dan', + commands => '(ALL) ALL', + hosts => 'ALL', + comment => 'comment2', +} +sudoers{ 'ID3': + users => 'bill', + commands => '(ALL) ALL', + hosts => 'ALL', +} diff --git a/tests/sudoers/blah.pp b/tests/sudoers/blah.pp new file mode 100644 index 0000000..0f30782 --- /dev/null +++ b/tests/sudoers/blah.pp @@ -0,0 +1,10 @@ +#resources { 'sudoers': purge => true } + +sudoers{'BLAHDDD': + # could be a user named defaults + users =>['dan','bob', 'joe'], + hosts => 'ALL', + commands => '/bin/ls -la', + type => 'user_spec', + comment => 'my comment' +} diff --git a/tests/sudoers/default.pp b/tests/sudoers/default.pp new file mode 100644 index 0000000..3383ad7 --- /dev/null +++ b/tests/sudoers/default.pp @@ -0,0 +1,9 @@ +# +# this should fail, cannot have a use called Defaults +# +sudoers{'BLAHDDD': + # could be a user named defaults + users => ['dan', 'Defaults'], + hosts => 'ALL', + commands => '/bin/ls -la' +} diff --git a/tests/sudoers/sudo-bad.pp b/tests/sudoers/sudo-bad.pp new file mode 100644 index 0000000..4bca785 --- /dev/null +++ b/tests/sudoers/sudo-bad.pp @@ -0,0 +1,18 @@ +sudoers{'BLAH': + #target => '/tmp/sudoers', + ensure => present, + sudo_alias => 'Cmnd_Alias', + items => ['/bin/blah3', '/bin/blah4', '/bin/blah2'], + require => Sudoers['Defaults@host'], + type => 'alias', +} +sudoers{'Defaults@host': + parameters => ['x=z', 'one=1', 'two=2'], + type => 'default', +} +sudoers{'TEST': + users => 'dan1', + hosts => 'localhost', + commands => '/bin/true', + type => 'user_spec', +} diff --git a/tests/sudoers/sudo-dep.pp b/tests/sudoers/sudo-dep.pp new file mode 100644 index 0000000..2474de2 --- /dev/null +++ b/tests/sudoers/sudo-dep.pp @@ -0,0 +1,20 @@ +resources{'sudoers': purge => true} +sudoers{'BLAH': + #target => '/tmp/sudoers', + ensure => present, + sudo_alias => 'Cmnd_Alias', + items => ['/bin/blah', '/bin/blah4', '/bin/blah2'], + require => Sudoers['Defaults@host'], + type => 'alias', +} +sudoers{'Defaults@host': + parameters => ['x=y', 'one=1', 'two=2'], + type => 'default', +} +sudoers{'TEST': + users => 'dan3', + hosts => 'localhost', + commands => '/bin/true', + require => Sudoers['BLAH'], + type => 'user_spec', +} diff --git a/tests/sudoers/sudoers-break-test.pp b/tests/sudoers/sudoers-break-test.pp new file mode 100644 index 0000000..2351e96 --- /dev/null +++ b/tests/sudoers/sudoers-break-test.pp @@ -0,0 +1,7 @@ +# invalid line should break and not be written to /etc/sudoers +Sudoers{type => 'alias'} +sudoers{'blah4': + sudo_alias => 'Runas_Alias', + items => 'root', + commands => '/bin/true' +} diff --git a/tests/sudoers/sudoers-create.pp b/tests/sudoers/sudoers-create.pp new file mode 100644 index 0000000..625333c --- /dev/null +++ b/tests/sudoers/sudoers-create.pp @@ -0,0 +1,22 @@ +sudoers { 'blah1': + target => '/tmp/sudoers', + ensure => present, + sudo_alias => 'Cmnd_Alias', + items => ['/usr/bin/which', '/bin/touch'], + type => 'alias', +} +sudoers { 'blah2': + target => '/tmp/sudoers', + ensure => present, + sudo_alias => 'Host_Alias', + items => ['localhost', 'localhost.localdomain'], + type => 'alias', +} +sudoers { 'blah3': + target => '/tmp/sudoers', + ensure => present, + users => 'dan', + hosts => 'localhost', + commands => ['/bin/true', '/bin/false'], + type => 'user_spec', +} diff --git a/tests/sudoers/sudoers-delete.pp b/tests/sudoers/sudoers-delete.pp new file mode 100644 index 0000000..831c7fd --- /dev/null +++ b/tests/sudoers/sudoers-delete.pp @@ -0,0 +1,22 @@ +sudoers { 'blah1': + target => '/tmp/sudoers', + ensure => absent, + sudo_alias => 'Cmnd_Alias', + items => ['blah4', 'blah2'], + type => 'alias', +} +sudoers { 'blah2': + target => '/tmp/sudoers', + ensure => absent, + sudo_alias => 'Host_Alias', + items => ['blah2', 'blah3'], + type => 'alias', +} +sudoers { 'blah3': + target => '/tmp/sudoers', + ensure => absent, + users => 'dan', + hosts => 'localhost', + commands => ['/bin/true', '/bin/false'], + type => 'user_spec', +} diff --git a/tests/sudoers/sudoers.pp b/tests/sudoers/sudoers.pp new file mode 100644 index 0000000..d3260db --- /dev/null +++ b/tests/sudoers/sudoers.pp @@ -0,0 +1,39 @@ +Sudoers { type => 'alias' } +#resources{'sudoers': +# purge => true, +#} +sudoers{'BLAH1': + #target => '/tmp/sudoers', + ensure => present, + sudo_alias => 'Cmnd_Alias', + items => ['/bin/blah', '/bin/blah4', '/bin/blah2'], + require => Sudoers['BHAH2'], + type => 'alias', +} +#sudoers{'blah4': +# #target => '/tmp/sudoers', +# ensure => present, +# users => 'dan', +# hosts => 'localhost', +# commands => '/bin/true', +# type => 'user_spec', +#} +sudoers{'BLAH3': + ensure => present, + sudo_alias => 'Cmnd_Alias', + items => ['/bin/blah', '/bin/blah4', '/bin/blah2'], + before => Sudoers['BHAH2'], + type => 'alias', +} +sudoers{'BHAH2': + #target => '/tmp/sudoers', + ensure => present, + sudo_alias => 'Host_Alias', + items => ['blah2', 'blah3', 'blah4', 'blah5'], + #require => Sudoers['blah4'], + type => 'alias', +} +sudoers{'Defaults@host': + parameters => ['x=y', 'one=1', 'two=2'], + type => 'default', +} diff --git a/tests/sudoers/test-alias-user.pp b/tests/sudoers/test-alias-user.pp new file mode 100644 index 0000000..69fabdd --- /dev/null +++ b/tests/sudoers/test-alias-user.pp @@ -0,0 +1,12 @@ +#sudoers{'BLAH4': +# sudo_alias => 'Runas_Alias', +# items => 'root', +#} +sudoers{'BLAH4': + #target => '/tmp/sudoers', + ensure => present, + users => ['dan', 'dan4', 'dan3'], + hosts => ['localhost', 'localhost2'], + commands => ['/bin/true blah', '/bin/false de', '/bin/duder/dude blah'], + type => 'spec' +} diff --git a/tests/sudoers/test2.pp b/tests/sudoers/test2.pp new file mode 100644 index 0000000..63c6714 --- /dev/null +++ b/tests/sudoers/test2.pp @@ -0,0 +1,20 @@ +sudoers{'NAME': + ensure => present, + users => ['dan1', 'dan2'], + hosts => 'ALL', + commands => [ + '(root) /usr/bin/su - easapp', + '(easapp)/usr/local/eas-ts/bin/appctl', + ], + type => 'user_spec', +} +sudoers{'ALIAS_NAME': + ensure => present, + sudo_alias => 'Cmnd', + items => ['/bin/true', '/usr/bin/su - bob'], + type => 'alias', +} +sudoers{'Defaults@host': + parameters => ['x=y', 'one=1', 'two=2'], + type => 'default', + } -- cgit v1.2.3