serverspec 1.16.0 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (246) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -2
  3. data/Rakefile +20 -25
  4. data/lib/serverspec.rb +0 -3
  5. data/lib/serverspec/helper/os.rb +0 -3
  6. data/lib/serverspec/helper/type.rb +3 -3
  7. data/lib/serverspec/matchers.rb +1 -7
  8. data/lib/serverspec/matchers/have_rule.rb +1 -1
  9. data/lib/serverspec/setup.rb +12 -11
  10. data/lib/serverspec/type/file.rb +0 -15
  11. data/lib/serverspec/type/iis_app_pool.rb +0 -28
  12. data/lib/serverspec/type/iis_website.rb +0 -12
  13. data/lib/serverspec/type/interface.rb +0 -3
  14. data/lib/serverspec/type/user.rb +0 -4
  15. data/lib/serverspec/version.rb +1 -1
  16. data/serverspec.gemspec +4 -3
  17. data/wercker.yml +9 -9
  18. metadata +36 -471
  19. data/lib/serverspec/matchers/belong_to_primary_group.rb +0 -5
  20. data/lib/serverspec/matchers/have_site_application.rb +0 -18
  21. data/lib/serverspec/matchers/have_site_bindings.rb +0 -22
  22. data/lib/serverspec/matchers/have_virtual_dir.rb +0 -14
  23. data/lib/serverspec/type/ip6tables.rb +0 -13
  24. data/lib/serverspec/type/ppa.rb +0 -13
  25. data/lib/serverspec/type/windows_scheduled_task.rb +0 -9
  26. data/spec/aix/command_spec.rb +0 -65
  27. data/spec/aix/cron_spec.rb +0 -21
  28. data/spec/aix/default_gateway_spec.rb +0 -16
  29. data/spec/aix/file_spec.rb +0 -404
  30. data/spec/aix/group_spec.rb +0 -21
  31. data/spec/aix/host_spec.rb +0 -58
  32. data/spec/aix/package_spec.rb +0 -100
  33. data/spec/aix/php_config_spec.rb +0 -36
  34. data/spec/aix/port_spec.rb +0 -30
  35. data/spec/aix/process_spec.rb +0 -29
  36. data/spec/aix/routing_table_spec.rb +0 -120
  37. data/spec/aix/service_spec.rb +0 -93
  38. data/spec/aix/user_spec.rb +0 -57
  39. data/spec/arch/file_spec.rb +0 -413
  40. data/spec/arch/package_spec.rb +0 -100
  41. data/spec/arch/service_spec.rb +0 -84
  42. data/spec/backend/cmd/configuration_spec.rb +0 -9
  43. data/spec/backend/exec/configuration_spec.rb +0 -61
  44. data/spec/backend/powershell/script_helper_spec.rb +0 -105
  45. data/spec/backend/ssh/configuration_spec.rb +0 -184
  46. data/spec/backend/winrm/configuration_spec.rb +0 -9
  47. data/spec/darwin/command_spec.rb +0 -65
  48. data/spec/darwin/cron_spec.rb +0 -21
  49. data/spec/darwin/default_gateway_spec.rb +0 -16
  50. data/spec/darwin/file_spec.rb +0 -413
  51. data/spec/darwin/group_spec.rb +0 -21
  52. data/spec/darwin/host_spec.rb +0 -58
  53. data/spec/darwin/mail_alias_spec.rb +0 -12
  54. data/spec/darwin/package_spec.rb +0 -82
  55. data/spec/darwin/php_config_spec.rb +0 -36
  56. data/spec/darwin/port_spec.rb +0 -30
  57. data/spec/darwin/process_spec.rb +0 -29
  58. data/spec/darwin/routing_table_spec.rb +0 -120
  59. data/spec/darwin/service_spec.rb +0 -91
  60. data/spec/darwin/user_spec.rb +0 -57
  61. data/spec/debian/cgroup_spec.rb +0 -14
  62. data/spec/debian/command_spec.rb +0 -65
  63. data/spec/debian/cron_spec.rb +0 -21
  64. data/spec/debian/default_gateway_spec.rb +0 -16
  65. data/spec/debian/file_spec.rb +0 -413
  66. data/spec/debian/group_spec.rb +0 -22
  67. data/spec/debian/host_spec.rb +0 -58
  68. data/spec/debian/interface_spec.rb +0 -24
  69. data/spec/debian/ip6tables_spec.rb +0 -21
  70. data/spec/debian/iptables_spec.rb +0 -21
  71. data/spec/debian/kernel_module_spec.rb +0 -12
  72. data/spec/debian/linux_kernel_parameter_spec.rb +0 -36
  73. data/spec/debian/lxc_spec.rb +0 -22
  74. data/spec/debian/mail_alias_spec.rb +0 -12
  75. data/spec/debian/package_spec.rb +0 -130
  76. data/spec/debian/php_config_spec.rb +0 -36
  77. data/spec/debian/port_spec.rb +0 -40
  78. data/spec/debian/process_spec.rb +0 -29
  79. data/spec/debian/routing_table_spec.rb +0 -120
  80. data/spec/debian/selinux_spec.rb +0 -18
  81. data/spec/debian/service_spec.rb +0 -93
  82. data/spec/debian/user_spec.rb +0 -57
  83. data/spec/debian/zfs_spec.rb +0 -18
  84. data/spec/fedora/cgroup_spec.rb +0 -14
  85. data/spec/fedora/command_spec.rb +0 -67
  86. data/spec/fedora/cron_spec.rb +0 -21
  87. data/spec/fedora/default_gateway_spec.rb +0 -16
  88. data/spec/fedora/file_spec.rb +0 -413
  89. data/spec/fedora/group_spec.rb +0 -21
  90. data/spec/fedora/host_spec.rb +0 -58
  91. data/spec/fedora/interface_spec.rb +0 -24
  92. data/spec/fedora/ip6tables_spec.rb +0 -21
  93. data/spec/fedora/iptables_spec.rb +0 -21
  94. data/spec/fedora/kernel_module_spec.rb +0 -12
  95. data/spec/fedora/linux_kernel_parameter_spec.rb +0 -36
  96. data/spec/fedora/lxc_spec.rb +0 -22
  97. data/spec/fedora/mail_alias_spec.rb +0 -12
  98. data/spec/fedora/package_spec.rb +0 -118
  99. data/spec/fedora/php_config_spec.rb +0 -36
  100. data/spec/fedora/port_spec.rb +0 -30
  101. data/spec/fedora/process_spec.rb +0 -41
  102. data/spec/fedora/routing_table_spec.rb +0 -120
  103. data/spec/fedora/selinux_spec.rb +0 -18
  104. data/spec/fedora/user_spec.rb +0 -57
  105. data/spec/fedora/yumrepo_spec.rb +0 -25
  106. data/spec/fedora/zfs_spec.rb +0 -18
  107. data/spec/freebsd/command_spec.rb +0 -65
  108. data/spec/freebsd/cron_spec.rb +0 -21
  109. data/spec/freebsd/default_gateway_spec.rb +0 -16
  110. data/spec/freebsd/file_spec.rb +0 -385
  111. data/spec/freebsd/group_spec.rb +0 -21
  112. data/spec/freebsd/host_spec.rb +0 -58
  113. data/spec/freebsd/package_spec.rb +0 -96
  114. data/spec/freebsd/php_config_spec.rb +0 -36
  115. data/spec/freebsd/port_spec.rb +0 -30
  116. data/spec/freebsd/process_spec.rb +0 -29
  117. data/spec/freebsd/routing_table_spec.rb +0 -120
  118. data/spec/freebsd/service_spec.rb +0 -93
  119. data/spec/freebsd/user_spec.rb +0 -57
  120. data/spec/freebsd10/package_spec.rb +0 -13
  121. data/spec/gentoo/cgroup_spec.rb +0 -14
  122. data/spec/gentoo/command_spec.rb +0 -65
  123. data/spec/gentoo/cron_spec.rb +0 -21
  124. data/spec/gentoo/default_gateway_spec.rb +0 -16
  125. data/spec/gentoo/file_spec.rb +0 -413
  126. data/spec/gentoo/group_spec.rb +0 -21
  127. data/spec/gentoo/host_spec.rb +0 -58
  128. data/spec/gentoo/interface_spec.rb +0 -24
  129. data/spec/gentoo/ip6tables_spec.rb +0 -21
  130. data/spec/gentoo/iptables_spec.rb +0 -21
  131. data/spec/gentoo/kernel_module_spec.rb +0 -12
  132. data/spec/gentoo/linux_kernel_parameter_spec.rb +0 -36
  133. data/spec/gentoo/lxc_spec.rb +0 -22
  134. data/spec/gentoo/mail_alias_spec.rb +0 -12
  135. data/spec/gentoo/package_spec.rb +0 -91
  136. data/spec/gentoo/php_config_spec.rb +0 -36
  137. data/spec/gentoo/port_spec.rb +0 -30
  138. data/spec/gentoo/process_spec.rb +0 -29
  139. data/spec/gentoo/routing_table_spec.rb +0 -120
  140. data/spec/gentoo/selinux_spec.rb +0 -18
  141. data/spec/gentoo/service_spec.rb +0 -93
  142. data/spec/gentoo/user_spec.rb +0 -57
  143. data/spec/gentoo/zfs_spec.rb +0 -18
  144. data/spec/nixos/file_spec.rb +0 -421
  145. data/spec/nixos/package_spec.rb +0 -109
  146. data/spec/nixos/service_spec.rb +0 -40
  147. data/spec/plamo/cgroup_spec.rb +0 -14
  148. data/spec/plamo/command_spec.rb +0 -65
  149. data/spec/plamo/cron_spec.rb +0 -21
  150. data/spec/plamo/default_gateway_spec.rb +0 -16
  151. data/spec/plamo/file_spec.rb +0 -413
  152. data/spec/plamo/group_spec.rb +0 -22
  153. data/spec/plamo/host_spec.rb +0 -58
  154. data/spec/plamo/interface_spec.rb +0 -24
  155. data/spec/plamo/ip6tables_spec.rb +0 -21
  156. data/spec/plamo/iptables_spec.rb +0 -21
  157. data/spec/plamo/kernel_module_spec.rb +0 -12
  158. data/spec/plamo/linux_kernel_parameter_spec.rb +0 -36
  159. data/spec/plamo/lxc_spec.rb +0 -22
  160. data/spec/plamo/mail_alias_spec.rb +0 -12
  161. data/spec/plamo/package_spec.rb +0 -100
  162. data/spec/plamo/php_config_spec.rb +0 -36
  163. data/spec/plamo/port_spec.rb +0 -30
  164. data/spec/plamo/routing_table_spec.rb +0 -120
  165. data/spec/plamo/selinux_spec.rb +0 -18
  166. data/spec/plamo/service_spec.rb +0 -84
  167. data/spec/plamo/user_spec.rb +0 -57
  168. data/spec/plamo/zfs_spec.rb +0 -18
  169. data/spec/redhat/cgroup_spec.rb +0 -14
  170. data/spec/redhat/command_spec.rb +0 -67
  171. data/spec/redhat/cron_spec.rb +0 -21
  172. data/spec/redhat/default_gateway_spec.rb +0 -16
  173. data/spec/redhat/file_spec.rb +0 -418
  174. data/spec/redhat/group_spec.rb +0 -21
  175. data/spec/redhat/host_spec.rb +0 -64
  176. data/spec/redhat/interface_spec.rb +0 -24
  177. data/spec/redhat/ip6tables_spec.rb +0 -21
  178. data/spec/redhat/iptables_spec.rb +0 -21
  179. data/spec/redhat/kernel_module_spec.rb +0 -12
  180. data/spec/redhat/linux_kernel_parameter_spec.rb +0 -36
  181. data/spec/redhat/lxc_spec.rb +0 -22
  182. data/spec/redhat/mail_alias_spec.rb +0 -12
  183. data/spec/redhat/package_spec.rb +0 -118
  184. data/spec/redhat/php_config_spec.rb +0 -36
  185. data/spec/redhat/port_spec.rb +0 -30
  186. data/spec/redhat/process_spec.rb +0 -41
  187. data/spec/redhat/routing_table_spec.rb +0 -120
  188. data/spec/redhat/selinux_spec.rb +0 -18
  189. data/spec/redhat/service_spec.rb +0 -93
  190. data/spec/redhat/user_spec.rb +0 -57
  191. data/spec/redhat/yumrepo_spec.rb +0 -25
  192. data/spec/redhat/zfs_spec.rb +0 -18
  193. data/spec/redhat7/service_spec.rb +0 -21
  194. data/spec/smartos/mail_alias_spec.rb +0 -12
  195. data/spec/smartos/process_spec.rb +0 -29
  196. data/spec/solaris/command_spec.rb +0 -65
  197. data/spec/solaris/cron_spec.rb +0 -21
  198. data/spec/solaris/default_gateway_spec.rb +0 -16
  199. data/spec/solaris/file_spec.rb +0 -413
  200. data/spec/solaris/group_spec.rb +0 -21
  201. data/spec/solaris/host_spec.rb +0 -58
  202. data/spec/solaris/ipfilter_spec.rb +0 -8
  203. data/spec/solaris/ipnat_spec.rb +0 -8
  204. data/spec/solaris/mail_alias_spec.rb +0 -12
  205. data/spec/solaris/package_spec.rb +0 -100
  206. data/spec/solaris/php_config_spec.rb +0 -36
  207. data/spec/solaris/port_spec.rb +0 -30
  208. data/spec/solaris/process_spec.rb +0 -29
  209. data/spec/solaris/routing_table_spec.rb +0 -120
  210. data/spec/solaris/service_spec.rb +0 -93
  211. data/spec/solaris/svcprop_spec.rb +0 -13
  212. data/spec/solaris/user_spec.rb +0 -57
  213. data/spec/solaris/zfs_spec.rb +0 -18
  214. data/spec/solaris10/file_spec.rb +0 -395
  215. data/spec/solaris10/group_spec.rb +0 -21
  216. data/spec/solaris10/mail_alias_spec.rb +0 -12
  217. data/spec/solaris10/package_spec.rb +0 -85
  218. data/spec/solaris10/php_config_spec.rb +0 -36
  219. data/spec/solaris10/user_spec.rb +0 -57
  220. data/spec/solaris11/command_spec.rb +0 -65
  221. data/spec/solaris11/cron_spec.rb +0 -21
  222. data/spec/solaris11/default_gateway_spec.rb +0 -16
  223. data/spec/solaris11/file_spec.rb +0 -413
  224. data/spec/solaris11/group_spec.rb +0 -21
  225. data/spec/solaris11/host_spec.rb +0 -58
  226. data/spec/solaris11/ipfilter_spec.rb +0 -8
  227. data/spec/solaris11/ipnat_spec.rb +0 -8
  228. data/spec/solaris11/mail_alias_spec.rb +0 -12
  229. data/spec/solaris11/package_spec.rb +0 -100
  230. data/spec/solaris11/php_config_spec.rb +0 -36
  231. data/spec/solaris11/port_spec.rb +0 -12
  232. data/spec/solaris11/routing_table_spec.rb +0 -120
  233. data/spec/solaris11/service_spec.rb +0 -93
  234. data/spec/solaris11/svcprop_spec.rb +0 -13
  235. data/spec/solaris11/user_spec.rb +0 -57
  236. data/spec/solaris11/zfs_spec.rb +0 -18
  237. data/spec/support/powershell_command_runner.rb +0 -52
  238. data/spec/ubuntu/ppa_spec.rb +0 -25
  239. data/spec/windows/command_spec.rb +0 -67
  240. data/spec/windows/file_spec.rb +0 -161
  241. data/spec/windows/group_spec.rb +0 -28
  242. data/spec/windows/port_spec.rb +0 -31
  243. data/spec/windows/service_spec.rb +0 -31
  244. data/spec/windows/user_spec.rb +0 -44
  245. data/spec/windows/windows_hot_fix_spec.rb +0 -25
  246. data/spec/windows/windows_registry_key_spec.rb +0 -66
