summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDan Bode <dan@bodepd.com>2010-06-02 11:45:37 -0500
committerDan Bode <dan@bodepd.com>2010-06-02 11:45:37 -0500
commit2f983bc4253bf5ca7ee641c8db9e8ccd96c0401d (patch)
tree918f2948c98b4fc4f84f4d2f9a42dadb3d717a5f /tests
parent37099d6d140f073522f9f9b37ba2a9b429433f25 (diff)
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 :(
Diffstat (limited to 'tests')
-rw-r--r--tests/sudoers/all.pp22
-rw-r--r--tests/sudoers/blah.pp10
-rw-r--r--tests/sudoers/default.pp9
-rw-r--r--tests/sudoers/sudo-bad.pp18
-rw-r--r--tests/sudoers/sudo-dep.pp20
-rw-r--r--tests/sudoers/sudoers-break-test.pp7
-rw-r--r--tests/sudoers/sudoers-create.pp22
-rw-r--r--tests/sudoers/sudoers-delete.pp22
-rw-r--r--tests/sudoers/sudoers.pp39
-rw-r--r--tests/sudoers/test-alias-user.pp12
-rw-r--r--tests/sudoers/test2.pp20
11 files changed, 201 insertions, 0 deletions
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',
+ }