inspec 0.30.0 → 0.31.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (316) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +50 -2
  3. data/Gemfile +2 -1
  4. data/docs/cli.rst +1 -17
  5. data/docs/resources.rst +128 -0
  6. data/docs/shell.rst +130 -0
  7. data/inspec.gemspec +3 -4
  8. data/lib/bundles/inspec-compliance/.kitchen.yml +0 -1
  9. data/lib/bundles/inspec-compliance/README.md +8 -3
  10. data/lib/bundles/inspec-compliance/api.rb +21 -6
  11. data/lib/bundles/inspec-compliance/bootstrap.sh +13 -9
  12. data/lib/bundles/inspec-compliance/cli.rb +23 -19
  13. data/lib/bundles/inspec-compliance/target.rb +1 -0
  14. data/lib/bundles/inspec-compliance/test/integration/default/cli.rb +42 -5
  15. data/lib/bundles/inspec-init/cli.rb +9 -0
  16. data/lib/bundles/inspec-supermarket/cli.rb +9 -0
  17. data/lib/bundles/inspec-supermarket/target.rb +2 -1
  18. data/lib/fetchers/local.rb +5 -2
  19. data/lib/fetchers/url.rb +1 -0
  20. data/lib/inspec/base_cli.rb +2 -1
  21. data/lib/inspec/cli.rb +14 -5
  22. data/lib/inspec/dependencies/dependency_set.rb +38 -0
  23. data/lib/inspec/dependencies/requirement.rb +103 -0
  24. data/lib/inspec/{dependencies.rb → dependencies/resolver.rb} +13 -132
  25. data/lib/inspec/dependencies/vendor_index.rb +98 -0
  26. data/lib/inspec/plugins/source_reader.rb +4 -0
  27. data/lib/inspec/profile.rb +2 -2
  28. data/lib/inspec/resource.rb +2 -0
  29. data/lib/inspec/runner.rb +13 -1
  30. data/lib/inspec/runner_mock.rb +4 -0
  31. data/lib/inspec/runner_rspec.rb +6 -2
  32. data/lib/inspec/shell.rb +22 -1
  33. data/lib/inspec/version.rb +1 -1
  34. data/lib/resources/iis_site.rb +107 -0
  35. data/lib/resources/port.rb +11 -4
  36. data/lib/resources/ssh_conf.rb +10 -2
  37. data/lib/resources/ssl.rb +94 -0
  38. data/lib/resources/xinetd.rb +11 -2
  39. data/lib/utils/parser.rb +6 -1
  40. metadata +17 -561
  41. data/lib/utils/hash_map.rb +0 -37
  42. data/tasks/maintainers.rb +0 -213
  43. data/test/bench/startup/startup.flat.txt +0 -1005
  44. data/test/bench/startup/startup.graph.html +0 -71958
  45. data/test/bench/startup/startup.grind.dat +0 -101602
  46. data/test/bench/startup/startup.stack.html +0 -24516
  47. data/test/bench/startup.flat.txt +0 -998
  48. data/test/bench/startup.graph.html +0 -71420
  49. data/test/bench/startup.grind.dat +0 -103554
  50. data/test/bench/startup.stack.html +0 -25015
  51. data/test/cookbooks/os_prepare/attributes/default.rb +0 -2
  52. data/test/cookbooks/os_prepare/files/empty.iso +0 -0
  53. data/test/cookbooks/os_prepare/files/example.csv +0 -7
  54. data/test/cookbooks/os_prepare/files/example.ini +0 -6
  55. data/test/cookbooks/os_prepare/files/example.json +0 -12
  56. data/test/cookbooks/os_prepare/files/example.yml +0 -7
  57. data/test/cookbooks/os_prepare/metadata.rb +0 -13
  58. data/test/cookbooks/os_prepare/recipes/_runit_service_centos.rb +0 -34
  59. data/test/cookbooks/os_prepare/recipes/_upstart_service_centos.rb +0 -25
  60. data/test/cookbooks/os_prepare/recipes/apache.rb +0 -14
  61. data/test/cookbooks/os_prepare/recipes/apt.rb +0 -20
  62. data/test/cookbooks/os_prepare/recipes/auditctl.rb +0 -8
  63. data/test/cookbooks/os_prepare/recipes/default.rb +0 -29
  64. data/test/cookbooks/os_prepare/recipes/file.rb +0 -46
  65. data/test/cookbooks/os_prepare/recipes/iptables.rb +0 -13
  66. data/test/cookbooks/os_prepare/recipes/json_yaml_csv_ini.rb +0 -34
  67. data/test/cookbooks/os_prepare/recipes/mount.rb +0 -33
  68. data/test/cookbooks/os_prepare/recipes/package.rb +0 -25
  69. data/test/cookbooks/os_prepare/recipes/postgres.rb +0 -20
  70. data/test/cookbooks/os_prepare/recipes/prep_container.rb +0 -15
  71. data/test/cookbooks/os_prepare/recipes/registry_key.rb +0 -87
  72. data/test/cookbooks/os_prepare/recipes/service.rb +0 -19
  73. data/test/cookbooks/os_prepare/templates/default/sv-default-svlog-run.erb +0 -2
  74. data/test/docker_run.rb +0 -162
  75. data/test/docker_test.rb +0 -58
  76. data/test/functional/helper.rb +0 -37
  77. data/test/functional/inheritance_test.rb +0 -62
  78. data/test/functional/inspec_archive_test.rb +0 -80
  79. data/test/functional/inspec_compliance_test.rb +0 -61
  80. data/test/functional/inspec_exec_json_test.rb +0 -122
  81. data/test/functional/inspec_exec_jsonmin_test.rb +0 -59
  82. data/test/functional/inspec_exec_test.rb +0 -123
  83. data/test/functional/inspec_json_profile_test.rb +0 -103
  84. data/test/functional/inspec_test.rb +0 -91
  85. data/test/helper.rb +0 -329
  86. data/test/integration/default/_debug_spec.rb +0 -8
  87. data/test/integration/default/apache_conf_spec.rb +0 -21
  88. data/test/integration/default/apt_spec.rb +0 -37
  89. data/test/integration/default/auditd_rules_spec.rb +0 -32
  90. data/test/integration/default/cmp_matcher_spec.rb +0 -115
  91. data/test/integration/default/csv_spec.rb +0 -11
  92. data/test/integration/default/etc_group_spec.rb +0 -29
  93. data/test/integration/default/file_spec.rb +0 -195
  94. data/test/integration/default/group_spec.rb +0 -59
  95. data/test/integration/default/ini_spec.rb +0 -11
  96. data/test/integration/default/iptables_spec.rb +0 -29
  97. data/test/integration/default/json_spec.rb +0 -11
  98. data/test/integration/default/kernel_module_spec.rb +0 -23
  99. data/test/integration/default/kernel_parameter_spec.rb +0 -60
  100. data/test/integration/default/mount_spec.rb +0 -19
  101. data/test/integration/default/os_spec.rb +0 -13
  102. data/test/integration/default/package_spec.rb +0 -30
  103. data/test/integration/default/port_spec.rb +0 -27
  104. data/test/integration/default/postgres_session_spec.rb +0 -13
  105. data/test/integration/default/powershell_spec.rb +0 -42
  106. data/test/integration/default/registry_key_spec.rb +0 -109
  107. data/test/integration/default/secpol_spec.rb +0 -11
  108. data/test/integration/default/service_spec.rb +0 -128
  109. data/test/integration/default/user_spec.rb +0 -96
  110. data/test/integration/default/vbscript_spec.rb +0 -22
  111. data/test/integration/default/wmi_spec.rb +0 -66
  112. data/test/integration/default/yaml_spec.rb +0 -11
  113. data/test/resource/command_test.rb +0 -33
  114. data/test/resource/dsl_test.rb +0 -45
  115. data/test/resource/file_test.rb +0 -146
  116. data/test/resource/ssh_config.rb +0 -9
  117. data/test/resource/sshd_config.rb +0 -9
  118. data/test/test-extra.yaml +0 -11
  119. data/test/test.yaml +0 -11
  120. data/test/unit/control_test.rb +0 -58
  121. data/test/unit/fetchers/local_test.rb +0 -67
  122. data/test/unit/fetchers/mock_test.rb +0 -43
  123. data/test/unit/fetchers/tar_test.rb +0 -36
  124. data/test/unit/fetchers/url_test.rb +0 -152
  125. data/test/unit/fetchers/zip_test.rb +0 -36
  126. data/test/unit/fetchers_test.rb +0 -65
  127. data/test/unit/metadata_test.rb +0 -137
  128. data/test/unit/mock/cmd/$env-PATH +0 -1
  129. data/test/unit/mock/cmd/Get-NetAdapter +0 -24
  130. data/test/unit/mock/cmd/GetUserAccount +0 -33
  131. data/test/unit/mock/cmd/GetWin32Group +0 -23
  132. data/test/unit/mock/cmd/Resolve-DnsName +0 -26
  133. data/test/unit/mock/cmd/Test-NetConnection +0 -4
  134. data/test/unit/mock/cmd/auditctl +0 -3
  135. data/test/unit/mock/cmd/auditctl-legacy +0 -7
  136. data/test/unit/mock/cmd/auditctl-s +0 -8
  137. data/test/unit/mock/cmd/auditpol +0 -2
  138. data/test/unit/mock/cmd/brew-info-jq +0 -1
  139. data/test/unit/mock/cmd/chage-l-root +0 -7
  140. data/test/unit/mock/cmd/dpkg-s-curl +0 -21
  141. data/test/unit/mock/cmd/dscl +0 -5
  142. data/test/unit/mock/cmd/env +0 -1
  143. data/test/unit/mock/cmd/etc-apt +0 -7
  144. data/test/unit/mock/cmd/find-apache2-conf-enabled +0 -1
  145. data/test/unit/mock/cmd/find-apache2-ports-conf +0 -1
  146. data/test/unit/mock/cmd/find-etc-rc-d-name-S +0 -12
  147. data/test/unit/mock/cmd/find-net-interface +0 -9
  148. data/test/unit/mock/cmd/find-xinetd.d +0 -2
  149. data/test/unit/mock/cmd/gem-list-local-a-q-rubocop +0 -1
  150. data/test/unit/mock/cmd/get-net-tcpconnection +0 -24
  151. data/test/unit/mock/cmd/get-netadapter-binding-bridge +0 -4
  152. data/test/unit/mock/cmd/get-package-firefox +0 -30
  153. data/test/unit/mock/cmd/get-package-ruby +0 -18
  154. data/test/unit/mock/cmd/get-service-dhcp +0 -10
  155. data/test/unit/mock/cmd/get-windows-feature +0 -7
  156. data/test/unit/mock/cmd/get-wmiobject +0 -9
  157. data/test/unit/mock/cmd/getent-hosts-example.com +0 -1
  158. data/test/unit/mock/cmd/getent-passwd-jfolmer +0 -1
  159. data/test/unit/mock/cmd/getent-passwd-root +0 -1
  160. data/test/unit/mock/cmd/hpux-netstat-inet +0 -10
  161. data/test/unit/mock/cmd/hpux-netstat-inet6 +0 -11
  162. data/test/unit/mock/cmd/id-chartmann +0 -1
  163. data/test/unit/mock/cmd/id-jfolmer +0 -1
  164. data/test/unit/mock/cmd/id-root +0 -1
  165. data/test/unit/mock/cmd/initctl--version +0 -5
  166. data/test/unit/mock/cmd/initctl-show-config-ssh +0 -3
  167. data/test/unit/mock/cmd/initctl-status-ssh +0 -1
  168. data/test/unit/mock/cmd/iptables-s +0 -6
  169. data/test/unit/mock/cmd/launchctl-list +0 -3
  170. data/test/unit/mock/cmd/logins-x +0 -4
  171. data/test/unit/mock/cmd/ls-1-etc-init.d +0 -2
  172. data/test/unit/mock/cmd/ls-sys-class-net-br +0 -2
  173. data/test/unit/mock/cmd/lsmod +0 -2
  174. data/test/unit/mock/cmd/lsof-nP-i-FpctPn +0 -63
  175. data/test/unit/mock/cmd/mount +0 -1
  176. data/test/unit/mock/cmd/mount-multiple +0 -2
  177. data/test/unit/mock/cmd/netstat-an.utf8 +0 -13
  178. data/test/unit/mock/cmd/netstat-tulpen +0 -6
  179. data/test/unit/mock/cmd/npm-ls-g--json-bower +0 -9
  180. data/test/unit/mock/cmd/pacman-qi-curl +0 -21
  181. data/test/unit/mock/cmd/ping-example.com +0 -6
  182. data/test/unit/mock/cmd/pip-show-jinja2 +0 -11
  183. data/test/unit/mock/cmd/pkg-info-system-file-system-zfs +0 -8
  184. data/test/unit/mock/cmd/pkginfo-l-SUNWzfsr +0 -7
  185. data/test/unit/mock/cmd/ps-aux +0 -5
  186. data/test/unit/mock/cmd/ps-auxZ +0 -3
  187. data/test/unit/mock/cmd/pw-usershow-root-7 +0 -1
  188. data/test/unit/mock/cmd/reg_schedule +0 -6
  189. data/test/unit/mock/cmd/rpm-qia-curl +0 -24
  190. data/test/unit/mock/cmd/s11-netstat-an-finet-finet6 +0 -32
  191. data/test/unit/mock/cmd/sbin_sysctl +0 -1
  192. data/test/unit/mock/cmd/secedit-export +0 -7
  193. data/test/unit/mock/cmd/service-e +0 -2
  194. data/test/unit/mock/cmd/service-sendmail-onestatus +0 -3
  195. data/test/unit/mock/cmd/service-sshd-status +0 -1
  196. data/test/unit/mock/cmd/sockstat +0 -5
  197. data/test/unit/mock/cmd/success +0 -0
  198. data/test/unit/mock/cmd/swlist-l-product +0 -1
  199. data/test/unit/mock/cmd/systemctl-show-all-dbus +0 -6
  200. data/test/unit/mock/cmd/systemctl-show-all-sshd +0 -7
  201. data/test/unit/mock/cmd/win32_product +0 -8
  202. data/test/unit/mock/cmd/yum-repolist-all +0 -52
  203. data/test/unit/mock/files/apache2.conf +0 -14
  204. data/test/unit/mock/files/auditd.conf +0 -4
  205. data/test/unit/mock/files/bond0 +0 -37
  206. data/test/unit/mock/files/etcgroup +0 -3
  207. data/test/unit/mock/files/example.csv +0 -6
  208. data/test/unit/mock/files/grub.conf +0 -21
  209. data/test/unit/mock/files/inetd.conf +0 -2
  210. data/test/unit/mock/files/kitchen.yml +0 -7
  211. data/test/unit/mock/files/limits.conf +0 -5
  212. data/test/unit/mock/files/login.defs +0 -5
  213. data/test/unit/mock/files/mysql.conf +0 -8
  214. data/test/unit/mock/files/mysql2.conf +0 -2
  215. data/test/unit/mock/files/ntp.conf +0 -5
  216. data/test/unit/mock/files/passwd +0 -2
  217. data/test/unit/mock/files/policyfile.lock.json +0 -12
  218. data/test/unit/mock/files/ports.conf +0 -6
  219. data/test/unit/mock/files/rootwrap.conf +0 -7
  220. data/test/unit/mock/files/serve-cgi-bin.conf +0 -20
  221. data/test/unit/mock/files/shadow +0 -2
  222. data/test/unit/mock/files/ssh_config +0 -5
  223. data/test/unit/mock/files/sshd_config +0 -7
  224. data/test/unit/mock/files/sysctl.conf +0 -7
  225. data/test/unit/mock/files/xinetd.conf +0 -9
  226. data/test/unit/mock/files/xinetd.d/.gitkeep +0 -0
  227. data/test/unit/mock/files/xinetd.d_chargen-dgram +0 -9
  228. data/test/unit/mock/files/xinetd.d_chargen-stream +0 -9
  229. data/test/unit/mock/profiles/complete-metadata/inspec.yml +0 -7
  230. data/test/unit/mock/profiles/complete-profile/controls/filesystem_spec.rb +0 -16
  231. data/test/unit/mock/profiles/complete-profile/inspec.yml +0 -10
  232. data/test/unit/mock/profiles/complete-profile/libraries/testlib.rb +0 -1
  233. data/test/unit/mock/profiles/empty-metadata/inspec.yml +0 -0
  234. data/test/unit/mock/profiles/legacy-complete-metadata/metadata.rb +0 -7
  235. data/test/unit/mock/profiles/legacy-complete-metadata/test/.gitkeep +0 -0
  236. data/test/unit/mock/profiles/legacy-empty-metadata/controls/.gitkeep +0 -0
  237. data/test/unit/mock/profiles/legacy-empty-metadata/metadata.rb +0 -0
  238. data/test/unit/mock/profiles/legacy-simple-metadata/metadata.rb +0 -1
  239. data/test/unit/mock/profiles/legacy-simple-metadata/test/.gitkeep +0 -0
  240. data/test/unit/mock/profiles/library/controls/filesystem_spec.rb +0 -7
  241. data/test/unit/mock/profiles/library/inspec.yml +0 -10
  242. data/test/unit/mock/profiles/library/libraries/gordonlib.rb +0 -2
  243. data/test/unit/mock/profiles/library/libraries/testlib.rb +0 -12
  244. data/test/unit/mock/profiles/resource-tiny/inspec.yml +0 -10
  245. data/test/unit/mock/profiles/resource-tiny/libraries/resource.rb +0 -3
  246. data/test/unit/mock/profiles/simple-metadata/inspec.yml +0 -1
  247. data/test/unit/mock/profiles/skippy-profile-os/controls/one.rb +0 -3
  248. data/test/unit/mock/profiles/skippy-profile-os/inspec.yml +0 -5
  249. data/test/unit/mock/profiles/spec_only/specfile.rb +0 -11
  250. data/test/unit/mock/profiles/supported_inspec/inspec.yml +0 -2
  251. data/test/unit/mock/profiles/unsupported_inspec/inspec.yml +0 -2
  252. data/test/unit/objects_test.rb +0 -65
  253. data/test/unit/plugin_test.rb +0 -44
  254. data/test/unit/plugins/resource_test.rb +0 -60
  255. data/test/unit/profile_context_test.rb +0 -345
  256. data/test/unit/profile_test.rb +0 -252
  257. data/test/unit/resources/apache_conf_test.rb +0 -31
  258. data/test/unit/resources/apt_test.rb +0 -46
  259. data/test/unit/resources/audit_policy_test.rb +0 -13
  260. data/test/unit/resources/auditd_conf_test.rb +0 -15
  261. data/test/unit/resources/auditd_rules_test.rb +0 -91
  262. data/test/unit/resources/bash_test.rb +0 -29
  263. data/test/unit/resources/bond_test.rb +0 -24
  264. data/test/unit/resources/bridge_test.rb +0 -56
  265. data/test/unit/resources/csv_test.rb +0 -35
  266. data/test/unit/resources/etc_group_test.rb +0 -37
  267. data/test/unit/resources/file_test.rb +0 -202
  268. data/test/unit/resources/gem_test.rb +0 -20
  269. data/test/unit/resources/group_test.rb +0 -96
  270. data/test/unit/resources/grub_conf_test.rb +0 -29
  271. data/test/unit/resources/host_test.rb +0 -38
  272. data/test/unit/resources/inetd_conf_test.rb +0 -15
  273. data/test/unit/resources/ini_test.rb +0 -16
  274. data/test/unit/resources/interface_test.rb +0 -54
  275. data/test/unit/resources/iptables_test.rb +0 -35
  276. data/test/unit/resources/json_test.rb +0 -36
  277. data/test/unit/resources/kernel_module_test.rb +0 -23
  278. data/test/unit/resources/kernel_parameter_test.rb +0 -13
  279. data/test/unit/resources/limits_conf_test.rb +0 -14
  280. data/test/unit/resources/login_def_test.rb +0 -16
  281. data/test/unit/resources/mount_test.rb +0 -26
  282. data/test/unit/resources/mysql_conf_test.rb +0 -14
  283. data/test/unit/resources/npm_test.rb +0 -20
  284. data/test/unit/resources/ntp_conf_test.rb +0 -16
  285. data/test/unit/resources/oneget_test.rb +0 -45
  286. data/test/unit/resources/os_env_test.rb +0 -18
  287. data/test/unit/resources/os_test.rb +0 -40
  288. data/test/unit/resources/package_test.rb +0 -87
  289. data/test/unit/resources/parse_config_test.rb +0 -26
  290. data/test/unit/resources/passwd_test.rb +0 -111
  291. data/test/unit/resources/pip_test.rb +0 -15
  292. data/test/unit/resources/port_test.rb +0 -165
  293. data/test/unit/resources/powershell_test.rb +0 -32
  294. data/test/unit/resources/processes_test.rb +0 -72
  295. data/test/unit/resources/registry_key_test.rb +0 -18
  296. data/test/unit/resources/security_policy_test.rb +0 -16
  297. data/test/unit/resources/service_test.rb +0 -305
  298. data/test/unit/resources/shadow_test.rb +0 -67
  299. data/test/unit/resources/ssh_conf_test.rb +0 -33
  300. data/test/unit/resources/user_test.rb +0 -124
  301. data/test/unit/resources/vbscript_test.rb +0 -18
  302. data/test/unit/resources/windows_feature.rb +0 -17
  303. data/test/unit/resources/wmi_test.rb +0 -42
  304. data/test/unit/resources/xinetd_test.rb +0 -60
  305. data/test/unit/resources/yaml_test.rb +0 -34
  306. data/test/unit/resources/yum_test.rb +0 -68
  307. data/test/unit/shell_detector_test.rb +0 -78
  308. data/test/unit/source_reader_test.rb +0 -17
  309. data/test/unit/source_readers/flat_test.rb +0 -61
  310. data/test/unit/source_readers/inspec_test.rb +0 -38
  311. data/test/unit/utils/filter_array_test.rb +0 -59
  312. data/test/unit/utils/filter_table_test.rb +0 -177
  313. data/test/unit/utils/find_files_test.rb +0 -23
  314. data/test/unit/utils/passwd_parser_test.rb +0 -32
  315. data/test/unit/utils/simpleconfig_test.rb +0 -80
  316. data/test/unit/utils/solaris_netstat_parser.rb +0 -124
