serverspec 0.5.8 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. data/lib/serverspec.rb +37 -33
  2. data/lib/serverspec/helper.rb +0 -3
  3. data/lib/serverspec/matchers.rb +18 -34
  4. data/lib/serverspec/matchers/be_executable.rb +1 -9
  5. data/lib/serverspec/matchers/be_installed.rb +1 -15
  6. data/lib/serverspec/matchers/be_mounted.rb +1 -5
  7. data/lib/serverspec/matchers/be_reachable.rb +1 -5
  8. data/lib/serverspec/matchers/be_readable.rb +1 -9
  9. data/lib/serverspec/matchers/be_resolvable.rb +1 -5
  10. data/lib/serverspec/matchers/be_running.rb +1 -15
  11. data/lib/serverspec/matchers/be_writable.rb +1 -9
  12. data/lib/serverspec/matchers/belong_to_group.rb +1 -5
  13. data/lib/serverspec/matchers/contain.rb +1 -11
  14. data/lib/serverspec/matchers/have_entry.rb +0 -2
  15. data/lib/serverspec/matchers/match_md5checksum.rb +1 -5
  16. data/lib/serverspec/matchers/return_exit_status.rb +1 -6
  17. data/lib/serverspec/matchers/return_stderr.rb +1 -10
  18. data/lib/serverspec/matchers/return_stdout.rb +1 -10
  19. data/lib/serverspec/version.rb +1 -1
  20. data/spec/darwin/commands_spec.rb +1 -1
  21. data/spec/debian/commands_spec.rb +1 -1
  22. data/spec/gentoo/commands_spec.rb +1 -1
  23. data/spec/redhat/commands_spec.rb +1 -1
  24. data/spec/solaris/commands_spec.rb +1 -1
  25. data/spec/solaris/service_spec.rb +1 -1
  26. data/spec/support/shared_commands_examples.rb +2 -2
  27. data/spec/support/shared_cron_examples.rb +4 -4
  28. data/spec/support/shared_group_examples.rb +2 -2
  29. data/spec/support/shared_iptables_examples.rb +2 -2
  30. data/spec/support/shared_package_examples.rb +4 -4
  31. data/spec/support/shared_user_examples.rb +2 -2
  32. metadata +3 -45
  33. data/lib/serverspec/backend/puppet.rb +0 -108
  34. data/lib/serverspec/filter.rb +0 -21
  35. data/lib/serverspec/helper/obsoleted.rb +0 -74
  36. data/lib/serverspec/matchers/be_default_gateway.rb +0 -14
  37. data/lib/serverspec/matchers/be_directory.rb +0 -9
  38. data/lib/serverspec/matchers/be_disabled.rb +0 -9
  39. data/lib/serverspec/matchers/be_enabled.rb +0 -9
  40. data/lib/serverspec/matchers/be_enforcing.rb +0 -10
  41. data/lib/serverspec/matchers/be_file.rb +0 -9
  42. data/lib/serverspec/matchers/be_group.rb +0 -5
  43. data/lib/serverspec/matchers/be_grouped_into.rb +0 -9
  44. data/lib/serverspec/matchers/be_linked_to.rb +0 -9
  45. data/lib/serverspec/matchers/be_listening.rb +0 -10
  46. data/lib/serverspec/matchers/be_mode.rb +0 -9
  47. data/lib/serverspec/matchers/be_owned_by.rb +0 -9
  48. data/lib/serverspec/matchers/be_permissive.rb +0 -9
  49. data/lib/serverspec/matchers/be_user.rb +0 -5
  50. data/lib/serverspec/matchers/be_zfs.rb +0 -9
  51. data/lib/serverspec/matchers/get_stdout.rb +0 -14
  52. data/lib/serverspec/matchers/have_authorized_key.rb +0 -9
  53. data/lib/serverspec/matchers/have_cron_entry.rb +0 -9
  54. data/lib/serverspec/matchers/have_gid.rb +0 -10
  55. data/lib/serverspec/matchers/have_home_directory.rb +0 -10
  56. data/lib/serverspec/matchers/have_ipfilter_rule.rb +0 -5
  57. data/lib/serverspec/matchers/have_ipnat_rule.rb +0 -5
  58. data/lib/serverspec/matchers/have_iptables_rule.rb +0 -11
  59. data/lib/serverspec/matchers/have_login_shell.rb +0 -10
  60. data/lib/serverspec/matchers/have_svcprop.rb +0 -9
  61. data/lib/serverspec/matchers/have_svcprops.rb +0 -5
  62. data/lib/serverspec/matchers/have_uid.rb +0 -10
  63. data/spec/darwin/matchers_spec.rb +0 -89
  64. data/spec/debian/matchers_spec.rb +0 -92
  65. data/spec/gentoo/matchers_spec.rb +0 -93
  66. data/spec/redhat/matchers_spec.rb +0 -98
  67. data/spec/solaris/matchers_spec.rb +0 -92
  68. data/spec/support/shared_matcher_examples.rb +0 -1310
