inspec 4.18.51 → 4.18.85

Sign up to get free protection for your applications and to get access to all the features.
Files changed (371) hide show
  1. checksums.yaml +4 -4
  2. data/inspec.gemspec +15 -37
  3. data/lib/resource_support/aws/aws_resource_mixin.rb +1 -1
  4. metadata +22 -709
  5. data/Gemfile +0 -61
  6. data/LICENSE +0 -14
  7. data/README.md +0 -474
  8. data/etc/deprecations.json +0 -125
  9. data/etc/plugin_filters.json +0 -45
  10. data/lib/bundles/README.md +0 -3
  11. data/lib/bundles/inspec-compliance/api.rb +0 -7
  12. data/lib/bundles/inspec-compliance/configuration.rb +0 -7
  13. data/lib/bundles/inspec-compliance/http.rb +0 -7
  14. data/lib/bundles/inspec-compliance/support.rb +0 -7
  15. data/lib/bundles/inspec-compliance/target.rb +0 -7
  16. data/lib/bundles/inspec-supermarket.rb +0 -9
  17. data/lib/bundles/inspec-supermarket/README.md +0 -45
  18. data/lib/bundles/inspec-supermarket/api.rb +0 -87
  19. data/lib/bundles/inspec-supermarket/cli.rb +0 -71
  20. data/lib/bundles/inspec-supermarket/target.rb +0 -31
  21. data/lib/inspec.rb +0 -30
  22. data/lib/inspec/archive/tar.rb +0 -25
  23. data/lib/inspec/archive/zip.rb +0 -15
  24. data/lib/inspec/backend.rb +0 -101
  25. data/lib/inspec/base_cli.rb +0 -318
  26. data/lib/inspec/cached_fetcher.rb +0 -65
  27. data/lib/inspec/cli.rb +0 -469
  28. data/lib/inspec/completions/bash.sh.erb +0 -45
  29. data/lib/inspec/completions/fish.sh.erb +0 -34
  30. data/lib/inspec/completions/zsh.sh.erb +0 -61
  31. data/lib/inspec/config.rb +0 -511
  32. data/lib/inspec/control_eval_context.rb +0 -248
  33. data/lib/inspec/dependencies/cache.rb +0 -74
  34. data/lib/inspec/dependencies/dependency_set.rb +0 -93
  35. data/lib/inspec/dependencies/lockfile.rb +0 -115
  36. data/lib/inspec/dependencies/requirement.rb +0 -135
  37. data/lib/inspec/dependencies/resolver.rb +0 -86
  38. data/lib/inspec/describe_base.rb +0 -53
  39. data/lib/inspec/dist.rb +0 -20
  40. data/lib/inspec/dsl.rb +0 -115
  41. data/lib/inspec/dsl_shared.rb +0 -32
  42. data/lib/inspec/env_printer.rb +0 -156
  43. data/lib/inspec/errors.rb +0 -18
  44. data/lib/inspec/exceptions.rb +0 -11
  45. data/lib/inspec/expect.rb +0 -42
  46. data/lib/inspec/fetcher.rb +0 -48
  47. data/lib/inspec/fetcher/git.rb +0 -211
  48. data/lib/inspec/fetcher/local.rb +0 -116
  49. data/lib/inspec/fetcher/mock.rb +0 -34
  50. data/lib/inspec/fetcher/url.rb +0 -281
  51. data/lib/inspec/file_provider.rb +0 -318
  52. data/lib/inspec/formatters.rb +0 -3
  53. data/lib/inspec/formatters/base.rb +0 -269
  54. data/lib/inspec/formatters/json_rspec.rb +0 -20
  55. data/lib/inspec/formatters/show_progress.rb +0 -12
  56. data/lib/inspec/globals.rb +0 -9
  57. data/lib/inspec/impact.rb +0 -36
  58. data/lib/inspec/input.rb +0 -421
  59. data/lib/inspec/input_dsl_helpers.rb +0 -26
  60. data/lib/inspec/input_registry.rb +0 -315
  61. data/lib/inspec/library_eval_context.rb +0 -55
  62. data/lib/inspec/log.rb +0 -7
  63. data/lib/inspec/metadata.rb +0 -253
  64. data/lib/inspec/method_source.rb +0 -20
  65. data/lib/inspec/objects.rb +0 -14
  66. data/lib/inspec/objects/control.rb +0 -85
  67. data/lib/inspec/objects/describe.rb +0 -106
  68. data/lib/inspec/objects/each_loop.rb +0 -41
  69. data/lib/inspec/objects/input.rb +0 -49
  70. data/lib/inspec/objects/list.rb +0 -15
  71. data/lib/inspec/objects/or_test.rb +0 -45
  72. data/lib/inspec/objects/ruby_helper.rb +0 -13
  73. data/lib/inspec/objects/tag.rb +0 -32
  74. data/lib/inspec/objects/test.rb +0 -94
  75. data/lib/inspec/objects/value.rb +0 -32
  76. data/lib/inspec/plugin/v1.rb +0 -2
  77. data/lib/inspec/plugin/v1/plugin_types/cli.rb +0 -22
  78. data/lib/inspec/plugin/v1/plugin_types/fetcher.rb +0 -83
  79. data/lib/inspec/plugin/v1/plugin_types/resource.rb +0 -176
  80. data/lib/inspec/plugin/v1/plugin_types/secret.rb +0 -11
  81. data/lib/inspec/plugin/v1/plugin_types/source_reader.rb +0 -36
  82. data/lib/inspec/plugin/v1/plugins.rb +0 -59
  83. data/lib/inspec/plugin/v1/registry.rb +0 -90
  84. data/lib/inspec/plugin/v2.rb +0 -46
  85. data/lib/inspec/plugin/v2/activator.rb +0 -40
  86. data/lib/inspec/plugin/v2/config_file.rb +0 -151
  87. data/lib/inspec/plugin/v2/filter.rb +0 -96
  88. data/lib/inspec/plugin/v2/installer.rb +0 -512
  89. data/lib/inspec/plugin/v2/loader.rb +0 -321
  90. data/lib/inspec/plugin/v2/plugin_base.rb +0 -112
  91. data/lib/inspec/plugin/v2/plugin_types/cli.rb +0 -49
  92. data/lib/inspec/plugin/v2/plugin_types/dsl.rb +0 -11
  93. data/lib/inspec/plugin/v2/plugin_types/input.rb +0 -34
  94. data/lib/inspec/plugin/v2/plugin_types/mock.rb +0 -12
  95. data/lib/inspec/plugin/v2/registry.rb +0 -98
  96. data/lib/inspec/plugin/v2/status.rb +0 -29
  97. data/lib/inspec/profile.rb +0 -658
  98. data/lib/inspec/profile_context.rb +0 -203
  99. data/lib/inspec/profile_vendor.rb +0 -84
  100. data/lib/inspec/reporters.rb +0 -73
  101. data/lib/inspec/reporters/automate.rb +0 -78
  102. data/lib/inspec/reporters/base.rb +0 -25
  103. data/lib/inspec/reporters/cli.rb +0 -370
  104. data/lib/inspec/reporters/json.rb +0 -113
  105. data/lib/inspec/reporters/json_automate.rb +0 -80
  106. data/lib/inspec/reporters/json_min.rb +0 -48
  107. data/lib/inspec/reporters/junit.rb +0 -77
  108. data/lib/inspec/reporters/yaml.rb +0 -20
  109. data/lib/inspec/require_loader.rb +0 -29
  110. data/lib/inspec/resource.rb +0 -114
  111. data/lib/inspec/resources.rb +0 -130
  112. data/lib/inspec/resources/aide_conf.rb +0 -153
  113. data/lib/inspec/resources/apache.rb +0 -47
  114. data/lib/inspec/resources/apache_conf.rb +0 -156
  115. data/lib/inspec/resources/apt.rb +0 -151
  116. data/lib/inspec/resources/audit_policy.rb +0 -64
  117. data/lib/inspec/resources/auditd.rb +0 -251
  118. data/lib/inspec/resources/auditd_conf.rb +0 -45
  119. data/lib/inspec/resources/bash.rb +0 -33
  120. data/lib/inspec/resources/bond.rb +0 -70
  121. data/lib/inspec/resources/bridge.rb +0 -125
  122. data/lib/inspec/resources/bsd_service.rb +0 -2
  123. data/lib/inspec/resources/chocolatey_package.rb +0 -82
  124. data/lib/inspec/resources/command.rb +0 -91
  125. data/lib/inspec/resources/cpan.rb +0 -58
  126. data/lib/inspec/resources/cran.rb +0 -64
  127. data/lib/inspec/resources/crontab.rb +0 -173
  128. data/lib/inspec/resources/csv.rb +0 -56
  129. data/lib/inspec/resources/dh_params.rb +0 -83
  130. data/lib/inspec/resources/directory.rb +0 -23
  131. data/lib/inspec/resources/docker.rb +0 -274
  132. data/lib/inspec/resources/docker_container.rb +0 -91
  133. data/lib/inspec/resources/docker_image.rb +0 -84
  134. data/lib/inspec/resources/docker_object.rb +0 -52
  135. data/lib/inspec/resources/docker_plugin.rb +0 -64
  136. data/lib/inspec/resources/docker_service.rb +0 -91
  137. data/lib/inspec/resources/elasticsearch.rb +0 -165
  138. data/lib/inspec/resources/etc_fstab.rb +0 -96
  139. data/lib/inspec/resources/etc_group.rb +0 -157
  140. data/lib/inspec/resources/etc_hosts.rb +0 -68
  141. data/lib/inspec/resources/etc_hosts_allow.rb +0 -2
  142. data/lib/inspec/resources/etc_hosts_allow_deny.rb +0 -114
  143. data/lib/inspec/resources/etc_hosts_deny.rb +0 -2
  144. data/lib/inspec/resources/file.rb +0 -339
  145. data/lib/inspec/resources/filesystem.rb +0 -139
  146. data/lib/inspec/resources/firewalld.rb +0 -148
  147. data/lib/inspec/resources/gem.rb +0 -80
  148. data/lib/inspec/resources/group.rb +0 -2
  149. data/lib/inspec/resources/groups.rb +0 -241
  150. data/lib/inspec/resources/grub_conf.rb +0 -230
  151. data/lib/inspec/resources/host.rb +0 -310
  152. data/lib/inspec/resources/http.rb +0 -275
  153. data/lib/inspec/resources/iis_app.rb +0 -101
  154. data/lib/inspec/resources/iis_app_pool.rb +0 -127
  155. data/lib/inspec/resources/iis_site.rb +0 -148
  156. data/lib/inspec/resources/iis_website.rb +0 -2
  157. data/lib/inspec/resources/inetd_conf.rb +0 -53
  158. data/lib/inspec/resources/ini.rb +0 -28
  159. data/lib/inspec/resources/interface.rb +0 -204
  160. data/lib/inspec/resources/ip6tables.rb +0 -79
  161. data/lib/inspec/resources/iptables.rb +0 -80
  162. data/lib/inspec/resources/json.rb +0 -116
  163. data/lib/inspec/resources/kernel_module.rb +0 -106
  164. data/lib/inspec/resources/kernel_parameter.rb +0 -54
  165. data/lib/inspec/resources/key_rsa.rb +0 -66
  166. data/lib/inspec/resources/ksh.rb +0 -33
  167. data/lib/inspec/resources/launchd_service.rb +0 -2
  168. data/lib/inspec/resources/limits_conf.rb +0 -45
  169. data/lib/inspec/resources/linux_kernel_parameter.rb +0 -2
  170. data/lib/inspec/resources/login_defs.rb +0 -56
  171. data/lib/inspec/resources/mount.rb +0 -88
  172. data/lib/inspec/resources/mssql_session.rb +0 -117
  173. data/lib/inspec/resources/mysql.rb +0 -81
  174. data/lib/inspec/resources/mysql_conf.rb +0 -128
  175. data/lib/inspec/resources/mysql_session.rb +0 -88
  176. data/lib/inspec/resources/nginx.rb +0 -96
  177. data/lib/inspec/resources/nginx_conf.rb +0 -232
  178. data/lib/inspec/resources/noop.rb +0 -9
  179. data/lib/inspec/resources/npm.rb +0 -68
  180. data/lib/inspec/resources/ntp_conf.rb +0 -51
  181. data/lib/inspec/resources/oneget.rb +0 -71
  182. data/lib/inspec/resources/oracledb_session.rb +0 -149
  183. data/lib/inspec/resources/os.rb +0 -34
  184. data/lib/inspec/resources/os_env.rb +0 -86
  185. data/lib/inspec/resources/package.rb +0 -391
  186. data/lib/inspec/resources/packages.rb +0 -111
  187. data/lib/inspec/resources/parse_config.rb +0 -112
  188. data/lib/inspec/resources/parse_config_file.rb +0 -2
  189. data/lib/inspec/resources/passwd.rb +0 -73
  190. data/lib/inspec/resources/pip.rb +0 -132
  191. data/lib/inspec/resources/platform.rb +0 -112
  192. data/lib/inspec/resources/port.rb +0 -791
  193. data/lib/inspec/resources/postfix_conf.rb +0 -35
  194. data/lib/inspec/resources/postgres.rb +0 -152
  195. data/lib/inspec/resources/postgres_conf.rb +0 -116
  196. data/lib/inspec/resources/postgres_hba_conf.rb +0 -86
  197. data/lib/inspec/resources/postgres_ident_conf.rb +0 -75
  198. data/lib/inspec/resources/postgres_session.rb +0 -70
  199. data/lib/inspec/resources/powershell.rb +0 -67
  200. data/lib/inspec/resources/ppa.rb +0 -2
  201. data/lib/inspec/resources/processes.rb +0 -219
  202. data/lib/inspec/resources/rabbitmq_conf.rb +0 -2
  203. data/lib/inspec/resources/rabbitmq_config.rb +0 -52
  204. data/lib/inspec/resources/registry_key.rb +0 -296
  205. data/lib/inspec/resources/runit_service.rb +0 -2
  206. data/lib/inspec/resources/script.rb +0 -1
  207. data/lib/inspec/resources/security_identifier.rb +0 -91
  208. data/lib/inspec/resources/security_policy.rb +0 -182
  209. data/lib/inspec/resources/service.rb +0 -820
  210. data/lib/inspec/resources/shadow.rb +0 -150
  211. data/lib/inspec/resources/ssh_config.rb +0 -98
  212. data/lib/inspec/resources/sshd_config.rb +0 -2
  213. data/lib/inspec/resources/ssl.rb +0 -99
  214. data/lib/inspec/resources/sys_info.rb +0 -119
  215. data/lib/inspec/resources/systemd_service.rb +0 -2
  216. data/lib/inspec/resources/sysv_service.rb +0 -2
  217. data/lib/inspec/resources/toml.rb +0 -30
  218. data/lib/inspec/resources/upstart_service.rb +0 -2
  219. data/lib/inspec/resources/user.rb +0 -1
  220. data/lib/inspec/resources/users.rb +0 -742
  221. data/lib/inspec/resources/vbscript.rb +0 -67
  222. data/lib/inspec/resources/virtualization.rb +0 -255
  223. data/lib/inspec/resources/windows_feature.rb +0 -126
  224. data/lib/inspec/resources/windows_hotfix.rb +0 -37
  225. data/lib/inspec/resources/windows_registry_key.rb +0 -2
  226. data/lib/inspec/resources/windows_task.rb +0 -112
  227. data/lib/inspec/resources/wmi.rb +0 -109
  228. data/lib/inspec/resources/x509_certificate.rb +0 -143
  229. data/lib/inspec/resources/xinetd_conf.rb +0 -103
  230. data/lib/inspec/resources/xml.rb +0 -48
  231. data/lib/inspec/resources/yaml.rb +0 -42
  232. data/lib/inspec/resources/yum.rb +0 -162
  233. data/lib/inspec/resources/zfs_dataset.rb +0 -62
  234. data/lib/inspec/resources/zfs_pool.rb +0 -50
  235. data/lib/inspec/rspec_extensions.rb +0 -116
  236. data/lib/inspec/rule.rb +0 -389
  237. data/lib/inspec/runner.rb +0 -333
  238. data/lib/inspec/runner_mock.rb +0 -37
  239. data/lib/inspec/runner_rspec.rb +0 -184
  240. data/lib/inspec/runtime_profile.rb +0 -23
  241. data/lib/inspec/schema.rb +0 -245
  242. data/lib/inspec/secrets.rb +0 -15
  243. data/lib/inspec/secrets/yaml.rb +0 -29
  244. data/lib/inspec/shell.rb +0 -211
  245. data/lib/inspec/shell_detector.rb +0 -89
  246. data/lib/inspec/source_reader.rb +0 -26
  247. data/lib/inspec/ui.rb +0 -213
  248. data/lib/inspec/ui_table_helper.rb +0 -12
  249. data/lib/inspec/utils/command_wrapper.rb +0 -23
  250. data/lib/inspec/utils/convert.rb +0 -8
  251. data/lib/inspec/utils/database_helpers.rb +0 -75
  252. data/lib/inspec/utils/deprecation.rb +0 -6
  253. data/lib/inspec/utils/deprecation/config_file.rb +0 -109
  254. data/lib/inspec/utils/deprecation/deprecator.rb +0 -118
  255. data/lib/inspec/utils/deprecation/errors.rb +0 -14
  256. data/lib/inspec/utils/deprecation/global_method.rb +0 -9
  257. data/lib/inspec/utils/enumerable_delegation.rb +0 -7
  258. data/lib/inspec/utils/erlang_parser.rb +0 -190
  259. data/lib/inspec/utils/file_reader.rb +0 -24
  260. data/lib/inspec/utils/filter.rb +0 -461
  261. data/lib/inspec/utils/filter_array.rb +0 -25
  262. data/lib/inspec/utils/find_files.rb +0 -44
  263. data/lib/inspec/utils/hash.rb +0 -37
  264. data/lib/inspec/utils/json_log.rb +0 -15
  265. data/lib/inspec/utils/modulator.rb +0 -9
  266. data/lib/inspec/utils/nginx_parser.rb +0 -101
  267. data/lib/inspec/utils/object_traversal.rb +0 -47
  268. data/lib/inspec/utils/parser.rb +0 -277
  269. data/lib/inspec/utils/pkey_reader.rb +0 -17
  270. data/lib/inspec/utils/simpleconfig.rb +0 -121
  271. data/lib/inspec/utils/spdx.rb +0 -10
  272. data/lib/inspec/utils/spdx.txt +0 -383
  273. data/lib/inspec/utils/telemetry.rb +0 -3
  274. data/lib/inspec/utils/telemetry/collector.rb +0 -81
  275. data/lib/inspec/utils/telemetry/data_series.rb +0 -44
  276. data/lib/inspec/utils/telemetry/global_methods.rb +0 -22
  277. data/lib/inspec/version.rb +0 -3
  278. data/lib/matchers/matchers.rb +0 -341
  279. data/lib/plugins/README.md +0 -16
  280. data/lib/plugins/inspec-artifact/lib/inspec-artifact.rb +0 -12
  281. data/lib/plugins/inspec-artifact/lib/inspec-artifact/base.rb +0 -170
  282. data/lib/plugins/inspec-artifact/lib/inspec-artifact/cli.rb +0 -116
  283. data/lib/plugins/inspec-artifact/test/functional/inspec_artifact_test.rb +0 -50
  284. data/lib/plugins/inspec-compliance/README.md +0 -207
  285. data/lib/plugins/inspec-compliance/lib/inspec-compliance.rb +0 -12
  286. data/lib/plugins/inspec-compliance/lib/inspec-compliance/api.rb +0 -362
  287. data/lib/plugins/inspec-compliance/lib/inspec-compliance/api/login.rb +0 -198
  288. data/lib/plugins/inspec-compliance/lib/inspec-compliance/cli.rb +0 -269
  289. data/lib/plugins/inspec-compliance/lib/inspec-compliance/configuration.rb +0 -103
  290. data/lib/plugins/inspec-compliance/lib/inspec-compliance/http.rb +0 -117
  291. data/lib/plugins/inspec-compliance/lib/inspec-compliance/images/cc-token.png +0 -0
  292. data/lib/plugins/inspec-compliance/lib/inspec-compliance/support.rb +0 -34
  293. data/lib/plugins/inspec-compliance/lib/inspec-compliance/target.rb +0 -146
  294. data/lib/plugins/inspec-compliance/test/functional/inspec_compliance_test.rb +0 -53
  295. data/lib/plugins/inspec-compliance/test/integration/default/cli.rb +0 -91
  296. data/lib/plugins/inspec-compliance/test/unit/api/login_test.rb +0 -190
  297. data/lib/plugins/inspec-compliance/test/unit/api_test.rb +0 -386
  298. data/lib/plugins/inspec-compliance/test/unit/target_test.rb +0 -155
  299. data/lib/plugins/inspec-habitat/Berksfile +0 -5
  300. data/lib/plugins/inspec-habitat/README.md +0 -150
  301. data/lib/plugins/inspec-habitat/kitchen.yml +0 -28
  302. data/lib/plugins/inspec-habitat/lib/inspec-habitat.rb +0 -11
  303. data/lib/plugins/inspec-habitat/lib/inspec-habitat/cli.rb +0 -41
  304. data/lib/plugins/inspec-habitat/lib/inspec-habitat/profile.rb +0 -265
  305. data/lib/plugins/inspec-habitat/templates/habitat/plan.sh.erb +0 -6
  306. data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/Berksfile +0 -2
  307. data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/README.md +0 -3
  308. data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/files/hab_setup.exp +0 -28
  309. data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/metadata.rb +0 -9
  310. data/lib/plugins/inspec-habitat/test/cookbooks/inspec_habitat_fixture/recipes/default.rb +0 -61
  311. data/lib/plugins/inspec-habitat/test/functional/inspec_habitat_test.rb +0 -34
  312. data/lib/plugins/inspec-habitat/test/integration/default/inspec_habitat/README.md +0 -3
  313. data/lib/plugins/inspec-habitat/test/integration/default/inspec_habitat/controls/inspec_habitat.rb +0 -40
  314. data/lib/plugins/inspec-habitat/test/integration/default/inspec_habitat/inspec.yml +0 -10
  315. data/lib/plugins/inspec-habitat/test/support/example_profile/README.md +0 -3
  316. data/lib/plugins/inspec-habitat/test/support/example_profile/controls/example.rb +0 -7
  317. data/lib/plugins/inspec-habitat/test/support/example_profile/inspec.yml +0 -10
  318. data/lib/plugins/inspec-habitat/test/unit/profile_test.rb +0 -242
  319. data/lib/plugins/inspec-init/README.md +0 -31
  320. data/lib/plugins/inspec-init/lib/inspec-init.rb +0 -12
  321. data/lib/plugins/inspec-init/lib/inspec-init/cli.rb +0 -15
  322. data/lib/plugins/inspec-init/lib/inspec-init/cli_plugin.rb +0 -243
  323. data/lib/plugins/inspec-init/lib/inspec-init/cli_profile.rb +0 -47
  324. data/lib/plugins/inspec-init/lib/inspec-init/renderer.rb +0 -97
  325. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/Gemfile +0 -11
  326. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/LICENSE +0 -2
  327. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/README.md +0 -28
  328. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/Rakefile +0 -40
  329. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template.rb +0 -14
  330. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/cli_command.rb +0 -62
  331. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/plugin.rb +0 -53
  332. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/lib/inspec-plugin-template/version.rb +0 -8
  333. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/fixtures/README.md +0 -24
  334. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/functional/README.md +0 -12
  335. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/functional/inspec_plugin_template_test.rb +0 -110
  336. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/helper.rb +0 -24
  337. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/unit/README.md +0 -17
  338. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/unit/cli_args_test.rb +0 -67
  339. data/lib/plugins/inspec-init/templates/plugins/inspec-plugin-template/test/unit/plugin_def_test.rb +0 -51
  340. data/lib/plugins/inspec-init/templates/profiles/aws/libraries/.gitkeep +0 -0
  341. data/lib/plugins/inspec-init/templates/profiles/azure/libraries/.gitkeep +0 -0
  342. data/lib/plugins/inspec-init/templates/profiles/gcp/libraries/.gitkeep +0 -0
  343. data/lib/plugins/inspec-init/templates/profiles/os/README.md +0 -3
  344. data/lib/plugins/inspec-init/templates/profiles/os/controls/example.rb +0 -18
  345. data/lib/plugins/inspec-init/templates/profiles/os/inspec.yml +0 -10
  346. data/lib/plugins/inspec-init/templates/profiles/os/libraries/.gitkeep +0 -0
  347. data/lib/plugins/inspec-init/test/functional/inspec_init_plugin_test.rb +0 -184
  348. data/lib/plugins/inspec-init/test/functional/inspec_init_profile_test.rb +0 -121
  349. data/lib/plugins/inspec-plugin-manager-cli/README.md +0 -6
  350. data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli.rb +0 -17
  351. data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/cli_command.rb +0 -518
  352. data/lib/plugins/inspec-plugin-manager-cli/lib/inspec-plugin-manager-cli/plugin.rb +0 -12
  353. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/config_dirs/empty/.gitkeep +0 -0
  354. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/inspec-egg-white-omelette/lib/inspec-egg-white-omelette.rb +0 -2
  355. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/inspec-egg-white-omelette/lib/inspec-egg-white-omelette/.gitkeep +0 -0
  356. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/inspec-wrong-structure/.gitkeep +0 -0
  357. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/wrong-name/lib/wrong-name.rb +0 -1
  358. data/lib/plugins/inspec-plugin-manager-cli/test/fixtures/plugins/wrong-name/lib/wrong-name/.gitkeep +0 -0
  359. data/lib/plugins/inspec-plugin-manager-cli/test/functional/help_test.rb +0 -23
  360. data/lib/plugins/inspec-plugin-manager-cli/test/functional/helper.rb +0 -62
  361. data/lib/plugins/inspec-plugin-manager-cli/test/functional/install_test.rb +0 -368
  362. data/lib/plugins/inspec-plugin-manager-cli/test/functional/list_test.rb +0 -101
  363. data/lib/plugins/inspec-plugin-manager-cli/test/functional/search_test.rb +0 -129
  364. data/lib/plugins/inspec-plugin-manager-cli/test/functional/uninstall_test.rb +0 -63
  365. data/lib/plugins/inspec-plugin-manager-cli/test/functional/update_test.rb +0 -84
  366. data/lib/plugins/inspec-plugin-manager-cli/test/unit/cli_args_test.rb +0 -77
  367. data/lib/plugins/inspec-plugin-manager-cli/test/unit/plugin_def_test.rb +0 -39
  368. data/lib/plugins/shared/core_plugin_test_helper.rb +0 -153
  369. data/lib/plugins/things-for-train-integration.rb +0 -14
  370. data/lib/source_readers/flat.rb +0 -36
  371. data/lib/source_readers/inspec.rb +0 -66