@@ -1,20 +0,0 @@
1
- # encoding: utf-8
2
- # author: Christoph Hartmann
3
- # author: Dominik Richter
4
-
5
- require 'helper'
6
- require 'inspec/resource'
7
-
8
- describe 'Inspec::Resources::Npm' do
9
- it 'verify npm package detail parsing' do
10
- resource = load_resource('npm', 'bower')
11
- pkg = {
12
- name: 'bower',
13
- version: '1.4.1',
14
- type: 'npm',
15
- installed: true,
16
- }
17
- _(resource.installed?).must_equal true
18
- _(resource.info).must_equal pkg
19
- end
20
- end
@@ -1,16 +0,0 @@
1
- # encoding: utf-8
2
- # author: Christoph Hartmann
3
- # author: Dominik Richter
4
-
5
- require 'helper'
6
- require 'inspec/resource'
7
-
8
- describe 'Inspec::Resources::NtpConf' do
9
- it 'verify ntp config parsing' do
10
- resource = load_resource('ntp_conf')
11
- _(resource.driftfile).must_equal '/var/lib/ntp/ntp.drift'
12
- _(resource.server).must_equal %w{
13
- 0.ubuntu.pool.ntp.org 1.ubuntu.pool.ntp.org 2.ubuntu.pool.ntp.org
14
- }
15
- end
16
- end
@@ -1,45 +0,0 @@
1
- # encoding: utf-8
2
- # author: Christoph Hartmann
3
- # author: Dominik Richter
4
-
5
- require 'helper'
6
- require 'inspec/resource'
7
-
8
- describe 'Inspec::Resources::OneGet' do
9
-
10
- it 'verify oneget package detail parsing' do
11
- resource = MockLoader.new(:windows).load_resource('oneget', 'Mozilla Firefox')
12
- pkg = {
13
- name: 'Mozilla Firefox 40.0.3 (x86 en-US)',
14
- version: '40.0.3',
15
- type: 'oneget',
16
- installed: true,
17
- }
18
- _(resource.installed?).must_equal true
19
- _(resource.version).must_equal '40.0.3'
20
- _(resource.info).must_equal pkg
21
- end
22
-
23
- # catch cases where we recieve multiple return values
24
- # eg. happens if you do 'choco install ruby'
25
- it 'filter dups of Get-Package' do
26
- resource = MockLoader.new(:windows).load_resource('oneget', 'Ruby 2.1.6-p336-x64')
27
- pkg = {
28
- name: 'Ruby 2.1.6-p336-x64',
29
- version: '2.1.6-p336',
30
- type: 'oneget',
31
- installed: true,
32
- }
33
- _(resource.installed?).must_equal true
34
- _(resource.version).must_equal '2.1.6-p336'
35
- _(resource.info).must_equal pkg
36
- end
37
-
38
- it 'should skip on linux' do
39
- resource = MockLoader.new(:centos7).load_resource('oneget', 'Not available')
40
- pkg = { type: 'oneget', installed: false }
41
- _(resource.installed?).must_equal false
42
- _(resource.version).must_equal nil
43
- _(resource.info).must_equal pkg
44
- end
45
- end
@@ -1,18 +0,0 @@
1
- # encoding: utf-8
2
- # author: Christoph Hartmann
3
- # author: Dominik Richter
4
-
5
- require 'helper'
6
- require 'inspec/resource'
7
-
8
- describe 'Inspec::Resources::OsEnv' do
9
- it 'verify env parsing' do
10
- resource = load_resource('os_env', 'PATH')
11
- _(resource.split).must_equal %w{/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin}
12
- end
13
-
14
- it 'read env variable on Windows' do
15
- resource = MockLoader.new(:windows).load_resource('os_env', 'PATH')
16
- _(resource.split).must_equal ['C:\Windows\system32', 'C:\Windows', 'C:\Windows\System32\Wbem', 'C:\Windows\System32\WindowsPowerShell\v1.0\\', 'C:\opscode\chef\bin\\']
17
- end
18
- end
@@ -1,40 +0,0 @@
1
- # encoding: utf-8
2
- # author: Christoph Hartmann
3
- # author: Dominik Richter
4
-
5
- require 'helper'
6
- require 'inspec/resource'
7
-
8
- describe 'Inspec::Resources::Os' do
9
- it 'verify os parsing on CentOS' do
10
- resource = MockLoader.new(:centos7).load_resource('os')
11
- _(resource.name).must_equal 'centos'
12
- _(resource.family).must_equal 'redhat'
13
- _(resource.release).must_equal '7.1.1503'
14
- _(resource.arch).must_equal 'x86_64'
15
- end
16
-
17
- it 'read env variable on Windows' do
18
- resource = MockLoader.new(:windows).load_resource('os')
19
- _(resource.name).must_equal 'windows'
20
- _(resource.family).must_equal 'windows'
21
- _(resource.release).must_equal '6.2.9200'
22
- _(resource.arch).must_equal 'x86_64'
23
- end
24
-
25
- it 'verify os parsing on Debian' do
26
- resource = MockLoader.new(:debian8).load_resource('os')
27
- _(resource.name).must_equal 'debian'
28
- _(resource.family).must_equal 'debian'
29
- _(resource.release).must_equal '8'
30
- _(resource.arch).must_equal 'x86_64'
31
- end
32
-
33
- it 'verify os parsing on Ubuntu' do
34
- resource = MockLoader.new(:ubuntu1504).load_resource('os')
35
- _(resource.name).must_equal 'ubuntu'
36
- _(resource.family).must_equal 'debian'
37
- _(resource.release).must_equal '15.04'
38
- _(resource.arch).must_equal 'x86_64'
39
- end
40
- end
@@ -1,87 +0,0 @@
1
- # encoding: utf-8
2
- # author: Christoph Hartmann
3
- # author: Dominik Richter
4
-
5
- require 'helper'
6
- require 'inspec/resource'
7
-
8
- describe 'Inspec::Resources::Package' do
9
- # arch linux
10
- it 'verify arch linux package parsing' do
11
- resource = MockLoader.new(:arch).load_resource('package', 'curl')
12
- pkg = { name: 'curl', installed: true, version: '7.37.0-1', type: 'pacman' }
13
- _(resource.installed?).must_equal true
14
- _(resource.version).must_equal '7.37.0-1'
15
- _(resource.info).must_equal pkg
16
- end
17
-
18
- # ubuntu
19
- it 'verify ubuntu package parsing' do
20
- resource = MockLoader.new(:ubuntu1404).load_resource('package', 'curl')
21
- pkg = { name: 'curl', installed: true, version: '7.35.0-1ubuntu2', type: 'deb' }
22
- _(resource.installed?).must_equal true
23
- _(resource.version).must_equal '7.35.0-1ubuntu2'
24
- _(resource.info).must_equal pkg
25
- end
26
-
27
- # centos
28
- it 'verify centos package parsing' do
29
- resource = MockLoader.new(:centos7).load_resource('package', 'curl')
30
- pkg = { name: 'curl', installed: true, version: '7.29.0-19.el7', type: 'rpm' }
31
- _(resource.installed?).must_equal true
32
- _(resource.version).must_equal '7.29.0-19.el7'
33
- _(resource.info).must_equal pkg
34
- end
35
-
36
- # hpux
37
- it 'verify hpux package parsing' do
38
- resource = MockLoader.new(:hpux).load_resource('package', 'vim')
39
- pkg = { name: 'vim', installed: true, version: '7.4', type: 'pkg' }
40
- _(resource.installed?).must_equal true
41
- _(resource.version).must_equal '7.4'
42
- _(resource.info).must_equal pkg
43
- end
44
-
45
- # wrlinux
46
- it 'verify wrlinux package parsing' do
47
- resource = MockLoader.new(:wrlinux).load_resource('package', 'curl')
48
- pkg = { name: 'curl', installed: true, version: '7.29.0-19.el7', type: 'rpm' }
49
- _(resource.installed?).must_equal true
50
- _(resource.version).must_equal '7.29.0-19.el7'
51
- _(resource.info).must_equal pkg
52
- end
53
-
54
- # windows
55
- it 'verify windows package parsing' do
56
- resource = MockLoader.new(:windows).load_resource('package', 'Microsoft Visual C++ 2008 Redistributable - x64 9.0.30729.6161')
57
- pkg = { name: 'Microsoft Visual C++ 2008 Redistributable - x64 9.0.30729.6161', installed: true, version: '9.0.30729.6161', type: 'windows' }
58
- _(resource.installed?).must_equal true
59
- _(resource.version).must_equal '9.0.30729.6161'
60
- _(resource.info).must_equal pkg
61
- end
62
-
63
- # solaris 10
64
- it 'verify windows package parsing' do
65
- resource = MockLoader.new(:solaris10).load_resource('package', 'SUNWzfsr')
66
- pkg = { name: 'SUNWzfsr', installed: true, version: '11.10.0-2006.05.18.01.46', type: 'pkg' }
67
- _(resource.installed?).must_equal true
68
- _(resource.version).must_equal '11.10.0-2006.05.18.01.46'
69
- _(resource.info).must_equal pkg
70
- end
71
-
72
- # solaris 11
73
- it 'verify windows package parsing' do
74
- resource = MockLoader.new(:solaris11).load_resource('package', 'system/file-system/zfs')
75
- pkg = { name: 'system/file-system/zfs', installed: true, version: '0.5.11-0.175.3.1.0.5.0', type: 'pkg' }
76
- _(resource.installed?).must_equal true
77
- _(resource.version).must_equal '0.5.11-0.175.3.1.0.5.0'
78
- _(resource.info).must_equal pkg
79
- end
80
-
81
- # undefined
82
- it 'verify package handling on unsupported os' do
83
- resource = MockLoader.new(:undefined).load_resource('package', 'curl')
84
- _(resource.installed?).must_equal false
85
- _(resource.info).must_equal nil
86
- end
87
- end
@@ -1,26 +0,0 @@
1
- require 'helper'
2
- require 'inspec/resource'
3
-
4
- describe 'Inspec::Resources::ParseConfig' do
5
-
6
- it 'verify parse_config resource' do
7
- options = {
8
- assignment_re: /^\s*([^=]*?)\s*=\s*(.*?)\s*$/
9
- }
10
- resource = MockLoader.new(:centos6).load_resource('parse_config', 'kernel.domainname = example.com', options)
11
- result = {"kernel.domainname"=>"example.com"}
12
- _(resource.params).must_equal result
13
- _(resource.content).must_equal 'kernel.domainname = example.com'
14
- _(resource.send('kernel.domainname')).must_equal 'example.com'
15
- end
16
-
17
- it 'verify parse_config_file resource' do
18
- options = {
19
- assignment_re: /^\s*([^=]*?)\s*=\s*(.*?)\s*$/
20
- }
21
- resource = MockLoader.new(:centos6).load_resource('parse_config_file', '/etc/sysctl.conf', options)
22
- result = {"kernel.domainname"=>"example.com"}
23
- _(resource.params).must_equal result
24
- _(resource.send('kernel.domainname')).must_equal 'example.com'
25
- end
26
- end
@@ -1,111 +0,0 @@
1
- # encoding: utf-8
2
- # author: Christoph Hartmann
3
- # author: Dominik Richter
4
-
5
- require 'helper'
6
- require 'inspec/resource'
7
-
8
- describe 'Inspec::Resources::Passwd' do
9
- let(:passwd) { load_resource('passwd') }
10
- it 'retrieve users via field' do
11
- _(passwd.users).must_equal %w{root www-data}
12
- end
13
-
14
- it 'retrieve uids via field' do
15
- _(passwd.uids).must_equal %w{0 33}
16
- end
17
-
18
- it 'retrieve gids via field' do
19
- _(passwd.gids).must_equal %w{0 133}
20
- end
21
-
22
- it 'retrieve passwords via field' do
23
- _(passwd.passwords).must_equal %w{x x}
24
- end
25
-
26
- it 'retrieve login-shells via field' do
27
- _(passwd.shells).must_equal %w{/bin/bash /bin/sh}
28
- end
29
-
30
- it 'access all lines of the file' do
31
- _(passwd.lines).must_equal %w{root:x:0:0:root:/root:/bin/bash www-data:x:33:133:www-data:/var/www:/bin/sh}
32
- end
33
-
34
- it 'access all params of the file' do
35
- _(passwd.params[1]).must_equal({"user"=>"www-data", "password"=>"x", "uid"=>"33", "gid"=>"133", "desc"=>"www-data", "home"=>"/var/www", "shell"=>"/bin/sh"})
36
- end
37
-
38
- describe 'filter by uid == 0' do
39
- let(:child) { passwd.uids(0) }
40
- it 'creates a new passwd instance' do
41
- _(child.content).must_equal 'root:x:0:0:root:/root:/bin/bash'
42
- end
43
-
44
- it 'prints a nice to_s string' do
45
- _(child.to_s).must_equal '/etc/passwd with uid == 0'
46
- end
47
-
48
- it 'retrieves singular elements instead of arrays when filter has only one entry' do
49
- _(child.users).must_equal ['root']
50
- _(child.count).must_equal 1
51
- end
52
- end
53
-
54
- describe 'filter via name =~ /^www/' do
55
- let(:child) { passwd.users(/^www/) }
56
- it 'filters by user via name (regex)' do
57
- _(child.users).must_equal ['www-data']
58
- _(child.count).must_equal 1
59
- end
60
-
61
- it 'prints a nice to_s string' do
62
- _(child.to_s).must_equal '/etc/passwd with user == /^www/'
63
- end
64
- end
65
-
66
- describe 'deprecated calls' do
67
- it 'retrieves a username via uid' do
68
- _(passwd.uid(0).username).must_equal 'root'
69
- end
70
-
71
- it 'retrieves a usercount via uid' do
72
- _(passwd.uid(0).count).must_equal 1
73
- end
74
-
75
- it 'retrieves usernames' do
76
- _(passwd.usernames).must_equal ['root', 'www-data']
77
- end
78
- end
79
-
80
- describe 'where clause' do
81
- it 'retrieves username via uids < x' do
82
- _(passwd.where { uid.to_i < 33 }.entries.length).must_equal 1
83
- _(passwd.where { uid.to_i < 34 }.entries.length).must_equal 2
84
- end
85
-
86
- it 'retrieves username via uids <= x' do
87
- _(passwd.where { uid.to_i <= 32 }.entries.length).must_equal 1
88
- _(passwd.where { uid.to_i <= 33 }.entries.length).must_equal 2
89
- end
90
-
91
- it 'retrieves username via uids > x' do
92
- _(passwd.where { uid.to_i > 0 }.entries.length).must_equal 1
93
- _(passwd.where { uid.to_i > -1 }.entries.length).must_equal 2
94
- end
95
-
96
- it 'retrieves username via uids >= x' do
97
- _(passwd.where { uid.to_i >= 1 }.entries.length).must_equal 1
98
- _(passwd.where { uid.to_i >= 0 }.entries.length).must_equal 2
99
- end
100
-
101
- it 'retrieves username via uids == x' do
102
- _(passwd.where { uid.to_i == 0 }.entries.length).must_equal 1
103
- _(passwd.where { uid.to_i == 1 }.entries.length).must_equal 0
104
- end
105
-
106
- it 'retrieves username via uids != x' do
107
- _(passwd.where { uid.to_i != 0 }.entries.length).must_equal 1
108
- _(passwd.where { uid.to_i != 1 }.entries.length).must_equal 2
109
- end
110
- end
111
- end
@@ -1,15 +0,0 @@
1
- # encoding: utf-8
2
- # author: Christoph Hartmann
3
- # author: Dominik Richter
4
-
5
- require 'helper'
6
- require 'inspec/resource'
7
-
8
- describe 'Inspec::Resources::Pip' do
9
- it 'verify pip package detail parsing' do
10
- resource = load_resource('pip', 'jinja2')
11
- pkg = {:name=>'Jinja2', :installed=>true, :version=>'2.8', :type=>'pip'}
12
- _(resource.installed?).must_equal true
13
- _(resource.info).must_equal pkg
14
- end
15
- end
@@ -1,165 +0,0 @@
1
- # encoding: utf-8
2
- # author: Christoph Hartmann
3
- # author: Dominik Richter
4
-
5
- require 'helper'
6
- require 'inspec/resource'
7
-
8
- describe 'Inspec::Resources::Port' do
9
- it 'verify port on Ubuntu 14.04' do
10
- resource = MockLoader.new(:ubuntu1404).load_resource('port', 22)
11
- _(resource.listening?).must_equal true
12
- _(resource.protocols).must_equal %w{ tcp tcp6 }
13
- _(resource.pids).must_equal [1]
14
- _(resource.processes).must_equal ['sshd']
15
- _(resource.addresses).must_equal ["0.0.0.0", "::"]
16
- end
17
-
18
- it 'lists all ports' do
19
- resource = MockLoader.new(:ubuntu1404).load_resource('port')
20
- _(resource.entries.length).must_equal 4
21
- _(resource.listening?).must_equal true
22
- _(resource.protocols).must_equal %w{ tcp tcp6 udp }
23
- _(resource.pids).must_equal [1, 2043, 545]
24
- _(resource.processes).must_equal ['sshd', 'pidgin', 'rpcbind']
25
- _(resource.addresses).must_equal ['0.0.0.0', '::']
26
- end
27
-
28
- it 'filter ports by conditions' do
29
- resource = MockLoader.new(:ubuntu1404).load_resource('port').where { protocol =~ /udp/i }
30
- _(resource.entries.length).must_equal 1
31
- _(resource.listening?).must_equal true
32
- _(resource.protocols).must_equal ['udp']
33
- _(resource.pids).must_equal [545]
34
- _(resource.processes).must_equal ['rpcbind']
35
- _(resource.addresses).must_equal ['0.0.0.0']
36
- end
37
-
38
- it 'verify UDP port on Ubuntu 14.04' do
39
- resource = MockLoader.new(:ubuntu1404).load_resource('port', 111)
40
- _(resource.listening?).must_equal true
41
- _(resource.protocols).must_equal %w{ udp }
42
- _(resource.pids).must_equal [545]
43
- _(resource.processes).must_equal ['rpcbind']
44
- _(resource.addresses).must_equal ["0.0.0.0"]
45
- end
46
-
47
- it 'accepts the port as a string' do
48
- resource = MockLoader.new(:ubuntu1404).load_resource('port', '111')
49
- _(resource.listening?).must_equal true
50
- _(resource.protocols).must_equal %w{ udp }
51
- _(resource.pids).must_equal [545]
52
- _(resource.processes).must_equal ['rpcbind']
53
- _(resource.addresses).must_equal ["0.0.0.0"]
54
- end
55
-
56
- it 'verify port on MacOs x' do
57
- resource = MockLoader.new(:osx104).load_resource('port', 2022)
58
- _(resource.listening?).must_equal true
59
- _(resource.protocols).must_equal ['tcp']
60
- _(resource.processes).must_equal ['VBoxHeadl']
61
- _(resource.addresses).must_equal ["127.0.0.1"]
62
- end
63
-
64
- it 'verify port on Windows 2012' do
65
- resource = MockLoader.new(:windows).load_resource('port', 135)
66
- _(resource.listening?).must_equal true
67
- _(resource.protocols).must_equal ['tcp']
68
- _(resource.processes).must_equal []
69
- _(resource.addresses).must_equal ["::", "192.168.10.157"]
70
- end
71
-
72
- it 'verify port on Windows 2008 (unpriviledged)' do
73
- ml = MockLoader.new(:windows)
74
- # kill windows 2012 shell commands
75
- ml.backend.backend.commands
76
- .select { |k, _| k.start_with? 'Get-NetTCPConnection' }
77
- .values.each { |r| r.stdout = '' }
78
-
79
- resource = ml.load_resource('port', 135)
80
- _(resource.listening?).must_equal true
81
- _(resource.protocols).must_equal ['tcp']
82
- _(resource.processes).must_equal []
83
- _(resource.addresses).must_equal %w{0.0.0.0 ::}
84
- end
85
-
86
- it 'verify port list on Windows 2008 (unpriviledged)' do
87
- ml = MockLoader.new(:windows)
88
- # kill windows 2012 shell commands
89
- ml.backend.backend.commands
90
- .select { |k, _| k.start_with? 'Get-NetTCPConnection' }
91
- .values.each { |r| r.stdout = '' }
92
-
93
- resource = ml.load_resource('port')
94
- resource.entries.length.must_equal 9
95
- resource.protocols('tcp').entries.length.must_equal 6
96
- resource.protocols('udp').entries.length.must_equal 3
97
- end
98
-
99
- it 'verify port on FreeBSD' do
100
- resource = MockLoader.new(:freebsd10).load_resource('port', 22)
101
- _(resource.listening?).must_equal true
102
- _(resource.protocols).must_equal %w{ tcp6 tcp }
103
- _(resource.pids).must_equal [668]
104
- _(resource.processes).must_equal ['sshd']
105
- _(resource.addresses).must_equal ["0:0:0:0:0:0:0:0", "0.0.0.0"]
106
- end
107
-
108
- it 'verify port on wrlinux' do
109
- resource = MockLoader.new(:wrlinux).load_resource('port', 22)
110
- _(resource.listening?).must_equal true
111
- _(resource.protocols).must_equal %w{ tcp tcp6 }
112
- _(resource.processes).must_equal ['sshd']
113
- _(resource.addresses).must_equal ["0.0.0.0", "::"]
114
- end
115
-
116
- it 'verify running on undefined' do
117
- resource = MockLoader.new(:undefined).load_resource('port', 22)
118
- _(resource.listening?).must_equal false
119
- _(resource.protocols).must_equal []
120
- _(resource.pids).must_equal []
121
- _(resource.processes).must_equal []
122
- _(resource.addresses).must_equal []
123
- end
124
-
125
- it 'verify port and interface on Ubuntu 14.04' do
126
- resource = MockLoader.new(:ubuntu1404).load_resource('port', '0.0.0.0', 22)
127
- _(resource.listening?).must_equal true
128
- _(resource.protocols).must_equal %w{ tcp }
129
- _(resource.pids).must_equal [1]
130
- _(resource.processes).must_equal ['sshd']
131
- _(resource.addresses).must_equal ["0.0.0.0"]
132
- end
133
-
134
- it 'verify not listening port on interface on Ubuntu 14.04' do
135
- resource = MockLoader.new(:ubuntu1404).load_resource('port', '127.0.0.1', 22)
136
- _(resource.listening?).must_equal false
137
- _(resource.addresses).must_equal []
138
- end
139
-
140
- it 'verify port on Solaris 10' do
141
- resource = MockLoader.new(:solaris10).load_resource('port', 22)
142
- _(resource.listening?).must_equal true
143
- _(resource.addresses).must_equal ["0.0.0.0"]
144
- end
145
-
146
- it 'verify port on Solaris 11' do
147
- resource = MockLoader.new(:solaris11).load_resource('port', 22)
148
- _(resource.listening?).must_equal true
149
- _(resource.addresses).must_equal ["0.0.0.0"]
150
- end
151
-
152
- it 'verify port on hpux' do
153
- resource = MockLoader.new(:hpux).load_resource('port', 22)
154
- _(resource.listening?).must_equal true
155
- _(resource.protocols).must_equal %w{ tcp tcp6 }
156
- _(resource.addresses).must_equal ["0.0.0.0", "0:0:0:0:0:0:0:0" ]
157
- end
158
-
159
- it 'verify not listening port on hpux' do
160
- resource = MockLoader.new(:hpux).load_resource('port', 23)
161
- _(resource.listening?).must_equal false
162
- _(resource.protocols).must_equal []
163
- _(resource.addresses).must_equal []
164
- end
165
- end
@@ -1,32 +0,0 @@
1
- # encoding: utf-8
2
- # author: Christoph Hartmann
3
- # author: Dominik Richter
4
-
5
- require 'helper'
6
- require 'inspec/resource'
7
-
8
- describe 'Inspec::Resources::Powershell' do
9
-
10
- ps1_script = <<-EOH
11
- # call help for get command
12
- Get-Help Get-Command
13
- EOH
14
-
15
- it 'check if `powershell` for windows is properly generated ' do
16
- resource = MockLoader.new(:windows).load_resource('powershell', ps1_script)
17
- if Gem.loaded_specs['winrm'].version < Gem::Version.new('1.6.1')
18
- _(resource.command).must_equal 'powershell -encodedCommand IAAgACAAIAAjACAAYwBhAGwAbAAgAGgAZQBsAHAAIABmAG8AcgAgAGcAZQB0ACAAYwBvAG0AbQBhAG4AZAAKACAAIAAgACAARwBlAHQALQBIAGUAbABwACAARwBlAHQALQBDAG8AbQBtAGEAbgBkAAoA'
19
- else
20
- _(resource.command).must_equal 'powershell -encodedCommand JABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQA9ACcAUwBpAGwAZQBuAHQAbAB5AEMAbwBuAHQAaQBuAHUAZQAnADsAIAAgACAAIAAjACAAYwBhAGwAbAAgAGgAZQBsAHAAIABmAG8AcgAgAGcAZQB0ACAAYwBvAG0AbQBhAG4AZAAKACAAIAAgACAARwBlAHQALQBIAGUAbABwACAARwBlAHQALQBDAG8AbQBtAGEAbgBkAAoA'
21
- end
22
- end
23
-
24
- it 'check if legacy `script` for windows is properly generated ' do
25
- resource = MockLoader.new(:windows).load_resource('script', ps1_script)
26
- if Gem.loaded_specs['winrm'].version < Gem::Version.new('1.6.1')
27
- _(resource.command).must_equal 'powershell -encodedCommand IAAgACAAIAAjACAAYwBhAGwAbAAgAGgAZQBsAHAAIABmAG8AcgAgAGcAZQB0ACAAYwBvAG0AbQBhAG4AZAAKACAAIAAgACAARwBlAHQALQBIAGUAbABwACAARwBlAHQALQBDAG8AbQBtAGEAbgBkAAoA'
28
- else
29
- _(resource.command).must_equal 'powershell -encodedCommand JABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQA9ACcAUwBpAGwAZQBuAHQAbAB5AEMAbwBuAHQAaQBuAHUAZQAnADsAIAAgACAAIAAjACAAYwBhAGwAbAAgAGgAZQBsAHAAIABmAG8AcgAgAGcAZQB0ACAAYwBvAG0AbQBhAG4AZAAKACAAIAAgACAARwBlAHQALQBIAGUAbABwACAARwBlAHQALQBDAG8AbQBtAGEAbgBkAAoA'
30
- end
31
- end
32
- end
@@ -1,72 +0,0 @@
1
- # encoding: utf-8
2
- # author: Christoph Hartmann
3
- # author: Dominik Richter
4
-
5
- require 'helper'
6
- require 'inspec/resource'
7
-
8
- describe 'Inspec::Resources::Processes' do
9
- it 'handles empty process results' do
10
- resource = load_resource('processes', 'nothing')
11
- _(resource.list).must_equal []
12
- end
13
-
14
- it 'verify processes resource' do
15
- resource = MockLoader.new(:freebsd10).load_resource('processes', '/bin/bash')
16
- _(resource.list.length).must_equal 1
17
- _(resource.list[0].to_h).must_equal({
18
- label: nil,
19
- user: 'root',
20
- pid: 1,
21
- cpu: '0.0',
22
- mem: '0.0',
23
- vsz: 18084,
24
- rss: 3228,
25
- tty: '?',
26
- stat: 'Ss',
27
- start: '14:15',
28
- time: '0:00',
29
- command: '/bin/bash',
30
- })
31
- end
32
-
33
- it 'verify processes resource on linux os' do
34
- resource = MockLoader.new(:centos6).load_resource('processes', '/sbin/init')
35
- _(resource.list.length).must_equal 1
36
- _(resource.list[0].to_h).must_equal({
37
- label: 'system_u:system_r:kernel_t:s0',
38
- user: 'root',
39
- pid: 1,
40
- cpu: '0.0',
41
- mem: '0.0',
42
- vsz: 19232,
43
- rss: 1492,
44
- tty: '?',
45
- stat: 'Ss',
46
- start: 'May04',
47
- time: '0:01',
48
- command: '/sbin/init',
49
- })
50
- end
51
-
52
- it 'access attributes of a process' do
53
- resource = MockLoader.new(:centos6).load_resource('processes', '/sbin/init')
54
- process = resource.list[0]
55
- process.user.must_equal 'root'
56
- process[:user].must_equal 'root'
57
- process['user'].must_equal 'root'
58
- process[1].must_equal 'root'
59
- end
60
-
61
- it 'retrieves the users and states as arrays' do
62
- resource = MockLoader.new(:freebsd10).load_resource('processes', 'svc')
63
- _(resource.users.sort).must_equal ['noot']
64
- _(resource.states.sort).must_equal ['S', 'Ss']
65
- end
66
-
67
- it 'retrieves the users and states as arrays on linux os' do
68
- resource = MockLoader.new(:centos6).load_resource('processes', 'crypto/0')
69
- _(resource.users.sort).must_equal ['root']
70
- _(resource.states.sort).must_equal ['S']
71
- end
72
- end
@@ -1,18 +0,0 @@
1
- # encoding: utf-8
2
- # author: Christoph Hartmann
3
- # author: Dominik Richter
4
-
5
- require 'helper'
6
- require 'inspec/resource'
7
-
8
- describe 'Inspec::Resources::RegistryKey' do
9
- it 'read reg key with human readable name' do
10
- resource = MockLoader.new(:windows).load_resource('registry_key', 'Task Scheduler', 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Schedule')
11
- _(resource.Start).must_equal 2
12
- end
13
-
14
- it 'read reg key without human readable name' do
15
- resource_without_name = MockLoader.new(:windows).load_resource('registry_key', 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Schedule')
16
- _(resource_without_name.Start).must_equal 2
17
- end
18
- end