@@ -1,92 +0,0 @@
1
- require 'spec_helper'
2
-
3
- include Serverspec::Helper::Debian
4
-
5
- describe 'Serverspec matchers of Debian family' do
6
- it_behaves_like 'support be_enabled matcher', 'rc.local'
7
- it_behaves_like 'support be_installed matcher', 'openssh-server'
8
- it_behaves_like 'support be_running matcher', 'ssh'
9
- it_behaves_like 'support be_running.under("supervisor") matcher', 'growthforecast'
10
- it_behaves_like 'support be_listening matcher', 22
11
- it_behaves_like 'support be_file matcher', '/etc/ssh/sshd_config'
12
-
13
- it_behaves_like 'support be_mounted matcher', '/'
14
- it_behaves_like 'support be_mounted.with matcher', '/'
15
- it_behaves_like 'support be_mounted.only_with matcher', '/'
16
-
17
- it_behaves_like 'support be_reachable matcher', '127.0.0.1'
18
- it_behaves_like 'support be_reachable.with matcher', '127.0.0.1'
19
-
20
- it_behaves_like 'support be_resolvable matcher', 'localhost'
21
- it_behaves_like 'support be_resolvable.by matcher', 'localhost', 'hosts'
22
- it_behaves_like 'support be_resolvable.by matcher', 'localhost', 'dns'
23
- it_behaves_like 'support contain matcher', '/etc/ssh/sshd_config', 'See the sshd_config(5) manpage'
24
- it_behaves_like 'support contain.from.to matcher', 'Gemfile', 'rspec', /^group :test do/, /^end/
25
- it_behaves_like 'support contain.after matcher', 'Gemfile', 'rspec', /^group :test do/
26
- it_behaves_like 'support contain.before matcher', 'Gemfile', 'rspec', /^end/
27
- it_behaves_like 'support match_md5checksum matcher', '/etc/services', '35435ea447c19f0ea5ef971837ab9ced'
28
- it_behaves_like 'support be_user matcher', 'root'
29
- it_behaves_like 'support be_group matcher', 'wheel'
30
-
31
- # Test for case of not registered in the service, but running as process.
32
- it_behaves_like 'support be_running matcher', 'udevd'
33
-
34
- it_behaves_like 'support be_mode matcher', '/etc/passwd', 644
35
-
36
- it_behaves_like 'support be_owned_by matcher', '/etc/passwd', 'root'
37
- it_behaves_like 'support be_grouped_into matcher', '/etc/passwd', 'root'
38
-
39
- it_behaves_like 'support have_cron_entry matcher', 'cron', '* * * * * /usr/bin/foo'
40
- it_behaves_like 'support have_cron_entry.with_user matcher', 'cron', '* * * * * /usr/bin/foo', 'root'
41
-
42
- it_behaves_like 'support be_linked_to matcher', '/etc/pam.d/system-auth', '/etc/pam.d/system-auth-ac'
43
-
44
- it_behaves_like 'support be_installed.by(gem) matcher', 'jekyll'
45
- it_behaves_like 'support be_installed.by(gem).with_version matcher', 'jekyll', '1.0.0'
46
- it_behaves_like 'support be_installed.by(npm) matcher', 'bower'
47
- it_behaves_like 'support be_installed.by(npm).with_version matcher', 'bower', '0.9.2'
48
-
49
- it_behaves_like 'support belong_to_group matcher', 'root', 'root'
50
- it_behaves_like 'support have_gid matcher', 'root', 0
51
- it_behaves_like 'support have_uid matcher', 'root', 0
52
- it_behaves_like 'support have_login_shell matcher', 'root', '/bin/bash'
53
- it_behaves_like 'support have_home_directory matcher', 'root', '/root'
54
- it_behaves_like 'support have_authorized_key matcher', 'root', 'ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH foo@bar.local'
55
-
56
- it_behaves_like 'support have_iptables_rule matcher', '-P INPUT ACCEPT'
57
- it_behaves_like 'support have_iptables_rule.with_table.with_chain matcher', '-P INPUT ACCEPT', 'mangle', 'INPUT'
58
-
59
- it_behaves_like 'support be_readable matcher', '/dev'
60
- it_behaves_like 'support be_readable_by_owner matcher', '/dev'
61
- it_behaves_like 'support be_readable_by_group matcher', '/dev'
62
- it_behaves_like 'support be_readable_by_others matcher', '/dev'
63
-
64
- it_behaves_like 'support be_writable matcher', '/dev'
65
- it_behaves_like 'support be_writable_by_owner matcher', '/dev'
66
- it_behaves_like 'support be_writable_by_group matcher', '/dev'
67
- it_behaves_like 'support be_writable_by_others matcher', '/dev'
68
-
69
- it_behaves_like 'support be_executable matcher', '/dev'
70
- it_behaves_like 'support be_executable_by_owner matcher', '/dev'
71
- it_behaves_like 'support be_executable_by_group matcher', '/dev'
72
- it_behaves_like 'support be_executable_by_others matcher', '/dev'
73
-
74
- it_behaves_like 'support be_readable_by_specific_user matcher', '/tmp', 'mail'
75
- it_behaves_like 'support be_writable_by_specific_user matcher', '/tmp', 'mail'
76
- it_behaves_like 'support be_executable_by_specific_user matcher', '/tmp', 'mail'
77
-
78
- it_behaves_like 'support return_exit_status matcher', 'ls /tmp', 0
79
-
80
- it_behaves_like 'support return_stdout matcher', 'cat /etc/resolv.conf', 'localhost'
81
- it_behaves_like 'support return_stdout matcher with regexp', 'cat /etc/resolv.conf', /localhost/
82
-
83
- it_behaves_like 'support return_stderr matcher', 'cat /foo', 'cat: /foo: No such file or directory'
84
- it_behaves_like 'support return_stderr matcher with regexp', 'cat /foo', /No such file or directory/
85
-
86
- it_behaves_like 'support linux kernel parameter checking with integer', 'net.ipv4.tcp_syncookies', 1
87
- it_behaves_like 'support linux kernel parameter checking with string', 'kernel.osrelease', '2.6.32-131.0.15.el6.x86_64'
88
- it_behaves_like 'support linux kernel parameter checking with regexp', 'net.ipv4.tcp_wmem', /4096\t16384\t4194304/
89
-
90
- it_behaves_like 'support have_entry matcher'
91
- it_behaves_like 'support be_default_gateway matcher'
92
- end
@@ -1,93 +0,0 @@
1
- require 'spec_helper'
2
-
3
- include Serverspec::Helper::Gentoo
4
-
5
- describe 'Serverspec matchers of Gentoo family' do
6
- it_behaves_like 'support be_enabled matcher', 'sshd'
7
- it_behaves_like 'support be_installed matcher', 'openssh'
8
- it_behaves_like 'support be_running matcher', 'sshd'
9
- it_behaves_like 'support be_running.under("supervisor") matcher', 'growthforecast'
10
- it_behaves_like 'support be_listening matcher', 22
11
- it_behaves_like 'support be_file matcher', '/etc/ssh/sshd_config'
12
-
13
- it_behaves_like 'support be_mounted matcher', '/'
14
- it_behaves_like 'support be_mounted.with matcher', '/'
15
- it_behaves_like 'support be_mounted.only_with matcher', '/'
16
-
17
- it_behaves_like 'support be_reachable matcher', '127.0.0.1'
18
- it_behaves_like 'support be_reachable.with matcher', '127.0.0.1'
19
-
20
- it_behaves_like 'support be_resolvable matcher', 'localhost'
21
- it_behaves_like 'support be_resolvable.by matcher', 'localhost', 'hosts'
22
- it_behaves_like 'support be_resolvable.by matcher', 'localhost', 'dns'
23
- it_behaves_like 'support be_directory matcher', '/etc/ssh'
24
- it_behaves_like 'support contain matcher', '/etc/ssh/sshd_config', 'This is the sshd server system-wide configuration file'
25
- it_behaves_like 'support contain.from.to matcher', 'Gemfile', 'rspec', /^group :test do/, /^end/
26
- it_behaves_like 'support contain.after matcher', 'Gemfile', 'rspec', /^group :test do/
27
- it_behaves_like 'support contain.before matcher', 'Gemfile', 'rspec', /^end/
28
- it_behaves_like 'support match_md5checksum matcher', '/etc/services', '35435ea447c19f0ea5ef971837ab9ced'
29
- it_behaves_like 'support be_user matcher', 'root'
30
- it_behaves_like 'support be_group matcher', 'wheel'
31
-
32
- # Test for case of not registered in the service, but running as process.
33
- it_behaves_like 'support be_running matcher', 'udevd'
34
-
35
- it_behaves_like 'support be_mode matcher', '/etc/passwd', 644
36
-
37
- it_behaves_like 'support be_owned_by matcher', '/etc/passwd', 'root'
38
- it_behaves_like 'support be_grouped_into matcher', '/etc/passwd', 'root'
39
-
40
- it_behaves_like 'support have_cron_entry matcher', 'cron', '* * * * * /usr/bin/foo'
41
- it_behaves_like 'support have_cron_entry.with_user matcher', 'cron', '* * * * * /usr/bin/foo', 'root'
42
-
43
- it_behaves_like 'support be_linked_to matcher', '/etc/pam.d/system-auth', '/etc/pam.d/system-auth-ac'
44
-
45
- it_behaves_like 'support be_installed.by(gem) matcher', 'jekyll'
46
- it_behaves_like 'support be_installed.by(gem).with_version matcher', 'jekyll', '1.0.0'
47
- it_behaves_like 'support be_installed.by(npm) matcher', 'bower'
48
- it_behaves_like 'support be_installed.by(npm).with_version matcher', 'bower', '0.9.2'
49
-
50
- it_behaves_like 'support belong_to_group matcher', 'root', 'root'
51
- it_behaves_like 'support have_gid matcher', 'root', 0
52
- it_behaves_like 'support have_uid matcher', 'root', 0
53
- it_behaves_like 'support have_login_shell matcher', 'root', '/bin/bash'
54
- it_behaves_like 'support have_home_directory matcher', 'root', '/root'
55
- it_behaves_like 'support have_authorized_key matcher', 'root', 'ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH foo@bar.local'
56
-
57
- it_behaves_like 'support have_iptables_rule matcher', '-P INPUT ACCEPT'
58
- it_behaves_like 'support have_iptables_rule.with_table.with_chain matcher', '-P INPUT ACCEPT', 'mangle', 'INPUT'
59
-
60
- it_behaves_like 'support be_readable matcher', '/dev'
61
- it_behaves_like 'support be_readable_by_owner matcher', '/dev'
62
- it_behaves_like 'support be_readable_by_group matcher', '/dev'
63
- it_behaves_like 'support be_readable_by_others matcher', '/dev'
64
-
65
- it_behaves_like 'support be_writable matcher', '/dev'
66
- it_behaves_like 'support be_writable_by_owner matcher', '/dev'
67
- it_behaves_like 'support be_writable_by_group matcher', '/dev'
68
- it_behaves_like 'support be_writable_by_others matcher', '/dev'
69
-
70
- it_behaves_like 'support be_executable matcher', '/dev'
71
- it_behaves_like 'support be_executable_by_owner matcher', '/dev'
72
- it_behaves_like 'support be_executable_by_group matcher', '/dev'
73
- it_behaves_like 'support be_executable_by_others matcher', '/dev'
74
-
75
- it_behaves_like 'support be_readable_by_specific_user matcher', '/tmp', 'mail'
76
- it_behaves_like 'support be_writable_by_specific_user matcher', '/tmp', 'mail'
77
- it_behaves_like 'support be_executable_by_specific_user matcher', '/tmp', 'mail'
78
-
79
- it_behaves_like 'support return_exit_status matcher', 'ls /tmp', 0
80
-
81
- it_behaves_like 'support return_stdout matcher', 'cat /etc/resolv.conf', 'localhost'
82
- it_behaves_like 'support return_stdout matcher with regexp', 'cat /etc/resolv.conf', /localhost/
83
-
84
- it_behaves_like 'support return_stderr matcher', 'cat /foo', 'cat: /foo: No such file or directory'
85
- it_behaves_like 'support return_stderr matcher with regexp', 'cat /foo', /No such file or directory/
86
-
87
- it_behaves_like 'support linux kernel parameter checking with integer', 'net.ipv4.tcp_syncookies', 1
88
- it_behaves_like 'support linux kernel parameter checking with string', 'kernel.osrelease', '2.6.32-131.0.15.el6.x86_64'
89
- it_behaves_like 'support linux kernel parameter checking with regexp', 'net.ipv4.tcp_wmem', /4096\t16384\t4194304/
90
-
91
- it_behaves_like 'support have_entry matcher'
92
- it_behaves_like 'support be_default_gateway matcher'
93
- end
@@ -1,98 +0,0 @@
1
- require 'spec_helper'
2
-
3
- include Serverspec::Helper::RedHat
4
-
5
- describe 'Serverspec matchers of Red Hat family' do
6
- it_behaves_like 'support be_enabled matcher', 'sshd'
7
- it_behaves_like 'support be_installed matcher', 'openssh'
8
- it_behaves_like 'support be_running matcher', 'sshd'
9
- it_behaves_like 'support be_running.under("supervisor") matcher', 'growthforecast'
10
- it_behaves_like 'support be_running.under("not implemented") matcher', 'growthforecast'
11
- it_behaves_like 'support be_listening matcher', 22
12
- it_behaves_like 'support be_file matcher', '/etc/ssh/sshd_config'
13
-
14
- it_behaves_like 'support be_mounted matcher', '/'
15
- it_behaves_like 'support be_mounted.with matcher', '/'
16
- it_behaves_like 'support be_mounted.only_with matcher', '/'
17
-
18
- it_behaves_like 'support be_reachable matcher', '127.0.0.1'
19
- it_behaves_like 'support be_reachable.with matcher', '127.0.0.1'
20
-
21
- it_behaves_like 'support be_resolvable matcher', 'localhost'
22
- it_behaves_like 'support be_resolvable.by matcher', 'localhost', 'hosts'
23
- it_behaves_like 'support be_resolvable.by matcher', 'localhost', 'dns'
24
- it_behaves_like 'support be_directory matcher', '/etc/ssh'
25
- it_behaves_like 'support contain matcher', '/etc/ssh/sshd_config', 'This is the sshd server system-wide configuration file'
26
- it_behaves_like 'support contain.from.to matcher', 'Gemfile', 'rspec', /^group :test do/, /^end/
27
- it_behaves_like 'support contain.after matcher', 'Gemfile', 'rspec', /^group :test do/
28
- it_behaves_like 'support contain.before matcher', 'Gemfile', 'rspec', /^end/
29
- it_behaves_like 'support match_md5checksum matcher', '/etc/services', '35435ea447c19f0ea5ef971837ab9ced'
30
- it_behaves_like 'support be_user matcher', 'root'
31
- it_behaves_like 'support be_group matcher', 'wheel'
32
-
33
- # Test for case of not registered in the service, but running as process.
34
- it_behaves_like 'support be_running matcher', 'udevd'
35
-
36
- it_behaves_like 'support be_mode matcher', '/etc/passwd', 644
37
-
38
- it_behaves_like 'support be_owned_by matcher', '/etc/passwd', 'root'
39
- it_behaves_like 'support be_grouped_into matcher', '/etc/passwd', 'root'
40
-
41
- it_behaves_like 'support have_cron_entry matcher', 'cron', '* * * * * /usr/bin/foo'
42
- it_behaves_like 'support have_cron_entry.with_user matcher', 'cron', '* * * * * /usr/bin/foo', 'root'
43
-
44
- it_behaves_like 'support be_linked_to matcher', '/etc/pam.d/system-auth', '/etc/pam.d/system-auth-ac'
45
-
46
- it_behaves_like 'support be_installed.by(gem) matcher', 'jekyll'
47
- it_behaves_like 'support be_installed.by(gem).with_version matcher', 'jekyll', '1.0.0'
48
- it_behaves_like 'support be_installed.by(npm) matcher', 'bower'
49
- it_behaves_like 'support be_installed.by(npm).with_version matcher', 'bower', '0.9.2'
50
-
51
- it_behaves_like 'support belong_to_group matcher', 'root', 'root'
52
- it_behaves_like 'support have_gid matcher', 'root', 0
53
- it_behaves_like 'support have_uid matcher', 'root', 0
54
- it_behaves_like 'support have_login_shell matcher', 'root', '/bin/bash'
55
- it_behaves_like 'support have_home_directory matcher', 'root', '/root'
56
- it_behaves_like 'support have_authorized_key matcher', 'root', 'ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH foo@bar.local'
57
-
58
- it_behaves_like 'support have_iptables_rule matcher', '-P INPUT ACCEPT'
59
- it_behaves_like 'support have_iptables_rule.with_table.with_chain matcher', '-P INPUT ACCEPT', 'mangle', 'INPUT'
60
-
61
- it_behaves_like 'support be_readable matcher', '/dev'
62
- it_behaves_like 'support be_readable_by_owner matcher', '/dev'
63
- it_behaves_like 'support be_readable_by_group matcher', '/dev'
64
- it_behaves_like 'support be_readable_by_others matcher', '/dev'
65
-
66
- it_behaves_like 'support be_writable matcher', '/dev'
67
- it_behaves_like 'support be_writable_by_owner matcher', '/dev'
68
- it_behaves_like 'support be_writable_by_group matcher', '/dev'
69
- it_behaves_like 'support be_writable_by_others matcher', '/dev'
70
-
71
- it_behaves_like 'support be_executable matcher', '/dev'
72
- it_behaves_like 'support be_executable_by_owner matcher', '/dev'
73
- it_behaves_like 'support be_executable_by_group matcher', '/dev'
74
- it_behaves_like 'support be_executable_by_others matcher', '/dev'
75
-
76
- it_behaves_like 'support be_readable_by_specific_user matcher', '/tmp', 'mail'
77
- it_behaves_like 'support be_writable_by_specific_user matcher', '/tmp', 'mail'
78
- it_behaves_like 'support be_executable_by_specific_user matcher', '/tmp', 'mail'
79
-
80
- it_behaves_like 'support be_enforcing matcher', 'selinux'
81
- it_behaves_like 'support be_permissive matcher', 'selinux'
82
- it_behaves_like 'support be_disabled matcher', 'selinux'
83
-
84
- it_behaves_like 'support return_exit_status matcher', 'ls /tmp', 0
85
-
86
- it_behaves_like 'support return_stdout matcher', 'cat /etc/resolv.conf', 'localhost'
87
- it_behaves_like 'support return_stdout matcher with regexp', 'cat /etc/resolv.conf', /localhost/
88
-
89
- it_behaves_like 'support return_stderr matcher', 'cat /foo', 'cat: /foo: No such file or directory'
90
- it_behaves_like 'support return_stderr matcher with regexp', 'cat /foo', /No such file or directory/
91
-
92
- it_behaves_like 'support linux kernel parameter checking with integer', 'net.ipv4.tcp_syncookies', 1
93
- it_behaves_like 'support linux kernel parameter checking with string', 'kernel.osrelease', '2.6.32-131.0.15.el6.x86_64'
94
- it_behaves_like 'support linux kernel parameter checking with regexp', 'net.ipv4.tcp_wmem', /4096\t16384\t4194304/
95
-
96
- it_behaves_like 'support have_entry matcher'
97
- it_behaves_like 'support be_default_gateway matcher'
98
- end
@@ -1,92 +0,0 @@
1
- require 'spec_helper'
2
-
3
- include Serverspec::Helper::Solaris
4
-
5
- describe 'Serverspec matchers of Solaris family' do
6
- it_behaves_like 'support be_enabled matcher', 'svc:/network/ssh:default'
7
- it_behaves_like 'support be_installed matcher', 'service/network/ssh'
8
- it_behaves_like 'support be_running matcher', 'svc:/network/ssh:default'
9
- it_behaves_like 'support be_running.under("supervisor") matcher', 'growthforecast'
10
- it_behaves_like 'support be_listening matcher', 22
11
- it_behaves_like 'support be_file matcher', '/etc/ssh/sshd_config'
12
-
13
- it_behaves_like 'support be_mounted matcher', '/'
14
- it_behaves_like 'support be_mounted.with matcher', '/'
15
- it_behaves_like 'support be_mounted.only_with matcher', '/'
16
-
17
- it_behaves_like 'support be_reachable matcher', '127.0.0.1'
18
- it_behaves_like 'support be_reachable.with matcher', '127.0.0.1'
19
-
20
- it_behaves_like 'support be_resolvable matcher', 'localhost'
21
- it_behaves_like 'support be_resolvable.by matcher', 'localhost', 'hosts'
22
- it_behaves_like 'support be_resolvable.by matcher', 'localhost', 'dns'
23
- it_behaves_like 'support be_directory matcher', '/etc/ssh'
24
- it_behaves_like 'support contain matcher', '/etc/ssh/sshd_config', 'Configuration file for sshd(1m) (see also sshd_config(4))'
25
- it_behaves_like 'support contain.from.to matcher', 'Gemfile', 'rspec', /^group :test do/, /^end/
26
- it_behaves_like 'support contain.after matcher', 'Gemfile', 'rspec', /^group :test do/
27
- it_behaves_like 'support contain.before matcher', 'Gemfile', 'rspec', /^end/
28
- it_behaves_like 'support match_md5checksum matcher', '/etc/services', '35435ea447c19f0ea5ef971837ab9ced'
29
- it_behaves_like 'support be_user matcher', 'root'
30
- it_behaves_like 'support be_group matcher', 'root'
31
-
32
- # Test for case of not registered in the service, but running as process.
33
- it_behaves_like 'support be_running matcher', 'udevd'
34
-
35
- it_behaves_like 'support be_mode matcher', '/etc/passwd', 644
36
-
37
- it_behaves_like 'support be_owned_by matcher', '/etc/passwd', 'root'
38
- it_behaves_like 'support be_grouped_into matcher', '/etc/passwd', 'root'
39
-
40
- it_behaves_like 'support have_cron_entry matcher', 'cron', '* * * * * /usr/bin/foo'
41
- it_behaves_like 'support have_cron_entry.with_user matcher', 'cron', '* * * * * /usr/bin/foo', 'root'
42
-
43
- it_behaves_like 'support be_linked_to matcher', '/etc/pam.d/system-auth', '/etc/pam.d/system-auth-ac'
44
-
45
- it_behaves_like 'support be_installed.by(gem) matcher', 'jekyll'
46
- it_behaves_like 'support be_installed.by(gem).with_version matcher', 'jekyll', '1.0.0'
47
- it_behaves_like 'support be_installed.by(npm) matcher', 'bower'
48
- it_behaves_like 'support be_installed.by(npm).with_version matcher', 'bower', '0.9.2'
49
-
50
- it_behaves_like 'support belong_to_group matcher', 'root', 'root'
51
- it_behaves_like 'support have_gid matcher', 'root', 0
52
- it_behaves_like 'support have_uid matcher', 'root', 0
53
- it_behaves_like 'support have_login_shell matcher', 'root', '/bin/bash'
54
- it_behaves_like 'support have_home_directory matcher', 'root', '/root'
55
- it_behaves_like 'support have_authorized_key matcher', 'root', 'ssh-rsa ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH foo@bar.local'
56
-
57
- it_behaves_like 'support be_zfs matcher', 'rpool'
58
- it_behaves_like 'support be_zfs.property matcher', 'rpool', { 'mountpoint' => '/rpool' }
59
-
60
- it_behaves_like 'support be_readable matcher', '/dev'
61
- it_behaves_like 'support be_readable_by_owner matcher', '/dev'
62
- it_behaves_like 'support be_readable_by_group matcher', '/dev'
63
- it_behaves_like 'support be_readable_by_others matcher', '/dev'
64
-
65
- it_behaves_like 'support be_writable matcher', '/dev'
66
- it_behaves_like 'support be_writable_by_owner matcher', '/dev'
67
- it_behaves_like 'support be_writable_by_group matcher', '/dev'
68
- it_behaves_like 'support be_writable_by_others matcher', '/dev'
69
-
70
- it_behaves_like 'support be_executable matcher', '/dev'
71
- it_behaves_like 'support be_executable_by_owner matcher', '/dev'
72
- it_behaves_like 'support be_executable_by_group matcher', '/dev'
73
- it_behaves_like 'support be_executable_by_others matcher', '/dev'
74
-
75
- it_behaves_like 'support have_ipfilter_rule matcher', 'pass in quick on lo0 all'
76
-
77
- it_behaves_like 'support have_ipnat_rule matcher', 'map net1 192.168.0.0/24 -> 0.0.0.0/32'
78
-
79
- it_behaves_like 'support have_svcprop.with_value matcher', 'svc:/network/http:apache22', 'httpd/server_type', 'worker'
80
- it_behaves_like 'support have_svcprops matcher', 'svc:/network/http:apache22', {'httpd/enable_64bit' => 'false', 'httpd/server_type' => 'worker' }
81
-
82
- it_behaves_like 'support return_exit_status matcher', 'ls /tmp', 0
83
-
84
- it_behaves_like 'support return_stdout matcher', 'cat /etc/resolv.conf', 'localhost'
85
- it_behaves_like 'support return_stdout matcher with regexp', 'cat /etc/resolv.conf', /localhost/
86
-
87
- it_behaves_like 'support return_stderr matcher', 'cat /foo', 'cat: /foo: No such file or directory'
88
- it_behaves_like 'support return_stderr matcher with regexp', 'cat /foo', /No such file or directory/
89
-
90
- it_behaves_like 'support have_entry matcher'
91
- it_behaves_like 'support be_default_gateway matcher'
92
- end
@@ -1,1310 +0,0 @@
1
-
2
- shared_examples_for 'support be_enabled matcher' do |valid_service|
3
- describe 'be_enabled' do
4
- describe valid_service do
5
- it { should be_enabled }
6
- end
7
-
8
- describe 'this-is-invalid-service' do
9
- it { should_not be_enabled }
10
- end
11
- end
12
- end
13
-
14
- shared_examples_for 'support be_installed matcher' do |valid_package|
15
- describe 'be_installed' do
16
- describe valid_package do
17
- it { should be_installed }
18
- end
19
-
20
- describe 'this-is-invalid-package' do
21
- it { should_not be_installed }
22
- end
23
- end
24
- end
25
-
26
- shared_examples_for 'support be_running matcher' do |valid_service|
27
- describe 'be_running' do
28
- describe valid_service do
29
- it { should be_running }
30
- end
31
-
32
- describe 'this-is-invalid-daemon' do
33
- it { should_not be_running }
34
- end
35
-
36
- describe valid_service do
37
- before :all do
38
- RSpec.configure do |c|
39
- c.stdout = "#{valid_service} is stopped\r\n"
40
- end
41
- end
42
- it { should be_running }
43
- end
44
- end
45
- end
46
-
47
- shared_examples_for 'support be_running.under("supervisor") matcher' do |valid_service|
48
- describe 'be_running.under("supervisor")' do
49
- describe valid_service do
50
- before :all do
51
- RSpec.configure do |c|
52
- c.stdout = "#{valid_service} RUNNING\r\n"
53
- end
54
- end
55
-
56
- it { should be_running.under('supervisor') }
57
- end
58
-
59
- describe valid_service do
60
- before :all do
61
- RSpec.configure do |c|
62
- c.stdout = "#{valid_service} STOPPED\r\n"
63
- end
64
- end
65
-
66
- it { should_not be_running.under('supervisor') }
67
- end
68
-
69
- describe 'this-is-invalid-daemon' do
70
- it { should_not be_running.under('supervisor') }
71
- end
72
- end
73
- end
74
-
75
- shared_examples_for 'support be_running.under("not implemented") matcher' do |valid_service|
76
- describe 'be_running.under("not implemented")' do
77
- it {
78
- expect {
79
- should be_running.under('not implemented')
80
- }.to raise_error(ArgumentError, %r/\A`be_running` matcher doesn\'t support/)
81
- }
82
- end
83
- end
84
-
85
- shared_examples_for 'support be_listening matcher' do |valid_port|
86
- describe 'be_listening' do
87
- describe "port #{ valid_port }" do
88
- it { should be_listening }
89
- end
90
-
91
- describe 'port invalid' do
92
- it { should_not be_listening }
93
- end
94
- end
95
- end
96
-
97
- shared_examples_for 'support be_reachable matcher' do |valid_host|
98
- describe 'be_reachable' do
99
- context valid_host do
100
- it { should be_reachable }
101
- end
102
-
103
- describe 'invalid-host' do
104
- it { should_not be_reachable }
105
- end
106
- end
107
- end
108
-
109
- shared_examples_for 'support be_reachable.with matcher' do |valid_host|
110
- describe 'be_reachable.with' do
111
- context valid_host do
112
- it { should be_reachable.with(:proto => "icmp", :timeout=> 1) }
113
- end
114
- context valid_host do
115
- it { should be_reachable.with(:proto => "tcp", :port => 22, :timeout=> 1) }
116
- end
117
- context valid_host do
118
- it { should be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) }
119
- end
120
- context 'invalid-host' do
121
- it { should_not be_reachable.with(:proto => "udp", :port => 53, :timeout=> 1) }
122
- end
123
- end
124
- end
125
-
126
- shared_examples_for 'support be_mounted matcher' do |valid_mount|
127
- describe 'be_mounted' do
128
- describe valid_mount do
129
- it { should be_mounted }
130
- end
131
-
132
- describe '/etc/thid_is_a_invalid_mount' do
133
- it { should_not be_mounted }
134
- end
135
- end
136
- end
137
-
138
- shared_examples_for 'support be_mounted.with matcher' do |valid_mount|
139
- describe 'be_mounted.with' do
140
- before :all do
141
- RSpec.configure do |c|
142
- c.stdout = "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n"
143
- end
144
- end
145
-
146
- describe valid_mount do
147
- it { should be_mounted.with( :type => 'ext4' ) }
148
- end
149
-
150
- describe valid_mount do
151
- it { should be_mounted.with( :type => 'ext4', :options => { :rw => true } ) }
152
- end
153
-
154
- describe valid_mount do
155
- it { should be_mounted.with( :type => 'ext4', :options => { :mode => 620 } ) }
156
- end
157
-
158
- describe valid_mount do
159
- it { should be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_root' ) }
160
- end
161
-
162
- describe valid_mount do
163
- it { should_not be_mounted.with( :type => 'xfs' ) }
164
- end
165
-
166
- describe valid_mount do
167
- it { should_not be_mounted.with( :type => 'ext4', :options => { :rw => false } ) }
168
- end
169
-
170
- describe valid_mount do
171
- it { should_not be_mounted.with( :type => 'ext4', :options => { :mode => 600 } ) }
172
- end
173
-
174
- describe valid_mount do
175
- it { should_not be_mounted.with( :type => 'xfs', :device => '/dev/mapper/VolGroup-lv_root' ) }
176
- end
177
-
178
- describe valid_mount do
179
- it { should_not be_mounted.with( :type => 'ext4', :device => '/dev/mapper/VolGroup-lv_r00t' ) }
180
- end
181
-
182
- describe '/etc/thid_is_a_invalid_mount' do
183
- it { should_not be_mounted.with( :type => 'ext4' ) }
184
- end
185
- end
186
- end
187
-
188
-
189
- shared_examples_for 'support be_mounted.only_with matcher' do |valid_mount|
190
- describe 'be_mounted.with' do
191
- before :all do
192
- RSpec.configure do |c|
193
- c.stdout = "/dev/mapper/VolGroup-lv_root on / type ext4 (rw,mode=620)\r\n"
194
- end
195
- end
196
-
197
- describe valid_mount do
198
- it do
199
- should be_mounted.only_with(
200
- :device => '/dev/mapper/VolGroup-lv_root',
201
- :type => 'ext4',
202
- :options => {
203
- :rw => true,
204
- :mode => 620,
205
- }
206
- )
207
- end
208
- end
209
-
210
- describe valid_mount do
211
- it do
212
- should_not be_mounted.only_with(
213
- :device => '/dev/mapper/VolGroup-lv_root',
214
- :type => 'ext4',
215
- :options => {
216
- :rw => true,
217
- :mode => 620,
218
- :bind => true,
219
- }
220
- )
221
- end
222
- end
223
-
224
- describe valid_mount do
225
- it do
226
- should_not be_mounted.only_with(
227
- :device => '/dev/mapper/VolGroup-lv_root',
228
- :type => 'ext4',
229
- :options => {
230
- :rw => true,
231
- }
232
- )
233
- end
234
- end
235
-
236
- describe valid_mount do
237
- it do
238
- should_not be_mounted.only_with(
239
- :device => '/dev/mapper/VolGroup-lv_roooooooooot',
240
- :type => 'ext4',
241
- :options => {
242
- :rw => true,
243
- :mode => 620,
244
- }
245
- )
246
- end
247
- end
248
-
249
- describe '/etc/thid_is_a_invalid_mount' do
250
- it { should_not be_mounted.only_with( :type => 'ext4' ) }
251
- end
252
- end
253
- end
254
-
255
-
256
- shared_examples_for 'support be_default_gateway matcher' do
257
- describe 'be_default_gateway' do
258
- before :all do
259
- RSpec.configure do |c|
260
- c.stdout = "default via 192.168.1.1 dev eth1 \r\n"
261
- end
262
- end
263
-
264
- describe '192.168.1.1' do
265
- it { should be_default_gateway }
266
- it { should be_default_gateway.with_interface('eth1') }
267
- it { should_not be_default_gateway.with_interface('eth0') }
268
- end
269
-
270
- describe '192.168.1.100' do
271
- it { should_not be_default_gateway }
272
- it { should_not be_default_gateway.with_interface('eth1') }
273
- end
274
- end
275
- end
276
-
277
- shared_examples_for 'support have_entry matcher' do
278
- describe 'have_entry' do
279
- before :all do
280
- RSpec.configure do |c|
281
- c.stdout = "192.168.100.0/24 dev eth1 proto kernel scope link src 192.168.100.10 \r\ndefault via 192.168.100.1 dev eth0 \r\n"
282
- end
283
- end
284
-
285
- describe 'routing table' do
286
- it { should have_entry( :destination => '192.168.100.0/24' ) }
287
- it { should_not have_entry( :destination => '192.168.100.100/24' ) }
288
-
289
- it do
290
- should have_entry(
291
- :destination => '192.168.100.0/24',
292
- :gateway => '192.168.100.1'
293
- )
294
- end
295
-
296
- it do
297
- should have_entry(
298
- :destination => '192.168.100.0/24',
299
- :gateway => '192.168.100.1',
300
- :interface => 'eth1'
301
- )
302
- end
303
-
304
- it do
305
- should_not have_entry(
306
- :gateway => '192.168.100.1',
307
- :interface => 'eth1'
308
- )
309
- end
310
-
311
- it do
312
- should_not have_entry(
313
- :destination => '192.168.100.0/32',
314
- :gateway => '192.168.100.1',
315
- :interface => 'eth1'
316
- )
317
- end
318
- end
319
- end
320
-
321
- describe 'have_entry' do
322
- before :all do
323
- RSpec.configure do |c|
324
- c.stdout = "192.168.200.0/24 via 192.168.200.1 dev eth0 \r\ndefault via 192.168.100.1 dev eth0 \r\n"
325
- end
326
- end
327
-
328
- describe 'routing table' do
329
- it { should have_entry( :destination => '192.168.200.0/24' ) }
330
- it { should_not have_entry( :destination => '192.168.200.200/24' ) }
331
-
332
- it do
333
- should have_entry(
334
- :destination => '192.168.200.0/24',
335
- :gateway => '192.168.200.1'
336
- )
337
- end
338
-
339
- it do
340
- should have_entry(
341
- :destination => '192.168.200.0/24',
342
- :gateway => '192.168.200.1',
343
- :interface => 'eth0'
344
- )
345
- end
346
-
347
- it do
348
- should_not have_entry(
349
- :gateway => '192.168.200.1',
350
- :interface => 'eth0'
351
- )
352
- end
353
-
354
- it do
355
- should_not have_entry(
356
- :destination => '192.168.200.0/32',
357
- :gateway => '192.168.200.1',
358
- :interface => 'eth0'
359
- )
360
- end
361
- end
362
- end
363
-
364
- describe 'have_entry' do
365
- before :all do
366
- RSpec.configure do |c|
367
- c.stdout = "default via 10.0.2.2 dev eth0 \r\n"
368
- end
369
- end
370
-
371
- describe 'routing table' do
372
- it { should have_entry( :destination => 'default' ) }
373
- it { should_not have_entry( :destination => 'defaulth' ) }
374
-
375
- it do
376
- should have_entry(
377
- :destination => 'default',
378
- :gateway => '10.0.2.2'
379
- )
380
- end
381
-
382
- it do
383
- should have_entry(
384
- :destination => 'default',
385
- :gateway => '10.0.2.2',
386
- :interface => 'eth0'
387
- )
388
- end
389
-
390
- it do
391
- should_not have_entry(
392
- :gateway => '10.0.2.2',
393
- :interface => 'eth0'
394
- )
395
- end
396
-
397
- it do
398
- should_not have_entry(
399
- :destination => 'default',
400
- :gateway => '10.0.2.1',
401
- :interface => 'eth0'
402
- )
403
- end
404
- end
405
- end
406
- end
407
-
408
-
409
- shared_examples_for 'support be_resolvable matcher' do |valid_name|
410
- describe 'be_resolvable' do
411
- describe valid_name do
412
- it { should be_resolvable }
413
- end
414
-
415
- describe 'invalid_name' do
416
- it { should_not be_resolvable }
417
- end
418
- end
419
- end
420
-
421
-
422
- shared_examples_for 'support be_resolvable.by matcher' do |valid_name, type|
423
- describe 'be_resolvable.by' do
424
- describe valid_name do
425
- it { should be_resolvable.by(type) }
426
- end
427
-
428
- describe 'invalid_name' do
429
- it { should_not be_resolvable.by(type) }
430
- end
431
- end
432
- end
433
-
434
- shared_examples_for 'support be_file matcher' do |valid_file|
435
- describe 'be_file' do
436
- describe valid_file do
437
- it { should be_file }
438
- end
439
-
440
- describe '/etc/thid_is_invalid_file' do
441
- it { should_not be_file }
442
- end
443
- end
444
- end
445
-
446
- shared_examples_for 'support be_directory matcher' do |valid_directory|
447
- describe 'be_directory' do
448
- describe valid_directory do
449
- it { should be_directory }
450
- end
451
-
452
- describe '/etc/thid_is_invalid_directory' do
453
- it { should_not be_directory }
454
- end
455
- end
456
- end
457
-
458
- shared_examples_for 'support contain matcher' do |valid_file, pattern|
459
- describe 'contain' do
460
- describe valid_file do
461
- it { should contain pattern }
462
- end
463
-
464
- describe '/etc/ssh/sshd_config' do
465
- it { should_not contain 'This is invalid text!!' }
466
- end
467
- end
468
- end
469
-
470
- shared_examples_for 'support contain.from.to matcher' do |valid_file, pattern, from, to|
471
- describe 'contain' do
472
- describe valid_file do
473
- it { should contain(pattern).from(from).to(to) }
474
- end
475
-
476
- describe '/etc/ssh/sshd_config' do
477
- it { should_not contain('This is invalid text!!').from(from).to(to) }
478
- end
479
- end
480
- end
481
-
482
- shared_examples_for 'support contain.after matcher' do |valid_file, pattern, after|
483
- describe 'contain' do
484
- describe valid_file do
485
- it { should contain(pattern).after(after) }
486
- end
487
-
488
- describe '/etc/ssh/sshd_config' do
489
- it { should_not contain('This is invalid text!!').after(after) }
490
- end
491
- end
492
- end
493
-
494
- shared_examples_for 'support contain.before matcher' do |valid_file, pattern, before|
495
- describe 'contain' do
496
- describe valid_file do
497
- it { should contain(pattern).before(before) }
498
- end
499
-
500
- describe '/etc/ssh/sshd_config' do
501
- it { should_not contain('This is invalid text!!').before(before) }
502
- end
503
- end
504
- end
505
-
506
- shared_examples_for 'support match_md5checksum matcher' do |valid_file, pattern|
507
- describe 'match_md5checksum' do
508
- describe valid_file do
509
- it { should match_md5checksum pattern }
510
- end
511
-
512
- describe '/invalid_file' do
513
- it { should_not match_md5checksum 'INVALIDMD5CHECKSUM' }
514
- end
515
- end
516
- end
517
-
518
- shared_examples_for 'support be_user matcher' do |valid_user|
519
- describe 'be_user' do
520
- describe valid_user do
521
- it { should be_user }
522
- end
523
-
524
- describe 'i_am_invalid_user' do
525
- it { should_not be_user }
526
- end
527
- end
528
- end
529
-
530
- shared_examples_for 'support be_group matcher' do |valid_group|
531
- describe 'be_group' do
532
- describe valid_group do
533
- it { should be_group }
534
- end
535
-
536
- describe 'we_are_invalid_group' do
537
- it { should_not be_group }
538
- end
539
- end
540
- end
541
-
542
- shared_examples_for 'support be_mode matcher' do |valid_file, mode|
543
- describe 'be_mode' do
544
- describe valid_file do
545
- it { should be_mode mode }
546
- end
547
-
548
- describe '/etc/passwd' do
549
- it { should_not be_mode 'invalid' }
550
- end
551
- end
552
- end
553
-
554
- shared_examples_for 'support be_owned_by matcher' do |valid_file, owner|
555
- describe 'be_owned_by' do
556
- describe valid_file do
557
- it { should be_owned_by owner }
558
- end
559
-
560
- describe '/etc/passwd' do
561
- it { should_not be_owned_by 'invalid-owner' }
562
- end
563
- end
564
- end
565
-
566
- shared_examples_for 'support be_grouped_into matcher' do |valid_file, group|
567
- describe 'be_grouped_into' do
568
- describe valid_file do
569
- it { should be_grouped_into group }
570
- end
571
-
572
- describe '/etc/passwd' do
573
- it { should_not be_grouped_into 'invalid-group' }
574
- end
575
- end
576
- end
577
-
578
- shared_examples_for 'support be_enforcing matcher' do |selinux|
579
- describe selinux do
580
- it { should be_enforcing }
581
- end
582
- end
583
-
584
- shared_examples_for 'support be_permissive matcher' do |selinux|
585
- describe selinux do
586
- it { should be_permissive }
587
- end
588
- end
589
-
590
- shared_examples_for 'support be_disabled matcher' do |selinux|
591
- describe selinux do
592
- it { should be_disabled }
593
- end
594
- end
595
-
596
- shared_examples_for 'support have_cron_entry matcher' do |title, entry|
597
- describe 'have_cron_entry' do
598
- describe title do
599
- it { should have_cron_entry entry }
600
- end
601
-
602
- describe '/etc/passwd' do
603
- it { should_not have_cron_entry 'invalid entry' }
604
- end
605
- end
606
- end
607
-
608
- shared_examples_for 'support have_cron_entry.with_user matcher' do |title, entry, user|
609
- describe 'have_cron_entry.with_user' do
610
- describe title do
611
- it { should have_cron_entry(entry).with_user(user) }
612
- end
613
-
614
- describe title do
615
- it { should_not have_cron_entry('dummy entry').with_user('invaliduser') }
616
- end
617
- end
618
- end
619
-
620
- shared_examples_for 'support be_linked_to matcher' do |file, target|
621
- describe 'be_linked_to' do
622
- describe file do
623
- it { should be_linked_to target }
624
- end
625
-
626
- describe 'this-is-dummy-link' do
627
- it { should_not be_linked_to '/invalid/target' }
628
- end
629
- end
630
- end
631
-
632
- shared_examples_for 'support be_installed.by(gem) matcher' do |name|
633
- describe 'be_installed.by(gem)' do
634
- describe name do
635
- it { should be_installed.by('gem') }
636
- end
637
-
638
- describe 'invalid-gem' do
639
- it { should_not be_installed.by('gem') }
640
- end
641
- end
642
- end
643
-
644
- shared_examples_for 'support be_installed.by(gem).with_version matcher' do |name, version|
645
- describe 'be_installed.by(gem).with_version' do
646
- describe name do
647
- it { should be_installed.by('gem').with_version(version) }
648
- end
649
-
650
- describe name do
651
- it { should_not be_installed.by('gem').with_version('invalid-version') }
652
- end
653
- end
654
- end
655
-
656
- shared_examples_for 'support be_installed.by(npm) matcher' do |name|
657
- describe 'be_installed.by(npm)' do
658
- describe name do
659
- it { should be_installed.by('npm') }
660
- end
661
-
662
- describe 'invalid-npm' do
663
- it { should_not be_installed.by('npm') }
664
- end
665
- end
666
- end
667
-
668
- shared_examples_for 'support be_installed.by(npm).with_version matcher' do |name, version|
669
- describe 'be_installed.by(npm).with_version' do
670
- describe name do
671
- it { should be_installed.by('npm').with_version(version) }
672
- end
673
-
674
- describe name do
675
- it { should_not be_installed.by('npm').with_version('invalid-version') }
676
- end
677
- end
678
- end
679
-
680
- shared_examples_for 'support belong_to_group matcher' do |user, group|
681
- describe 'belong_to_group' do
682
- describe user do
683
- it { should belong_to_group group }
684
- end
685
-
686
- describe 'dummyuser' do
687
- it { should_not belong_to_group 'invalid-group' }
688
- end
689
- end
690
- end
691
-
692
- shared_examples_for 'support have_gid matcher' do |group, gid|
693
- describe 'have_gid' do
694
- describe group do
695
- it { should have_gid gid }
696
- end
697
-
698
- describe 'dummygroup' do
699
- it { should_not have_gid 'invalid-gid' }
700
- end
701
- end
702
- end
703
-
704
- shared_examples_for 'support have_uid matcher' do |user, uid|
705
- describe 'have_uid' do
706
- describe user do
707
- it { should have_uid uid }
708
- end
709
-
710
- describe 'dummyuser' do
711
- it { should_not have_uid 'invalid-uid' }
712
- end
713
- end
714
- end
715
-
716
- shared_examples_for 'support have_login_shell matcher' do |user, path_to_shell|
717
- describe 'have_login_shell' do
718
- describe user do
719
- it { should have_login_shell path_to_shell }
720
- end
721
-
722
- describe 'dummyuser' do
723
- it { should_not have_login_shell 'invalid-login-shell' }
724
- end
725
- end
726
- end
727
-
728
- shared_examples_for 'support have_home_directory matcher' do |user, path_to_home|
729
- describe 'have_home_directory' do
730
- describe user do
731
- it { should have_home_directory path_to_home }
732
- end
733
-
734
- describe 'dummyuser' do
735
- it { should_not have_home_directory 'invalid-home-directory' }
736
- end
737
- end
738
- end
739
-
740
- shared_examples_for 'support have_authorized_key matcher' do |user, key|
741
- describe 'have_authorized_key' do
742
- describe user do
743
- it { should have_authorized_key key }
744
- end
745
-
746
- describe user do
747
- it { should_not have_authorized_key 'invalid-publickey' }
748
- end
749
-
750
- describe 'dummyuser' do
751
- it { should_not have_authorized_key 'invalid-publickey' }
752
- end
753
- end
754
- end
755
-
756
- shared_examples_for 'support have_iptables_rule matcher' do |rule|
757
- describe 'have_iptables_rule' do
758
- describe 'iptables' do
759
- it { should have_iptables_rule rule }
760
- end
761
-
762
- describe 'iptables' do
763
- it { should_not have_iptables_rule 'invalid-rule' }
764
- end
765
- end
766
- end
767
-
768
- shared_examples_for 'support have_iptables_rule.with_table.with_chain matcher' do |rule, table, chain|
769
- describe 'have_iptables_rule.with_table.with_chain' do
770
- describe 'iptables' do
771
- it { should have_iptables_rule(rule).with_table(table).with_chain(chain) }
772
- end
773
-
774
- describe 'iptables' do
775
- it { should_not have_iptables_rule('invalid-rule').with_table(table).with_chain(chain) }
776
- end
777
- end
778
- end
779
-
780
- shared_examples_for 'support be_zfs matcher' do |zfs|
781
- describe 'be_zfs' do
782
- describe zfs do
783
- it { should be_zfs }
784
- end
785
-
786
- describe 'this-is-invalid-zfs' do
787
- it { should_not be_zfs }
788
- end
789
- end
790
- end
791
-
792
- shared_examples_for 'support be_zfs.property matcher' do |zfs, property|
793
- describe 'be_zfs' do
794
- describe zfs do
795
- it { should be_zfs.with(property) }
796
- end
797
-
798
- describe 'this-is-invalid-zfs' do
799
- it { should_not be_zfs.with(property) }
800
- end
801
- end
802
- end
803
-
804
- shared_examples_for 'support be_readable matcher' do |file|
805
- describe 'be_readable' do
806
- describe file do
807
- before :all do
808
- RSpec.configure do |c|
809
- c.stdout = "755\r\n"
810
- end
811
- end
812
- it { should be_readable }
813
- end
814
-
815
- describe file do
816
- before :all do
817
- RSpec.configure do |c|
818
- c.stdout = "333\r\n"
819
- end
820
- end
821
- it { should_not be_readable }
822
- end
823
- end
824
- end
825
-
826
- shared_examples_for 'support be_readable_by_owner matcher' do |file|
827
- describe 'be_readable_by_owner' do
828
- describe file do
829
- before :all do
830
- RSpec.configure do |c|
831
- c.stdout = "400\r\n"
832
- end
833
- end
834
- it { should be_readable.by('owner') }
835
- end
836
-
837
- describe file do
838
- before :all do
839
- RSpec.configure do |c|
840
- c.stdout = "044\r\n"
841
- end
842
- end
843
- it { should_not be_readable.by('owner') }
844
- end
845
- end
846
- end
847
-
848
- shared_examples_for 'support be_readable_by_group matcher' do |file|
849
- describe 'be_readable_by_group' do
850
- describe file do
851
- before :all do
852
- RSpec.configure do |c|
853
- c.stdout = "040\r\n"
854
- end
855
- end
856
- it { should be_readable.by('group') }
857
- end
858
-
859
- describe file do
860
- before :all do
861
- RSpec.configure do |c|
862
- c.stdout = "404\r\n"
863
- end
864
- end
865
- it { should_not be_readable.by('group') }
866
- end
867
- end
868
- end
869
-
870
- shared_examples_for 'support be_readable_by_others matcher' do |file|
871
- describe 'be_readable_by_others' do
872
- describe file do
873
- before :all do
874
- RSpec.configure do |c|
875
- c.stdout = "044\r\n"
876
- end
877
- end
878
- it { should be_readable.by('others') }
879
- end
880
-
881
- describe file do
882
- before :all do
883
- RSpec.configure do |c|
884
- c.stdout = "443\r\n"
885
- end
886
- end
887
- it { should_not be_readable.by('others') }
888
- end
889
- end
890
- end
891
-
892
- shared_examples_for 'support be_readable_by_specific_user matcher' do |file, user|
893
- describe 'be_readable_by_specific_user' do
894
- describe file do
895
- it { should be_readable.by_user(user) }
896
- end
897
- describe file+'_invalid' do
898
- it { should_not be_readable.by_user(user) }
899
- end
900
- end
901
- end
902
-
903
- shared_examples_for 'support be_writable matcher' do |file|
904
- describe 'be_writable' do
905
- describe file do
906
- before :all do
907
- RSpec.configure do |c|
908
- c.stdout = "755\r\n"
909
- end
910
- end
911
- it { should be_writable }
912
- end
913
-
914
- describe file do
915
- before :all do
916
- RSpec.configure do |c|
917
- c.stdout = "555\r\n"
918
- end
919
- end
920
- it { should_not be_writable }
921
- end
922
- end
923
- end
924
-
925
- shared_examples_for 'support be_writable_by_owner matcher' do |file|
926
- describe 'be_writable_by_owner' do
927
- describe file do
928
- before :all do
929
- RSpec.configure do |c|
930
- c.stdout = "200\r\n"
931
- end
932
- end
933
- it { should be_writable.by('owner') }
934
- end
935
-
936
- describe file do
937
- before :all do
938
- RSpec.configure do |c|
939
- c.stdout = "555\r\n"
940
- end
941
- end
942
- it { should_not be_writable.by('owner') }
943
- end
944
- end
945
- end
946
-
947
- shared_examples_for 'support be_writable_by_group matcher' do |file|
948
- describe 'be_writable_by_group' do
949
- describe file do
950
- before :all do
951
- RSpec.configure do |c|
952
- c.stdout = "030\r\n"
953
- end
954
- end
955
- it { should be_writable.by('group') }
956
- end
957
-
958
- describe file do
959
- before :all do
960
- RSpec.configure do |c|
961
- c.stdout = "555\r\n"
962
- end
963
- end
964
- it { should_not be_writable.by('group') }
965
- end
966
- end
967
- end
968
-
969
- shared_examples_for 'support be_writable_by_others matcher' do |file|
970
- describe 'be_writable_by_others' do
971
- describe file do
972
- before :all do
973
- RSpec.configure do |c|
974
- c.stdout = "666\r\n"
975
- end
976
- end
977
- it { should be_writable.by('others') }
978
- end
979
-
980
- describe file do
981
- before :all do
982
- RSpec.configure do |c|
983
- c.stdout = "555\r\n"
984
- end
985
- end
986
- it { should_not be_writable.by('others') }
987
- end
988
- end
989
- end
990
-
991
- shared_examples_for 'support be_writable_by_specific_user matcher' do |file, user|
992
- describe 'be_writable_by_specific_user' do
993
- describe file do
994
- it { should be_writable.by_user(user) }
995
- end
996
- describe 'invalid-file' do
997
- it { should_not be_writable.by_user(user) }
998
- end
999
- end
1000
- end
1001
-
1002
- shared_examples_for 'support be_executable matcher' do |file|
1003
- describe 'be_executable' do
1004
- describe file do
1005
- before :all do
1006
- RSpec.configure do |c|
1007
- c.stdout = "755\r\n"
1008
- end
1009
- end
1010
- it { should be_executable }
1011
- end
1012
-
1013
- describe file do
1014
- before :all do
1015
- RSpec.configure do |c|
1016
- c.stdout = "666\r\n"
1017
- end
1018
- end
1019
- it { should_not be_executable }
1020
- end
1021
- end
1022
- end
1023
-
1024
- shared_examples_for 'support be_executable_by_owner matcher' do |file|
1025
- describe 'be_executable_by_owner' do
1026
- describe file do
1027
- before :all do
1028
- RSpec.configure do |c|
1029
- c.stdout = "100\r\n"
1030
- end
1031
- end
1032
- it { should be_executable.by('owner') }
1033
- end
1034
-
1035
- describe file do
1036
- before :all do
1037
- RSpec.configure do |c|
1038
- c.stdout = "666\r\n"
1039
- end
1040
- end
1041
- it { should_not be_executable.by('owner') }
1042
- end
1043
- end
1044
- end
1045
-
1046
- shared_examples_for 'support be_executable_by_group matcher' do |file|
1047
- describe 'be_executable_by_group' do
1048
- describe file do
1049
- before :all do
1050
- RSpec.configure do |c|
1051
- c.stdout = "070\r\n"
1052
- end
1053
- end
1054
- it { should be_executable.by('group') }
1055
- end
1056
-
1057
- describe file do
1058
- before :all do
1059
- RSpec.configure do |c|
1060
- c.stdout = "666\r\n"
1061
- end
1062
- end
1063
- it { should_not be_executable.by('group') }
1064
- end
1065
- end
1066
- end
1067
-
1068
- shared_examples_for 'support be_executable_by_others matcher' do |file|
1069
- describe 'be_executable_by_others' do
1070
- describe file do
1071
- before :all do
1072
- RSpec.configure do |c|
1073
- c.stdout = "001\r\n"
1074
- end
1075
- end
1076
- it { should be_executable.by('others') }
1077
- end
1078
-
1079
- describe file do
1080
- before :all do
1081
- RSpec.configure do |c|
1082
- c.stdout = "666\r\n"
1083
- end
1084
- end
1085
- it { should_not be_executable.by('others') }
1086
- end
1087
- end
1088
- end
1089
-
1090
- shared_examples_for 'support be_executable_by_specific_user matcher' do |file, user|
1091
- describe 'be_writable_by_specific_user' do
1092
- describe file do
1093
- it { should be_executable.by_user(user) }
1094
- end
1095
- describe file+'_invalid' do
1096
- it { should_not be_executable.by_user(user) }
1097
- end
1098
- end
1099
- end
1100
-
1101
- shared_examples_for 'support have_ipfilter_rule matcher' do |rule|
1102
- describe 'have_ipfilter_rule' do
1103
- describe 'ipfilter' do
1104
- it { should have_ipfilter_rule rule }
1105
- end
1106
-
1107
- describe 'ipfilter' do
1108
- it { should_not have_ipfilter_rule 'invalid-rule' }
1109
- end
1110
- end
1111
- end
1112
-
1113
- shared_examples_for 'support have_ipnat_rule matcher' do |rule|
1114
- describe 'have_ipnat_rule' do
1115
- describe 'ipnat' do
1116
- it { should have_ipnat_rule rule }
1117
- end
1118
-
1119
- describe 'ipnat' do
1120
- it { should_not have_ipnat_rule 'invalid-rule' }
1121
- end
1122
- end
1123
- end
1124
-
1125
- shared_examples_for 'support have_svcprop.with_value matcher' do |svc, property, value|
1126
- describe 'have_svcprop' do
1127
- describe svc do
1128
- it { should have_svcprop(property).with_value(value) }
1129
- end
1130
-
1131
- describe 'this-is-invalid-svc' do
1132
- it { should_not have_svcprop(property).with_value(value) }
1133
- end
1134
- end
1135
- end
1136
-
1137
- shared_examples_for 'support have_svcprops matcher' do |svc, property|
1138
- describe 'have_svcprop' do
1139
- describe svc do
1140
- it { should have_svcprops(property) }
1141
- end
1142
-
1143
- describe 'this-is-invalid-svc' do
1144
- it { should_not have_svcprops(property) }
1145
- end
1146
- end
1147
- end
1148
-
1149
- shared_examples_for 'support return_exit_status matcher' do |command, status|
1150
- describe 'return_exit_status' do
1151
- describe command do
1152
- it { should return_exit_status(status) }
1153
- end
1154
-
1155
- describe 'this-is-invalid-command' do
1156
- it { should_not return_exit_status(status) }
1157
- end
1158
- end
1159
- end
1160
-
1161
- shared_examples_for 'support return_stdout matcher' do |command, content|
1162
- describe 'return_stdout' do
1163
- describe command do
1164
- before :all do
1165
- RSpec.configure do |c|
1166
- c.stdout = "#{content}\r\n"
1167
- end
1168
- end
1169
- it { should return_stdout(content) }
1170
- end
1171
-
1172
- describe command do
1173
- before :all do
1174
- RSpec.configure do |c|
1175
- c.stdout = "foo#{content}bar\r\n"
1176
- end
1177
- end
1178
- it { should_not return_stdout(content) }
1179
- end
1180
-
1181
-
1182
- describe 'this-is-invalid-command' do
1183
- it { should_not return_stdout(content) }
1184
- end
1185
- end
1186
- end
1187
-
1188
- shared_examples_for 'support return_stdout matcher with regexp' do |command, content|
1189
- describe 'return_stdout' do
1190
- describe command do
1191
- before :all do
1192
- RSpec.configure do |c|
1193
- c.stdout = "foo#{content}bar\r\n"
1194
- end
1195
- end
1196
- it { should return_stdout(content) }
1197
- end
1198
-
1199
- describe command do
1200
- before :all do
1201
- RSpec.configure do |c|
1202
- c.stdout = "foobar\r\n"
1203
- end
1204
- end
1205
- it { should_not return_stdout(content) }
1206
- end
1207
-
1208
- describe 'this-is-invalid-command' do
1209
- it { should_not return_stdout(content) }
1210
- end
1211
- end
1212
- end
1213
-
1214
- shared_examples_for 'support return_stderr matcher' do |command, content|
1215
- describe 'return_stderr' do
1216
- describe command do
1217
- before :all do
1218
- RSpec.configure do |c|
1219
- c.stderr = "#{content}\r\n"
1220
- end
1221
- end
1222
- it { should return_stderr(content) }
1223
- end
1224
-
1225
- describe command do
1226
- before :all do
1227
- RSpec.configure do |c|
1228
- c.stderr = "No such file or directory\r\n"
1229
- end
1230
- end
1231
- it { should_not return_stderr(content) }
1232
- end
1233
- end
1234
- end
1235
-
1236
- shared_examples_for 'support return_stderr matcher with regexp' do |command, content|
1237
- describe 'return_stderr' do
1238
- describe command do
1239
- before :all do
1240
- RSpec.configure do |c|
1241
- c.stdout = "cat: /foo: No such file or directory\r\n"
1242
- end
1243
- end
1244
- it { should return_stdout(content) }
1245
- end
1246
-
1247
- describe command do
1248
- before :all do
1249
- RSpec.configure do |c|
1250
- c.stdout = "foobar\r\n"
1251
- end
1252
- end
1253
- it { should_not return_stdout(content) }
1254
- end
1255
- end
1256
- end
1257
-
1258
- shared_examples_for 'support linux kernel parameter checking with integer' do |param, value|
1259
- describe 'linux kernel parameter' do
1260
- before :all do
1261
- RSpec.configure do |c|
1262
- c.stdout = "#{value}\n"
1263
- end
1264
- end
1265
-
1266
- context param do
1267
- its(:value) { should eq value }
1268
- end
1269
-
1270
- context param do
1271
- its(:value) { should_not eq value + 1 }
1272
- end
1273
- end
1274
- end
1275
-
1276
- shared_examples_for 'support linux kernel parameter checking with string' do |param, value|
1277
- describe 'linux kernel parameter' do
1278
- before :all do
1279
- RSpec.configure do |c|
1280
- c.stdout = "#{value}\n"
1281
- end
1282
- end
1283
-
1284
- context param do
1285
- its(:value) { should eq value }
1286
- end
1287
-
1288
- context param do
1289
- its(:value) { should_not eq value + '_suffix' }
1290
- end
1291
- end
1292
- end
1293
-
1294
- shared_examples_for 'support linux kernel parameter checking with regexp' do |param, regexp|
1295
- describe 'linux kernel parameter' do
1296
- before :all do
1297
- RSpec.configure do |c|
1298
- c.stdout = "4096 16384 4194304\n"
1299
- end
1300
- end
1301
-
1302
- context param do
1303
- its(:value) { should match regexp }
1304
- end
1305
-
1306
- context param do
1307
- its(:value) { should_not match /invalid-string/ }
1308
- end
1309
- end
1310
- end