@@ -1,386 +0,0 @@
1
- require "minitest/autorun"
2
- require "webmock/minitest"
3
- require "mocha/setup"
4
- require_relative "../../lib/inspec-compliance/api.rb"
5
-
6
- describe InspecPlugins::Compliance::API do
7
- let(:profiles_response) do
8
- [{ "name" => "apache-baseline",
9
- "title" => "DevSec Apache Baseline",
10
- "maintainer" => "DevSec Hardening Framework Team",
11
- "copyright" => "DevSec Hardening Framework Team",
12
- "copyright_email" => "hello@dev-sec.io",
13
- "license" => "Apache 2 license",
14
- "summary" => "Test-suite for best-practice apache hardening",
15
- "version" => "2.0.2",
16
- "supports" => [{ "os-family" => "unix" }],
17
- "depends" => nil,
18
- "owner_id" => "admin" },
19
- { "name" => "apache-baseline",
20
- "title" => "DevSec Apache Baseline",
21
- "maintainer" => "Hardening Framework Team",
22
- "copyright" => "Hardening Framework Team",
23
- "copyright_email" => "hello@dev-sec.io",
24
- "license" => "Apache 2 license",
25
- "summary" => "Test-suite for best-practice apache hardening",
26
- "version" => "2.0.1",
27
- "supports" => [{ "os-family" => "unix" }],
28
- "depends" => nil,
29
- "latest_version" => "2.0.2",
30
- "owner_id" => "admin" },
31
- { "name" => "cis-aix-5.3-6.1-level1",
32
- "title" => "CIS AIX 5.3 and AIX 6.1 Benchmark Level 1",
33
- "maintainer" => "Chef Software, Inc.",
34
- "copyright" => "Chef Software, Inc.",
35
- "copyright_email" => "support@chef.io",
36
- "license" => "Proprietary, All rights reserved",
37
- "summary" => "CIS AIX 5.3 and AIX 6.1 Benchmark Level 1 translated from SCAP",
38
- "version" => "1.1.0",
39
- "supports" => nil,
40
- "depends" => nil,
41
- "latest_version" => "1.1.0-3",
42
- "owner_id" => "admin" }]
43
- end
44
-
45
- describe ".version" do
46
- let(:headers) { "test-headers" }
47
- let(:config) do
48
- {
49
- "server" => "myserver",
50
- "insecure" => true,
51
- }
52
- end
53
-
54
- before do
55
- InspecPlugins::Compliance::API.expects(:get_headers).returns(headers)
56
- end
57
-
58
- describe "when a 404 is received" do
59
- it "should return an empty hash" do
60
- response = mock
61
- response.stubs(:code).returns("404")
62
- InspecPlugins::Compliance::HTTP.expects(:get).with("myserver/version", "test-headers", true).returns(response)
63
- _(InspecPlugins::Compliance::API.version(config)).must_equal({})
64
- end
65
- end
66
-
67
- describe "when the returned body is nil" do
68
- it "should return an empty hash" do
69
- response = mock
70
- response.stubs(:code).returns("200")
71
- response.stubs(:body).returns(nil)
72
- InspecPlugins::Compliance::HTTP.expects(:get).with("myserver/version", "test-headers", true).returns(response)
73
- _(InspecPlugins::Compliance::API.version(config)).must_equal({})
74
- end
75
- end
76
-
77
- describe "when the returned body is an empty string" do
78
- it "should return an empty hash" do
79
- response = mock
80
- response.stubs(:code).returns("200")
81
- response.stubs(:body).returns("")
82
- InspecPlugins::Compliance::HTTP.expects(:get).with("myserver/version", "test-headers", true).returns(response)
83
- _(InspecPlugins::Compliance::API.version(config)).must_equal({})
84
- end
85
- end
86
-
87
- describe "when the returned body has no version key" do
88
- it "should return an empty hash" do
89
- response = mock
90
- response.stubs(:code).returns("200")
91
- response.stubs(:body).returns('{"api":"compliance"}')
92
- InspecPlugins::Compliance::HTTP.expects(:get).with("myserver/version", "test-headers", true).returns(response)
93
- _(InspecPlugins::Compliance::API.version(config)).must_equal({})
94
- end
95
- end
96
-
97
- describe "when the returned body has an empty version key" do
98
- it "should return an empty hash" do
99
- response = mock
100
- response.stubs(:code).returns("200")
101
- response.stubs(:body).returns('{"api":"compliance","version":""}')
102
- InspecPlugins::Compliance::HTTP.expects(:get).with("myserver/version", "test-headers", true).returns(response)
103
- _(InspecPlugins::Compliance::API.version(config)).must_equal({})
104
- end
105
- end
106
-
107
- describe "when the returned body has a proper version" do
108
- it "should return an empty hash" do
109
- response = mock
110
- response.stubs(:code).returns("200")
111
- response.stubs(:body).returns('{"api":"compliance","version":"1.2.3"}')
112
- InspecPlugins::Compliance::HTTP.expects(:get).with("myserver/version", "test-headers", true).returns(response)
113
- _(InspecPlugins::Compliance::API.version(config)).must_equal({ "version" => "1.2.3", "api" => "compliance" })
114
- end
115
- end
116
- end
117
-
118
- describe "automate/compliance is? checks" do
119
- describe "when the config has a compliance server_type" do
120
- it "automate/compliance server is? methods return correctly" do
121
- config = InspecPlugins::Compliance::Configuration.new
122
- config.clean
123
- config["server_type"] = "compliance"
124
- _(InspecPlugins::Compliance::API.is_compliance_server?(config)).must_equal true
125
- _(InspecPlugins::Compliance::API.is_automate_server?(config)).must_equal false
126
- _(InspecPlugins::Compliance::API.is_automate_server_pre_080?(config)).must_equal false
127
- _(InspecPlugins::Compliance::API.is_automate_server_080_and_later?(config)).must_equal false
128
- _(InspecPlugins::Compliance::API.is_automate2_server?(config)).must_equal false
129
- end
130
- end
131
-
132
- describe "when the config has a automate2 server_type" do
133
- it "automate/compliance server is? methods return correctly" do
134
- config = InspecPlugins::Compliance::Configuration.new
135
- config.clean
136
- config["server_type"] = "automate2"
137
- _(InspecPlugins::Compliance::API.is_compliance_server?(config)).must_equal false
138
- _(InspecPlugins::Compliance::API.is_automate_server?(config)).must_equal false
139
- _(InspecPlugins::Compliance::API.is_automate_server_pre_080?(config)).must_equal false
140
- _(InspecPlugins::Compliance::API.is_automate_server_080_and_later?(config)).must_equal false
141
- _(InspecPlugins::Compliance::API.is_automate2_server?(config)).must_equal true
142
- end
143
- end
144
-
145
- describe "when the config has an automate server_type and no version key" do
146
- it "automate/compliance server is? methods return correctly" do
147
- config = InspecPlugins::Compliance::Configuration.new
148
- config.clean
149
- config["server_type"] = "automate"
150
- _(InspecPlugins::Compliance::API.is_compliance_server?(config)).must_equal false
151
- _(InspecPlugins::Compliance::API.is_automate_server?(config)).must_equal true
152
- _(InspecPlugins::Compliance::API.is_automate_server_pre_080?(config)).must_equal true
153
- _(InspecPlugins::Compliance::API.is_automate_server_080_and_later?(config)).must_equal false
154
- _(InspecPlugins::Compliance::API.is_automate2_server?(config)).must_equal false
155
- end
156
- end
157
-
158
- describe "when the config has an automate server_type and a version key that is not a hash" do
159
- it "automate/compliance server is? methods return correctly" do
160
- config = InspecPlugins::Compliance::Configuration.new
161
- config.clean
162
- config["server_type"] = "automate"
163
- config["version"] = "1.2.3"
164
- _(InspecPlugins::Compliance::API.is_compliance_server?(config)).must_equal false
165
- _(InspecPlugins::Compliance::API.is_automate_server?(config)).must_equal true
166
- _(InspecPlugins::Compliance::API.is_automate_server_pre_080?(config)).must_equal true
167
- _(InspecPlugins::Compliance::API.is_automate_server_080_and_later?(config)).must_equal false
168
- _(InspecPlugins::Compliance::API.is_automate2_server?(config)).must_equal false
169
- end
170
- end
171
-
172
- describe "when the config has an automate server_type and a version hash with no version" do
173
- it "automate/compliance server is? methods return correctly" do
174
- config = InspecPlugins::Compliance::Configuration.new
175
- config.clean
176
- config["server_type"] = "automate"
177
- config["version"] = {}
178
- _(InspecPlugins::Compliance::API.is_compliance_server?(config)).must_equal false
179
- _(InspecPlugins::Compliance::API.is_automate_server?(config)).must_equal true
180
- _(InspecPlugins::Compliance::API.is_automate_server_pre_080?(config)).must_equal true
181
- _(InspecPlugins::Compliance::API.is_automate_server_080_and_later?(config)).must_equal false
182
- end
183
- end
184
-
185
- describe "when the config has an automate server_type and a version hash with a version" do
186
- it "automate/compliance server is? methods return correctly" do
187
- config = InspecPlugins::Compliance::Configuration.new
188
- config.clean
189
- config["server_type"] = "automate"
190
- config["version"] = { "version" => "0.8.1" }
191
- _(InspecPlugins::Compliance::API.is_compliance_server?(config)).must_equal false
192
- _(InspecPlugins::Compliance::API.is_automate_server?(config)).must_equal true
193
- _(InspecPlugins::Compliance::API.is_automate_server_pre_080?(config)).must_equal false
194
- _(InspecPlugins::Compliance::API.is_automate_server_080_and_later?(config)).must_equal true
195
- end
196
- end
197
- end
198
-
199
- describe ".server_version_from_config" do
200
- it "returns nil when the config has no version key" do
201
- config = {}
202
- _(InspecPlugins::Compliance::API.server_version_from_config(config)).must_be_nil
203
- end
204
-
205
- it "returns nil when the version value is not a hash" do
206
- config = { "version" => "123" }
207
- _(InspecPlugins::Compliance::API.server_version_from_config(config)).must_be_nil
208
- end
209
-
210
- it "returns nil when the version value is a hash but has no version key inside" do
211
- config = { "version" => {} }
212
- _(InspecPlugins::Compliance::API.server_version_from_config(config)).must_be_nil
213
- end
214
-
215
- it "returns the version if the version value is a hash containing a version" do
216
- config = { "version" => { "version" => "1.2.3" } }
217
- _(InspecPlugins::Compliance::API.server_version_from_config(config)).must_equal "1.2.3"
218
- end
219
- end
220
-
221
- describe "profile_split" do
222
- it "handles a profile without version" do
223
- _(InspecPlugins::Compliance::API.profile_split("admin/apache-baseline")).must_equal ["admin", "apache-baseline", nil]
224
- end
225
-
226
- it "handles a profile with a version" do
227
- _(InspecPlugins::Compliance::API.profile_split("admin/apache-baseline#2.0.1")).must_equal ["admin", "apache-baseline", "2.0.1"]
228
- end
229
- end
230
-
231
- describe "target_url" do
232
- it "handles a automate profile with and without version" do
233
- config = InspecPlugins::Compliance::Configuration.new
234
- config.clean
235
- config["server_type"] = "automate"
236
- config["server"] = "https://myautomate"
237
- config["version"] = "1.6.99"
238
- _(InspecPlugins::Compliance::API.target_url(config, "admin/apache-baseline")).must_equal "https://myautomate/profiles/admin/apache-baseline/tar"
239
- _(InspecPlugins::Compliance::API.target_url(config, "admin/apache-baseline#2.0.2")).must_equal "https://myautomate/profiles/admin/apache-baseline/version/2.0.2/tar"
240
- end
241
-
242
- it "handles a chef-compliance profile with and without version" do
243
- config = InspecPlugins::Compliance::Configuration.new
244
- config.clean
245
- config["server_type"] = "compliance"
246
- config["server"] = "https://mychefcompliance"
247
- config["version"] = "1.1.2"
248
- _(InspecPlugins::Compliance::API.target_url(config, "admin/apache-baseline")).must_equal "https://mychefcompliance/owners/admin/compliance/apache-baseline/tar"
249
- _(InspecPlugins::Compliance::API.target_url(config, "admin/apache-baseline#2.0.2")).must_equal "https://mychefcompliance/owners/admin/compliance/apache-baseline/tar"
250
- end
251
- end
252
-
253
- describe "exist?" do
254
- it "works with profiles returned by Automate" do
255
- # ruby 2.3.3 has issues running stub_requests properly
256
- # skipping for that specific version
257
- return if RUBY_VERSION == "2.3.3"
258
-
259
- config = InspecPlugins::Compliance::Configuration.new
260
- config.clean
261
- config["owner"] = "admin"
262
- config["server_type"] = "automate"
263
- config["server"] = "https://myautomate"
264
- config["version"] = "1.6.99"
265
- config["automate"] = { "ent" => "automate", "token_type" => "dctoken" }
266
- config["version"] = { "api" => "compliance", "version" => "0.8.24" }
267
-
268
- stub_request(:get, "https://myautomate/profiles/admin")
269
- .with(headers: { "Accept" => "*/*", "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3", "Chef-Delivery-Enterprise" => "automate", "User-Agent" => "Ruby", "X-Data-Collector-Token" => "" })
270
- .to_return(status: 200, body: profiles_response.to_json, headers: {})
271
-
272
- _(InspecPlugins::Compliance::API.exist?(config, "admin/apache-baseline")).must_equal true
273
- _(InspecPlugins::Compliance::API.exist?(config, "admin/apache-baseline#2.0.1")).must_equal true
274
- _(InspecPlugins::Compliance::API.exist?(config, "admin/apache-baseline#2.0.999")).must_equal false
275
- _(InspecPlugins::Compliance::API.exist?(config, "admin/missing-in-action")).must_equal false
276
- end
277
- end
278
-
279
- describe ".determine_server_type" do
280
- let(:url) { "https://someserver.onthe.net/" }
281
-
282
- let(:compliance_endpoint) { "/api/version" }
283
- let(:automate_endpoint) { "/compliance/version" }
284
- let(:automate2_endpoint) { "/dex/auth" }
285
- let(:headers) { nil }
286
- let(:insecure) { true }
287
-
288
- let(:good_response) { mock }
289
- let(:bad_response) { mock }
290
-
291
- it "returns `:automate2` when a 400 is received from `https://URL/dex/auth`" do
292
- good_response.stubs(:code).returns("400")
293
-
294
- InspecPlugins::Compliance::HTTP.expects(:get)
295
- .with(url + automate2_endpoint, headers, insecure)
296
- .returns(good_response)
297
-
298
- _(InspecPlugins::Compliance::API.determine_server_type(url, insecure)).must_equal(:automate2)
299
- end
300
-
301
- it "returns `:automate` when a 401 is received from `https://URL/compliance/version`" do
302
- good_response.stubs(:code).returns("401")
303
- bad_response.stubs(:code).returns("404")
304
-
305
- InspecPlugins::Compliance::HTTP.expects(:get)
306
- .with(url + automate2_endpoint, headers, insecure)
307
- .returns(bad_response)
308
- InspecPlugins::Compliance::HTTP.expects(:get)
309
- .with(url + automate_endpoint, headers, insecure)
310
- .returns(good_response)
311
-
312
- _(InspecPlugins::Compliance::API.determine_server_type(url, insecure)).must_equal(:automate)
313
- end
314
-
315
- # Chef Automate currently returns 401 for `/compliance/version` but some
316
- # versions of OpsWorks Chef Automate return 200 and a Chef Manage page when
317
- # unauthenticated requests are received.
318
- it "returns `:automate` when a 200 is received from `https://URL/compliance/version`" do
319
- bad_response.stubs(:code).returns("404")
320
- good_response.stubs(:code).returns("200")
321
- good_response.stubs(:body).returns("Are You Looking For the Chef Server?")
322
-
323
- InspecPlugins::Compliance::HTTP.expects(:get)
324
- .with(url + automate2_endpoint, headers, insecure)
325
- .returns(bad_response)
326
- InspecPlugins::Compliance::HTTP.expects(:get)
327
- .with(url + automate_endpoint, headers, insecure)
328
- .returns(good_response)
329
-
330
- _(InspecPlugins::Compliance::API.determine_server_type(url, insecure)).must_equal(:automate)
331
- end
332
-
333
- it "returns `nil` if a 200 is received from `https://URL/compliance/version` but not redirected to Chef Manage" do
334
- bad_response.stubs(:code).returns("200")
335
- bad_response.stubs(:body).returns("No Chef Manage here")
336
-
337
- InspecPlugins::Compliance::HTTP.expects(:get)
338
- .with(url + automate_endpoint, headers, insecure)
339
- .returns(bad_response)
340
- InspecPlugins::Compliance::HTTP.expects(:get)
341
- .with(url + automate2_endpoint, headers, insecure)
342
- .returns(bad_response)
343
-
344
- mock_compliance_response = mock
345
- mock_compliance_response.stubs(:code).returns("404")
346
- InspecPlugins::Compliance::HTTP.expects(:get)
347
- .with(url + compliance_endpoint, headers, insecure)
348
- .returns(mock_compliance_response)
349
-
350
- _(InspecPlugins::Compliance::API.determine_server_type(url, insecure)).must_be_nil
351
- end
352
-
353
- it "returns `:compliance` when a 200 is received from `https://URL/api/version`" do
354
- good_response.stubs(:code).returns("200")
355
- bad_response.stubs(:code).returns("404")
356
-
357
- InspecPlugins::Compliance::HTTP.expects(:get)
358
- .with(url + automate_endpoint, headers, insecure)
359
- .returns(bad_response)
360
- InspecPlugins::Compliance::HTTP.expects(:get)
361
- .with(url + automate2_endpoint, headers, insecure)
362
- .returns(bad_response)
363
- InspecPlugins::Compliance::HTTP.expects(:get)
364
- .with(url + compliance_endpoint, headers, insecure)
365
- .returns(good_response)
366
-
367
- _(InspecPlugins::Compliance::API.determine_server_type(url, insecure)).must_equal(:compliance)
368
- end
369
-
370
- it "returns `nil` if it cannot determine the server type" do
371
- bad_response.stubs(:code).returns("404")
372
-
373
- InspecPlugins::Compliance::HTTP.expects(:get)
374
- .with(url + automate2_endpoint, headers, insecure)
375
- .returns(bad_response)
376
- InspecPlugins::Compliance::HTTP.expects(:get)
377
- .with(url + automate_endpoint, headers, insecure)
378
- .returns(bad_response)
379
- InspecPlugins::Compliance::HTTP.expects(:get)
380
- .with(url + compliance_endpoint, headers, insecure)
381
- .returns(bad_response)
382
-
383
- _(InspecPlugins::Compliance::API.determine_server_type(url, insecure)).must_be_nil
384
- end
385
- end
386
- end
@@ -1,155 +0,0 @@
1
- require "minitest/autorun"
2
- require "mocha/setup"
3
- require_relative "../../lib/inspec-compliance/api.rb"
4
-
5
- describe InspecPlugins::Compliance::Fetcher do
6
- let(:config) { { "server" => "myserver" } }
7
-
8
- describe "the check_compliance_token method" do
9
- let(:fetcher) { InspecPlugins::Compliance::Fetcher.new("a/bad/url", config) }
10
-
11
- it "returns without error if token is set" do
12
- config["token"] = "my-token"
13
- fetcher.class.check_compliance_token("http://test.com", config)
14
- end
15
-
16
- it "returns an error when token is not set" do
17
- ex = assert_raises(Inspec::FetcherFailure) { fetcher.class.check_compliance_token("http://test.com", config) }
18
- _(ex.message).must_include "Cannot fetch http://test.com because your compliance token has not been\nconfigured."
19
- end
20
- end
21
-
22
- describe "when the server is an automate2 server" do
23
- before { InspecPlugins::Compliance::API.expects(:is_automate2_server?).with(config).returns(true) }
24
-
25
- it "returns the correct owner and profile name" do
26
- config["profile"] = ["admin", "ssh-baseline", nil]
27
- fetcher = InspecPlugins::Compliance::Fetcher.new("myserver/profile", config)
28
- _(fetcher.send(:compliance_profile_name)).must_equal "admin/ssh-baseline"
29
- end
30
- end
31
-
32
- describe "when the server is an automate server pre-0.8.0" do
33
- before { InspecPlugins::Compliance::API.expects(:is_automate_server_pre_080?).with(config).returns(true) }
34
-
35
- it "returns the correct profile name when the url is correct" do
36
- fetcher = InspecPlugins::Compliance::Fetcher.new("myserver/myowner/myprofile/tar", config)
37
- _(fetcher.send(:compliance_profile_name)).must_equal "myowner/myprofile"
38
- end
39
-
40
- it "raises an exception if the url is malformed" do
41
- fetcher = InspecPlugins::Compliance::Fetcher.new("a/bad/url", config)
42
- _(proc { fetcher.send(:compliance_profile_name) }).must_raise RuntimeError
43
- end
44
- end
45
-
46
- describe "when the server is an automate server 0.8.0-or-later" do
47
- before do
48
- InspecPlugins::Compliance::API.expects(:is_automate_server_pre_080?).with(config).returns(false)
49
- InspecPlugins::Compliance::API.expects(:is_automate_server_080_and_later?).with(config).returns(true)
50
- end
51
-
52
- it "returns the correct profile name when the url is correct" do
53
- fetcher = InspecPlugins::Compliance::Fetcher.new("myserver/profiles/myowner/myprofile/tar", config)
54
- _(fetcher.send(:compliance_profile_name)).must_equal "myowner/myprofile"
55
- end
56
-
57
- it "raises an exception if the url is malformed" do
58
- fetcher = InspecPlugins::Compliance::Fetcher.new("a/bad/url", config)
59
- _(proc { fetcher.send(:compliance_profile_name) }).must_raise RuntimeError
60
- end
61
- end
62
-
63
- describe "when the server is not an automate server (likely a compliance server)" do
64
- before do
65
- InspecPlugins::Compliance::API.expects(:is_automate_server_pre_080?).with(config).returns(false)
66
- InspecPlugins::Compliance::API.expects(:is_automate_server_080_and_later?).with(config).returns(false)
67
- end
68
-
69
- it "returns the correct profile name when the url is correct" do
70
- fetcher = InspecPlugins::Compliance::Fetcher.new("myserver/owners/myowner/compliance/myprofile/tar", config)
71
- _(fetcher.send(:compliance_profile_name)).must_equal "myowner/myprofile"
72
- end
73
-
74
- it "raises an exception if the url is malformed" do
75
- fetcher = InspecPlugins::Compliance::Fetcher.new("a/bad/url", config)
76
- _(proc { fetcher.send(:compliance_profile_name) }).must_raise RuntimeError
77
- end
78
- end
79
-
80
- describe "when the server calls an automate profile" do
81
- let(:profiles_result) do
82
- [{ "name" => "ssh-baseline",
83
- "title" => "InSpec Profile",
84
- "maintainer" => "The Authors",
85
- "copyright" => "The Authors",
86
- "copyright_email" => "you@example.com",
87
- "license" => "Apache-2.0",
88
- "summary" => "An InSpec Compliance Profile",
89
- "version" => "0.1.1",
90
- "owner" => "admin",
91
- "supports" => [],
92
- "depends" => [],
93
- "sha256" => "132j1kjdasfasdoaefaewo12312",
94
- "groups" => [],
95
- "controls" => [],
96
- "attributes" => [],
97
- "latest_version" => "" }]
98
- end
99
- before do
100
- InspecPlugins::Compliance::Configuration.expects(:new).returns({ "token" => "123abc", "server" => "https://a2.instance.com" })
101
- end
102
-
103
- it "returns the correct profile name when parsing url" do
104
- InspecPlugins::Compliance::API.stubs(:profiles).returns(["success", profiles_result])
105
- fetcher = InspecPlugins::Compliance::Fetcher.resolve("compliance://admin/ssh-baseline")
106
- assert = ["admin", "ssh-baseline", nil]
107
- _(fetcher.instance_variable_get(:"@config")["profile"]).must_equal assert
108
- end
109
-
110
- it "returns the correct profile name when parsing compliance hash" do
111
- InspecPlugins::Compliance::API.stubs(:profiles).returns(["success", profiles_result])
112
- hash = {
113
- target: "https://a2.instance.com/api/v0/compliance/tar",
114
- compliance: "admin/ssh-baseline",
115
- sha256: "132j1kjdasfasdoaefaewo12312",
116
- }
117
- fetcher = InspecPlugins::Compliance::Fetcher.resolve(hash)
118
- assert = ["admin", "ssh-baseline", nil]
119
- _(fetcher.instance_variable_get(:"@config")["profile"]).must_equal assert
120
- end
121
- end
122
-
123
- describe "when the server provides a sha256 in the profiles_result" do
124
- let(:profiles_result) do
125
- [{ "name" => "ssh-baseline",
126
- "title" => "InSpec Profile",
127
- "maintainer" => "The Authors",
128
- "copyright" => "The Authors",
129
- "copyright_email" => "you@example.com",
130
- "license" => "Apache-2.0",
131
- "summary" => "An InSpec Compliance Profile",
132
- "version" => "0.1.1",
133
- "owner" => "admin",
134
- "supports" => [],
135
- "depends" => [],
136
- "sha256" => "132j1kjdasfasdoaefaewo12312",
137
- "groups" => [],
138
- "controls" => [],
139
- "attributes" => [],
140
- "latest_version" => "" }]
141
- end
142
-
143
- before do
144
- InspecPlugins::Compliance::Configuration.expects(:new).returns({ "token" => "123abc", "server" => "https://a2.instance.com" })
145
- end
146
-
147
- it "contains the upstream_sha256" do
148
- InspecPlugins::Compliance::API.stubs(:profiles).returns(["success", profiles_result])
149
- prof = profiles_result[0]
150
- target = "compliance://#{prof["owner"]}/#{prof["name"]}"
151
- fetcher = InspecPlugins::Compliance::Fetcher.resolve(target)
152
- _(fetcher.upstream_sha256).must_equal prof["sha256"]
153
- end
154
- end
155
- end