@@ -1,100 +0,0 @@
1
- require 'spec_helper'
2
-
3
- include SpecInfra::Helper::Arch
4
-
5
- describe package('curl') do
6
- it { should be_installed }
7
- its(:command) { should eq "pacman -Q | grep curl" }
8
- end
9
-
10
- describe package('invalid-package') do
11
- it { should_not be_installed }
12
- end
13
-
14
- describe package('curl') do
15
- it { should be_installed.with_version('7.37.0-1') }
16
- its(:command) { should eq "pacman -Q | grep curl 7.37.0-1" }
17
- end
18
-
19
- package('invalid-package') do
20
- it { should_not be_installed.by('pacman') }
21
- end
22
-
23
- describe package('jekyll') do
24
- it { should be_installed.by('gem') }
25
- its(:command) { should eq "gem list --local | grep -w -- \\^jekyll" }
26
- end
27
-
28
- describe package('invalid-gem') do
29
- it { should_not be_installed.by('gem') }
30
- end
31
-
32
- describe package('jekyll') do
33
- it { should be_installed.by('gem').with_version('1.1.1') }
34
- its(:command) { should eq "gem list --local | grep -w -- \\^jekyll | grep -w -- 1.1.1" }
35
- end
36
-
37
- describe package('jekyll') do
38
- it { should_not be_installed.by('gem').with_version('invalid-version') }
39
- end
40
-
41
- describe package('bower') do
42
- it { should be_installed.by('npm') }
43
- its(:command) { should eq "npm ls bower -g" }
44
- end
45
-
46
- describe package('invalid-npm-package') do
47
- it { should_not be_installed.by('npm') }
48
- end
49
-
50
- describe package('bower') do
51
- it { should be_installed.by('npm').with_version('0.9.2') }
52
- its(:command) { should eq "npm ls bower -g | grep -w -- 0.9.2" }
53
- end
54
-
55
- describe package('bower') do
56
- it { should_not be_installed.by('npm').with_version('invalid-version') }
57
- end
58
-
59
-
60
- describe package('mongo') do
61
- it { should be_installed.by('pecl') }
62
- its(:command) { should eq "pecl list | grep -w -- \\^mongo" }
63
- end
64
-
65
- describe package('invalid-pecl') do
66
- it { should_not be_installed.by('pecl') }
67
- end
68
-
69
- describe package('mongo') do
70
- it { should be_installed.by('pecl').with_version('1.4.1') }
71
- its(:command) { should eq "pecl list | grep -w -- \\^mongo | grep -w -- 1.4.1" }
72
- end
73
-
74
- describe package('mongo') do
75
- it { should_not be_installed.by('pecl').with_version('invalid-version') }
76
- end
77
-
78
- describe package('XML_Util') do
79
- it { should be_installed.by('pear').with_version('1.2.1') }
80
- its(:command) { should eq "pear list | grep -w -- \\^XML_Util | grep -w -- 1.2.1" }
81
- end
82
-
83
- describe package('supervisor') do
84
- it { should be_installed.by('pip').with_version('3.0') }
85
- its(:command) { should eq "pip list | grep -w -- \\^supervisor | grep -w -- 3.0" }
86
- end
87
-
88
- describe package('invalid-pip') do
89
- it { should_not be_installed.by('pip').with_version('invalid-version') }
90
- end
91
-
92
- describe package('App::Ack') do
93
- it { should be_installed.by('cpan') }
94
- its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack" }
95
- end
96
-
97
- describe package('App::Ack') do
98
- it { should be_installed.by('cpan').with_version('2.04') }
99
- its(:command) { should eq "cpan -l | grep -w -- \\^App::Ack | grep -w -- 2.04" }
100
- end
@@ -1,84 +0,0 @@
1
- require 'spec_helper'
2
-
3
- include SpecInfra::Helper::Arch
4
-
5
- describe service('sshd') do
6
- it { should be_enabled }
7
- its(:command) { should eq "systemctl --plain list-dependencies multi-user.target | grep '^sshd.service$'" }
8
- end
9
-
10
- describe service('invalid-service') do
11
- it { should_not be_enabled }
12
- end
13
-
14
- describe service('sshd') do
15
- it { should be_enabled.with_level("graphical.target") }
16
- its(:command) { should eq "systemctl --plain list-dependencies graphical.target | grep '^sshd.service$'" }
17
- end
18
-
19
- describe service('invalid-service') do
20
- it { should_not be_enabled.with_level(4) }
21
- end
22
-
23
- describe service('sshd') do
24
- it { should be_running }
25
- its(:command) { should eq "systemctl is-active sshd.service" }
26
- end
27
-
28
- describe service('invalid-daemon') do
29
- it { should_not be_running }
30
- end
31
-
32
- describe service('sshd') do
33
- let(:stdout) { "sshd is stopped\r\n" }
34
- it { should be_running }
35
- end
36
-
37
- describe service('sshd') do
38
- it { should be_running.under('supervisor') }
39
- its(:command) { should eq "supervisorctl status sshd | grep RUNNING" }
40
- end
41
-
42
- describe service('invalid-daemon') do
43
- it { should_not be_running.under('supervisor') }
44
- end
45
-
46
- describe service('sshd') do
47
- it {
48
- expect {
49
- should be_running.under('not implemented')
50
- }.to raise_error(ArgumentError, %r/\A`be_running` matcher doesn\'t support/)
51
- }
52
- end
53
-
54
- describe service('sshd') do
55
- let(:stdout) { "Process 'sshd'\r\n status running\r\n monitoring status monitored" }
56
- it { should be_monitored_by('monit') }
57
- its(:command) { should eq "monit status" }
58
- end
59
-
60
- describe service('sshd') do
61
- let(:stdout) { "Process 'sshd'\r\n status not monitored\r\n monitoring status not monitored" }
62
- it { should_not be_monitored_by('monit') }
63
- end
64
-
65
- describe service('invalid-daemon') do
66
- it { should_not be_monitored_by('monit') }
67
- end
68
-
69
- describe service('unicorn') do
70
- it { should be_monitored_by('god') }
71
- its(:command) { should eq "god status unicorn" }
72
- end
73
-
74
- describe service('invalid-daemon') do
75
- it { should_not be_monitored_by('god') }
76
- end
77
-
78
- describe service('sshd') do
79
- it {
80
- expect {
81
- should be_monitored_by('not implemented')
82
- }.to raise_error(ArgumentError, %r/\A`be_monitored_by` matcher doesn\'t support/)
83
- }
84
- end
@@ -1,9 +0,0 @@
1
- require 'spec_helper'
2
- require 'support/powershell_command_runner'
3
-
4
- include SpecInfra::Helper::Cmd
5
- include SpecInfra::Helper::Windows
6
-
7
- describe "Cmd" do
8
- it_behaves_like "a powershell command runner"
9
- end
@@ -1,61 +0,0 @@
1
- require 'spec_helper'
2
-
3
- include SpecInfra::Helper::RedHat
4
- include SpecInfra::Helper::Exec
5
-
6
- describe 'configurations are not set' do
7
- context file('/etc/passwd') do
8
- it { should be_file }
9
- its(:command) { should eq 'test -f /etc/passwd' }
10
- end
11
- end
12
-
13
- describe 'path is set' do
14
- let(:path) { '/sbin:/usr/sbin' }
15
- context file('/etc/passwd') do
16
- it { should be_file }
17
- its(:command) { should eq 'env PATH=/sbin:/usr/sbin:$PATH test -f /etc/passwd' }
18
- end
19
- end
20
-
21
- describe 'path is reset to nil' do
22
- context file('/etc/passwd') do
23
- it { should be_file }
24
- its(:command) { should eq 'test -f /etc/passwd' }
25
- end
26
- end
27
-
28
- describe 'pre_command is set' do
29
- let(:pre_command) { 'source ~/.zshrc' }
30
- context file('/etc/passwd') do
31
- it { should be_file }
32
- its(:command) { should eq 'source ~/.zshrc && test -f /etc/passwd' }
33
- end
34
- end
35
-
36
- describe 'path and pre_command are set' do
37
- let(:path) { '/sbin:/usr/sbin' }
38
- let(:pre_command) { 'source ~/.zshrc' }
39
- context file('/etc/passwd') do
40
- it { should be_file }
41
- its(:command) { should eq 'env PATH=/sbin:/usr/sbin:$PATH source ~/.zshrc && env PATH=/sbin:/usr/sbin:$PATH test -f /etc/passwd' }
42
- end
43
- end
44
-
45
- describe 'path is set for check_selinux' do
46
- let(:path) { '/sbin:/usr/sbin' }
47
- context selinux do
48
- it { should be_disabled }
49
- its(:command) { should eq "env PATH=/sbin:/usr/sbin:$PATH test ! -f /etc/selinux/config || (env PATH=/sbin:/usr/sbin:$PATH getenforce | grep -i -- disabled && env PATH=/sbin:/usr/sbin:$PATH grep -i -- ^SELINUX=disabled$ /etc/selinux/config)" }
50
- end
51
-
52
- context selinux do
53
- it { should be_enforcing }
54
- its(:command) { should eq "env PATH=/sbin:/usr/sbin:$PATH getenforce | grep -i -- enforcing && env PATH=/sbin:/usr/sbin:$PATH grep -i -- ^SELINUX=enforcing$ /etc/selinux/config" }
55
- end
56
-
57
- context selinux do
58
- it { should be_permissive }
59
- its(:command) { should eq "env PATH=/sbin:/usr/sbin:$PATH getenforce | grep -i -- permissive && env PATH=/sbin:/usr/sbin:$PATH grep -i -- ^SELINUX=permissive$ /etc/selinux/config" }
60
- end
61
- end
@@ -1,105 +0,0 @@
1
- require 'spec_helper'
2
-
3
- include SpecInfra::Backend::PowerShell::ScriptHelper
4
-
5
- describe 'build command with path' do
6
- before :each do
7
- RSpec.configure do |c|
8
- c.path = 'c:/test/path/bin'
9
- end
10
- end
11
-
12
- it "should prefix the command with the path instruction" do
13
- cmd = build_command('run_script -f param')
14
- cmd.should eq <<-eof
15
- $env:path = "c:/test/path/bin;$env:path"
16
- run_script -f param
17
- eof
18
- end
19
-
20
- after :each do
21
- RSpec.configure do |c|
22
- c.path = nil
23
- end
24
- end
25
- end
26
-
27
- describe 'add pre-command' do
28
- before :each do
29
- SpecInfra.configuration.pre_command = 'test_pre_command'
30
- end
31
-
32
- it "should add the test for pre_command before the command" do
33
- cmd = add_pre_command('run_script -f param')
34
- cmd.should eq <<-eof
35
- if (test_pre_command)
36
- {
37
- run_script -f param
38
- }
39
- eof
40
- end
41
-
42
- context "with path" do
43
- before :each do
44
- RSpec.configure do |c|
45
- c.path = 'c:/test/path/bin'
46
- end
47
- end
48
-
49
- it "should add the path instruction and the test for pre_command before the command" do
50
- cmd = add_pre_command('run_script -f param')
51
- cmd.should eq <<-eof
52
- $env:path = "c:/test/path/bin;$env:path"
53
- if (test_pre_command)
54
- {
55
- run_script -f param
56
- }
57
- eof
58
- end
59
-
60
- after :each do
61
- RSpec.configure do |c|
62
- c.path = nil
63
- end
64
- end
65
- end
66
-
67
- after :each do
68
- SpecInfra.configuration.pre_command = nil
69
- end
70
- end
71
-
72
- describe "script encoding" do
73
- it "should encode the given script" do
74
- script = encode_script("test_powershell_script")
75
- script.should == "dABlAHMAdABfAHAAbwB3AGUAcgBzAGgAZQBsAGwAXwBzAGMAcgBpAHAAdAA="
76
- end
77
- end
78
-
79
- describe 'script creation' do
80
- context "powershell command" do
81
- File.should_receive(:read).with(/test_function1.ps1/).and_return 'function test1'
82
- command = Backend::PowerShell::Command.new do
83
- using 'test_function1.ps1'
84
- exec 'test command'
85
- end
86
- script = create_script command
87
- script.should == <<-eof
88
- $exitCode = 1
89
- $ProgressPreference = "SilentlyContinue"
90
- try {
91
- function test1
92
- $success = (test command)
93
- if ($success -is [Boolean] -and $success) { $exitCode = 0 }
94
- } catch {
95
- Write-Output $_.Exception.Message
96
- }
97
- Write-Output "Exiting with code: $exitCode"
98
- exit $exitCode
99
- eof
100
- end
101
-
102
- context 'simple command' do
103
- create_script('test command').should == 'test command'
104
- end
105
- end
@@ -1,184 +0,0 @@
1
- require 'spec_helper'
2
-
3
- include SpecInfra::Helper::RedHat
4
- include SpecInfra::Helper::Ssh
5
-
6
- ssh = double
7
-
8
- describe 'configurations are not set' do
9
- before :all do
10
- RSpec.configure do |c|
11
- ssh.stub(:options) { { :user => 'root' } }
12
- c.ssh = ssh
13
- end
14
- end
15
-
16
- context file('/etc/passwd') do
17
- it { should be_file }
18
- its(:command) { should eq 'test -f /etc/passwd' }
19
- end
20
- end
21
-
22
- describe 'path is set' do
23
- before :all do
24
- RSpec.configure do |c|
25
- ssh.stub(:options) { { :user => 'root' } }
26
- c.ssh = ssh
27
- end
28
- end
29
-
30
- let(:path) { '/sbin:/usr/sbin' }
31
- context file('/etc/passwd') do
32
- it { should be_file }
33
- its(:command) { should eq 'env PATH=/sbin:/usr/sbin:$PATH test -f /etc/passwd' }
34
- end
35
- end
36
-
37
- describe 'pre_command is set and user is root' do
38
- before :all do
39
- RSpec.configure do |c|
40
- ssh.stub(:options) { { :user => 'root' } }
41
- c.ssh = ssh
42
- end
43
- end
44
-
45
- let(:pre_command) { 'source ~/.zshrc' }
46
- context file('/etc/passwd') do
47
- it { should be_file }
48
- its(:command) { should eq 'source ~/.zshrc && test -f /etc/passwd' }
49
- end
50
- end
51
-
52
- describe 'pre_command is set and user is non-root' do
53
- before :all do
54
- RSpec.configure do |c|
55
- ssh.stub(:options) { { :user => 'foo' } }
56
- c.ssh = ssh
57
- end
58
- end
59
-
60
- let(:pre_command) { 'source ~/.zshrc' }
61
- context file('/etc/passwd') do
62
- it { should be_file }
63
- its(:command) { should eq 'sudo source ~/.zshrc && sudo test -f /etc/passwd' }
64
- end
65
- end
66
-
67
- describe 'pre_command is not set and user is non-root' do
68
- before :all do
69
- RSpec.configure do |c|
70
- ssh.stub(:options) { { :user => 'foo' } }
71
- c.ssh = ssh
72
- end
73
- end
74
-
75
- context file('/etc/passwd') do
76
- it { should be_file }
77
- its(:command) { should eq 'sudo test -f /etc/passwd' }
78
- end
79
- end
80
-
81
-
82
- describe 'path pre_command and set and user is non-root' do
83
- before :all do
84
- RSpec.configure do |c|
85
- ssh.stub(:options) { { :user => 'foo' } }
86
- c.ssh = ssh
87
- end
88
- end
89
-
90
- let(:path) { '/sbin:/usr/sbin' }
91
- let(:pre_command) { 'source ~/.zshrc' }
92
- context file('/etc/passwd') do
93
- it { should be_file }
94
- its(:command) { should eq 'sudo env PATH=/sbin:/usr/sbin:$PATH source ~/.zshrc && sudo env PATH=/sbin:/usr/sbin:$PATH test -f /etc/passwd' }
95
- end
96
- end
97
-
98
- describe 'path pre_command and set and user is non-root' do
99
- before :all do
100
- RSpec.configure do |c|
101
- ssh.stub(:options) { { :user => 'root' } }
102
- c.ssh = ssh
103
- end
104
- end
105
-
106
- let(:path) { '/sbin:/usr/sbin' }
107
- let(:pre_command) { 'source ~/.zshrc' }
108
- context file('/etc/passwd') do
109
- it { should be_file }
110
- its(:command) { should eq 'env PATH=/sbin:/usr/sbin:$PATH source ~/.zshrc && env PATH=/sbin:/usr/sbin:$PATH test -f /etc/passwd' }
111
- end
112
- end
113
-
114
- describe 'user is non-root for check_selinux' do
115
- context selinux do
116
- before :all do
117
- RSpec.configure do |c|
118
- ssh.stub(:options) { { :user => 'foo' } }
119
- c.ssh = ssh
120
- end
121
- end
122
- it { should be_disabled }
123
- its(:command) { should eq "sudo test ! -f /etc/selinux/config || (sudo getenforce | grep -i -- disabled && sudo grep -i -- ^SELINUX=disabled$ /etc/selinux/config)" }
124
- end
125
-
126
- context selinux do
127
- before :all do
128
- RSpec.configure do |c|
129
- ssh.stub(:options) { { :user => 'foo' } }
130
- c.ssh = ssh
131
- end
132
- end
133
- it { should be_enforcing }
134
- its(:command) { should eq "sudo getenforce | grep -i -- enforcing && sudo grep -i -- ^SELINUX=enforcing$ /etc/selinux/config" }
135
- end
136
-
137
- context selinux do
138
- before :all do
139
- RSpec.configure do |c|
140
- ssh.stub(:options) { { :user => 'foo' } }
141
- c.ssh = ssh
142
- end
143
- end
144
- it { should be_permissive }
145
- its(:command) { should eq "sudo getenforce | grep -i -- permissive && sudo grep -i -- ^SELINUX=permissive$ /etc/selinux/config" }
146
- end
147
- end
148
-
149
- describe 'path is set and user is non-root for check_selinux' do
150
- let(:path) { "/sbin:/usr/sbin" }
151
-
152
- context selinux do
153
- before :all do
154
- RSpec.configure do |c|
155
- ssh.stub(:options) { { :user => 'foo' } }
156
- c.ssh = ssh
157
- end
158
- end
159
- it { should be_disabled }
160
- its(:command) { should eq "sudo env PATH=/sbin:/usr/sbin:$PATH test ! -f /etc/selinux/config || (sudo env PATH=/sbin:/usr/sbin:$PATH getenforce | grep -i -- disabled && sudo env PATH=/sbin:/usr/sbin:$PATH grep -i -- ^SELINUX=disabled$ /etc/selinux/config)" }
161
- end
162
-
163
- context selinux do
164
- before :all do
165
- RSpec.configure do |c|
166
- ssh.stub(:options) { { :user => 'foo' } }
167
- c.ssh = ssh
168
- end
169
- end
170
- it { should be_enforcing }
171
- its(:command) { should eq "sudo env PATH=/sbin:/usr/sbin:$PATH getenforce | grep -i -- enforcing && sudo env PATH=/sbin:/usr/sbin:$PATH grep -i -- ^SELINUX=enforcing$ /etc/selinux/config" }
172
- end
173
-
174
- context selinux do
175
- before :all do
176
- RSpec.configure do |c|
177
- ssh.stub(:options) { { :user => 'foo' } }
178
- c.ssh = ssh
179
- end
180
- end
181
- it { should be_permissive }
182
- its(:command) { should eq "sudo env PATH=/sbin:/usr/sbin:$PATH getenforce | grep -i -- permissive && sudo env PATH=/sbin:/usr/sbin:$PATH grep -i -- ^SELINUX=permissive$ /etc/selinux/config" }
183
- end
184
- end