inspec 0.30.0 → 0.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +50 -2
- data/Gemfile +2 -1
- data/docs/cli.rst +1 -17
- data/docs/resources.rst +128 -0
- data/docs/shell.rst +130 -0
- data/inspec.gemspec +3 -4
- data/lib/bundles/inspec-compliance/.kitchen.yml +0 -1
- data/lib/bundles/inspec-compliance/README.md +8 -3
- data/lib/bundles/inspec-compliance/api.rb +21 -6
- data/lib/bundles/inspec-compliance/bootstrap.sh +13 -9
- data/lib/bundles/inspec-compliance/cli.rb +23 -19
- data/lib/bundles/inspec-compliance/target.rb +1 -0
- data/lib/bundles/inspec-compliance/test/integration/default/cli.rb +42 -5
- data/lib/bundles/inspec-init/cli.rb +9 -0
- data/lib/bundles/inspec-supermarket/cli.rb +9 -0
- data/lib/bundles/inspec-supermarket/target.rb +2 -1
- data/lib/fetchers/local.rb +5 -2
- data/lib/fetchers/url.rb +1 -0
- data/lib/inspec/base_cli.rb +2 -1
- data/lib/inspec/cli.rb +14 -5
- data/lib/inspec/dependencies/dependency_set.rb +38 -0
- data/lib/inspec/dependencies/requirement.rb +103 -0
- data/lib/inspec/{dependencies.rb → dependencies/resolver.rb} +13 -132
- data/lib/inspec/dependencies/vendor_index.rb +98 -0
- data/lib/inspec/plugins/source_reader.rb +4 -0
- data/lib/inspec/profile.rb +2 -2
- data/lib/inspec/resource.rb +2 -0
- data/lib/inspec/runner.rb +13 -1
- data/lib/inspec/runner_mock.rb +4 -0
- data/lib/inspec/runner_rspec.rb +6 -2
- data/lib/inspec/shell.rb +22 -1
- data/lib/inspec/version.rb +1 -1
- data/lib/resources/iis_site.rb +107 -0
- data/lib/resources/port.rb +11 -4
- data/lib/resources/ssh_conf.rb +10 -2
- data/lib/resources/ssl.rb +94 -0
- data/lib/resources/xinetd.rb +11 -2
- data/lib/utils/parser.rb +6 -1
- metadata +17 -561
- data/lib/utils/hash_map.rb +0 -37
- data/tasks/maintainers.rb +0 -213
- data/test/bench/startup/startup.flat.txt +0 -1005
- data/test/bench/startup/startup.graph.html +0 -71958
- data/test/bench/startup/startup.grind.dat +0 -101602
- data/test/bench/startup/startup.stack.html +0 -24516
- data/test/bench/startup.flat.txt +0 -998
- data/test/bench/startup.graph.html +0 -71420
- data/test/bench/startup.grind.dat +0 -103554
- data/test/bench/startup.stack.html +0 -25015
- data/test/cookbooks/os_prepare/attributes/default.rb +0 -2
- data/test/cookbooks/os_prepare/files/empty.iso +0 -0
- data/test/cookbooks/os_prepare/files/example.csv +0 -7
- data/test/cookbooks/os_prepare/files/example.ini +0 -6
- data/test/cookbooks/os_prepare/files/example.json +0 -12
- data/test/cookbooks/os_prepare/files/example.yml +0 -7
- data/test/cookbooks/os_prepare/metadata.rb +0 -13
- data/test/cookbooks/os_prepare/recipes/_runit_service_centos.rb +0 -34
- data/test/cookbooks/os_prepare/recipes/_upstart_service_centos.rb +0 -25
- data/test/cookbooks/os_prepare/recipes/apache.rb +0 -14
- data/test/cookbooks/os_prepare/recipes/apt.rb +0 -20
- data/test/cookbooks/os_prepare/recipes/auditctl.rb +0 -8
- data/test/cookbooks/os_prepare/recipes/default.rb +0 -29
- data/test/cookbooks/os_prepare/recipes/file.rb +0 -46
- data/test/cookbooks/os_prepare/recipes/iptables.rb +0 -13
- data/test/cookbooks/os_prepare/recipes/json_yaml_csv_ini.rb +0 -34
- data/test/cookbooks/os_prepare/recipes/mount.rb +0 -33
- data/test/cookbooks/os_prepare/recipes/package.rb +0 -25
- data/test/cookbooks/os_prepare/recipes/postgres.rb +0 -20
- data/test/cookbooks/os_prepare/recipes/prep_container.rb +0 -15
- data/test/cookbooks/os_prepare/recipes/registry_key.rb +0 -87
- data/test/cookbooks/os_prepare/recipes/service.rb +0 -19
- data/test/cookbooks/os_prepare/templates/default/sv-default-svlog-run.erb +0 -2
- data/test/docker_run.rb +0 -162
- data/test/docker_test.rb +0 -58
- data/test/functional/helper.rb +0 -37
- data/test/functional/inheritance_test.rb +0 -62
- data/test/functional/inspec_archive_test.rb +0 -80
- data/test/functional/inspec_compliance_test.rb +0 -61
- data/test/functional/inspec_exec_json_test.rb +0 -122
- data/test/functional/inspec_exec_jsonmin_test.rb +0 -59
- data/test/functional/inspec_exec_test.rb +0 -123
- data/test/functional/inspec_json_profile_test.rb +0 -103
- data/test/functional/inspec_test.rb +0 -91
- data/test/helper.rb +0 -329
- data/test/integration/default/_debug_spec.rb +0 -8
- data/test/integration/default/apache_conf_spec.rb +0 -21
- data/test/integration/default/apt_spec.rb +0 -37
- data/test/integration/default/auditd_rules_spec.rb +0 -32
- data/test/integration/default/cmp_matcher_spec.rb +0 -115
- data/test/integration/default/csv_spec.rb +0 -11
- data/test/integration/default/etc_group_spec.rb +0 -29
- data/test/integration/default/file_spec.rb +0 -195
- data/test/integration/default/group_spec.rb +0 -59
- data/test/integration/default/ini_spec.rb +0 -11
- data/test/integration/default/iptables_spec.rb +0 -29
- data/test/integration/default/json_spec.rb +0 -11
- data/test/integration/default/kernel_module_spec.rb +0 -23
- data/test/integration/default/kernel_parameter_spec.rb +0 -60
- data/test/integration/default/mount_spec.rb +0 -19
- data/test/integration/default/os_spec.rb +0 -13
- data/test/integration/default/package_spec.rb +0 -30
- data/test/integration/default/port_spec.rb +0 -27
- data/test/integration/default/postgres_session_spec.rb +0 -13
- data/test/integration/default/powershell_spec.rb +0 -42
- data/test/integration/default/registry_key_spec.rb +0 -109
- data/test/integration/default/secpol_spec.rb +0 -11
- data/test/integration/default/service_spec.rb +0 -128
- data/test/integration/default/user_spec.rb +0 -96
- data/test/integration/default/vbscript_spec.rb +0 -22
- data/test/integration/default/wmi_spec.rb +0 -66
- data/test/integration/default/yaml_spec.rb +0 -11
- data/test/resource/command_test.rb +0 -33
- data/test/resource/dsl_test.rb +0 -45
- data/test/resource/file_test.rb +0 -146
- data/test/resource/ssh_config.rb +0 -9
- data/test/resource/sshd_config.rb +0 -9
- data/test/test-extra.yaml +0 -11
- data/test/test.yaml +0 -11
- data/test/unit/control_test.rb +0 -58
- data/test/unit/fetchers/local_test.rb +0 -67
- data/test/unit/fetchers/mock_test.rb +0 -43
- data/test/unit/fetchers/tar_test.rb +0 -36
- data/test/unit/fetchers/url_test.rb +0 -152
- data/test/unit/fetchers/zip_test.rb +0 -36
- data/test/unit/fetchers_test.rb +0 -65
- data/test/unit/metadata_test.rb +0 -137
- data/test/unit/mock/cmd/$env-PATH +0 -1
- data/test/unit/mock/cmd/Get-NetAdapter +0 -24
- data/test/unit/mock/cmd/GetUserAccount +0 -33
- data/test/unit/mock/cmd/GetWin32Group +0 -23
- data/test/unit/mock/cmd/Resolve-DnsName +0 -26
- data/test/unit/mock/cmd/Test-NetConnection +0 -4
- data/test/unit/mock/cmd/auditctl +0 -3
- data/test/unit/mock/cmd/auditctl-legacy +0 -7
- data/test/unit/mock/cmd/auditctl-s +0 -8
- data/test/unit/mock/cmd/auditpol +0 -2
- data/test/unit/mock/cmd/brew-info-jq +0 -1
- data/test/unit/mock/cmd/chage-l-root +0 -7
- data/test/unit/mock/cmd/dpkg-s-curl +0 -21
- data/test/unit/mock/cmd/dscl +0 -5
- data/test/unit/mock/cmd/env +0 -1
- data/test/unit/mock/cmd/etc-apt +0 -7
- data/test/unit/mock/cmd/find-apache2-conf-enabled +0 -1
- data/test/unit/mock/cmd/find-apache2-ports-conf +0 -1
- data/test/unit/mock/cmd/find-etc-rc-d-name-S +0 -12
- data/test/unit/mock/cmd/find-net-interface +0 -9
- data/test/unit/mock/cmd/find-xinetd.d +0 -2
- data/test/unit/mock/cmd/gem-list-local-a-q-rubocop +0 -1
- data/test/unit/mock/cmd/get-net-tcpconnection +0 -24
- data/test/unit/mock/cmd/get-netadapter-binding-bridge +0 -4
- data/test/unit/mock/cmd/get-package-firefox +0 -30
- data/test/unit/mock/cmd/get-package-ruby +0 -18
- data/test/unit/mock/cmd/get-service-dhcp +0 -10
- data/test/unit/mock/cmd/get-windows-feature +0 -7
- data/test/unit/mock/cmd/get-wmiobject +0 -9
- data/test/unit/mock/cmd/getent-hosts-example.com +0 -1
- data/test/unit/mock/cmd/getent-passwd-jfolmer +0 -1
- data/test/unit/mock/cmd/getent-passwd-root +0 -1
- data/test/unit/mock/cmd/hpux-netstat-inet +0 -10
- data/test/unit/mock/cmd/hpux-netstat-inet6 +0 -11
- data/test/unit/mock/cmd/id-chartmann +0 -1
- data/test/unit/mock/cmd/id-jfolmer +0 -1
- data/test/unit/mock/cmd/id-root +0 -1
- data/test/unit/mock/cmd/initctl--version +0 -5
- data/test/unit/mock/cmd/initctl-show-config-ssh +0 -3
- data/test/unit/mock/cmd/initctl-status-ssh +0 -1
- data/test/unit/mock/cmd/iptables-s +0 -6
- data/test/unit/mock/cmd/launchctl-list +0 -3
- data/test/unit/mock/cmd/logins-x +0 -4
- data/test/unit/mock/cmd/ls-1-etc-init.d +0 -2
- data/test/unit/mock/cmd/ls-sys-class-net-br +0 -2
- data/test/unit/mock/cmd/lsmod +0 -2
- data/test/unit/mock/cmd/lsof-nP-i-FpctPn +0 -63
- data/test/unit/mock/cmd/mount +0 -1
- data/test/unit/mock/cmd/mount-multiple +0 -2
- data/test/unit/mock/cmd/netstat-an.utf8 +0 -13
- data/test/unit/mock/cmd/netstat-tulpen +0 -6
- data/test/unit/mock/cmd/npm-ls-g--json-bower +0 -9
- data/test/unit/mock/cmd/pacman-qi-curl +0 -21
- data/test/unit/mock/cmd/ping-example.com +0 -6
- data/test/unit/mock/cmd/pip-show-jinja2 +0 -11
- data/test/unit/mock/cmd/pkg-info-system-file-system-zfs +0 -8
- data/test/unit/mock/cmd/pkginfo-l-SUNWzfsr +0 -7
- data/test/unit/mock/cmd/ps-aux +0 -5
- data/test/unit/mock/cmd/ps-auxZ +0 -3
- data/test/unit/mock/cmd/pw-usershow-root-7 +0 -1
- data/test/unit/mock/cmd/reg_schedule +0 -6
- data/test/unit/mock/cmd/rpm-qia-curl +0 -24
- data/test/unit/mock/cmd/s11-netstat-an-finet-finet6 +0 -32
- data/test/unit/mock/cmd/sbin_sysctl +0 -1
- data/test/unit/mock/cmd/secedit-export +0 -7
- data/test/unit/mock/cmd/service-e +0 -2
- data/test/unit/mock/cmd/service-sendmail-onestatus +0 -3
- data/test/unit/mock/cmd/service-sshd-status +0 -1
- data/test/unit/mock/cmd/sockstat +0 -5
- data/test/unit/mock/cmd/success +0 -0
- data/test/unit/mock/cmd/swlist-l-product +0 -1
- data/test/unit/mock/cmd/systemctl-show-all-dbus +0 -6
- data/test/unit/mock/cmd/systemctl-show-all-sshd +0 -7
- data/test/unit/mock/cmd/win32_product +0 -8
- data/test/unit/mock/cmd/yum-repolist-all +0 -52
- data/test/unit/mock/files/apache2.conf +0 -14
- data/test/unit/mock/files/auditd.conf +0 -4
- data/test/unit/mock/files/bond0 +0 -37
- data/test/unit/mock/files/etcgroup +0 -3
- data/test/unit/mock/files/example.csv +0 -6
- data/test/unit/mock/files/grub.conf +0 -21
- data/test/unit/mock/files/inetd.conf +0 -2
- data/test/unit/mock/files/kitchen.yml +0 -7
- data/test/unit/mock/files/limits.conf +0 -5
- data/test/unit/mock/files/login.defs +0 -5
- data/test/unit/mock/files/mysql.conf +0 -8
- data/test/unit/mock/files/mysql2.conf +0 -2
- data/test/unit/mock/files/ntp.conf +0 -5
- data/test/unit/mock/files/passwd +0 -2
- data/test/unit/mock/files/policyfile.lock.json +0 -12
- data/test/unit/mock/files/ports.conf +0 -6
- data/test/unit/mock/files/rootwrap.conf +0 -7
- data/test/unit/mock/files/serve-cgi-bin.conf +0 -20
- data/test/unit/mock/files/shadow +0 -2
- data/test/unit/mock/files/ssh_config +0 -5
- data/test/unit/mock/files/sshd_config +0 -7
- data/test/unit/mock/files/sysctl.conf +0 -7
- data/test/unit/mock/files/xinetd.conf +0 -9
- data/test/unit/mock/files/xinetd.d/.gitkeep +0 -0
- data/test/unit/mock/files/xinetd.d_chargen-dgram +0 -9
- data/test/unit/mock/files/xinetd.d_chargen-stream +0 -9
- data/test/unit/mock/profiles/complete-metadata/inspec.yml +0 -7
- data/test/unit/mock/profiles/complete-profile/controls/filesystem_spec.rb +0 -16
- data/test/unit/mock/profiles/complete-profile/inspec.yml +0 -10
- data/test/unit/mock/profiles/complete-profile/libraries/testlib.rb +0 -1
- data/test/unit/mock/profiles/empty-metadata/inspec.yml +0 -0
- data/test/unit/mock/profiles/legacy-complete-metadata/metadata.rb +0 -7
- data/test/unit/mock/profiles/legacy-complete-metadata/test/.gitkeep +0 -0
- data/test/unit/mock/profiles/legacy-empty-metadata/controls/.gitkeep +0 -0
- data/test/unit/mock/profiles/legacy-empty-metadata/metadata.rb +0 -0
- data/test/unit/mock/profiles/legacy-simple-metadata/metadata.rb +0 -1
- data/test/unit/mock/profiles/legacy-simple-metadata/test/.gitkeep +0 -0
- data/test/unit/mock/profiles/library/controls/filesystem_spec.rb +0 -7
- data/test/unit/mock/profiles/library/inspec.yml +0 -10
- data/test/unit/mock/profiles/library/libraries/gordonlib.rb +0 -2
- data/test/unit/mock/profiles/library/libraries/testlib.rb +0 -12
- data/test/unit/mock/profiles/resource-tiny/inspec.yml +0 -10
- data/test/unit/mock/profiles/resource-tiny/libraries/resource.rb +0 -3
- data/test/unit/mock/profiles/simple-metadata/inspec.yml +0 -1
- data/test/unit/mock/profiles/skippy-profile-os/controls/one.rb +0 -3
- data/test/unit/mock/profiles/skippy-profile-os/inspec.yml +0 -5
- data/test/unit/mock/profiles/spec_only/specfile.rb +0 -11
- data/test/unit/mock/profiles/supported_inspec/inspec.yml +0 -2
- data/test/unit/mock/profiles/unsupported_inspec/inspec.yml +0 -2
- data/test/unit/objects_test.rb +0 -65
- data/test/unit/plugin_test.rb +0 -44
- data/test/unit/plugins/resource_test.rb +0 -60
- data/test/unit/profile_context_test.rb +0 -345
- data/test/unit/profile_test.rb +0 -252
- data/test/unit/resources/apache_conf_test.rb +0 -31
- data/test/unit/resources/apt_test.rb +0 -46
- data/test/unit/resources/audit_policy_test.rb +0 -13
- data/test/unit/resources/auditd_conf_test.rb +0 -15
- data/test/unit/resources/auditd_rules_test.rb +0 -91
- data/test/unit/resources/bash_test.rb +0 -29
- data/test/unit/resources/bond_test.rb +0 -24
- data/test/unit/resources/bridge_test.rb +0 -56
- data/test/unit/resources/csv_test.rb +0 -35
- data/test/unit/resources/etc_group_test.rb +0 -37
- data/test/unit/resources/file_test.rb +0 -202
- data/test/unit/resources/gem_test.rb +0 -20
- data/test/unit/resources/group_test.rb +0 -96
- data/test/unit/resources/grub_conf_test.rb +0 -29
- data/test/unit/resources/host_test.rb +0 -38
- data/test/unit/resources/inetd_conf_test.rb +0 -15
- data/test/unit/resources/ini_test.rb +0 -16
- data/test/unit/resources/interface_test.rb +0 -54
- data/test/unit/resources/iptables_test.rb +0 -35
- data/test/unit/resources/json_test.rb +0 -36
- data/test/unit/resources/kernel_module_test.rb +0 -23
- data/test/unit/resources/kernel_parameter_test.rb +0 -13
- data/test/unit/resources/limits_conf_test.rb +0 -14
- data/test/unit/resources/login_def_test.rb +0 -16
- data/test/unit/resources/mount_test.rb +0 -26
- data/test/unit/resources/mysql_conf_test.rb +0 -14
- data/test/unit/resources/npm_test.rb +0 -20
- data/test/unit/resources/ntp_conf_test.rb +0 -16
- data/test/unit/resources/oneget_test.rb +0 -45
- data/test/unit/resources/os_env_test.rb +0 -18
- data/test/unit/resources/os_test.rb +0 -40
- data/test/unit/resources/package_test.rb +0 -87
- data/test/unit/resources/parse_config_test.rb +0 -26
- data/test/unit/resources/passwd_test.rb +0 -111
- data/test/unit/resources/pip_test.rb +0 -15
- data/test/unit/resources/port_test.rb +0 -165
- data/test/unit/resources/powershell_test.rb +0 -32
- data/test/unit/resources/processes_test.rb +0 -72
- data/test/unit/resources/registry_key_test.rb +0 -18
- data/test/unit/resources/security_policy_test.rb +0 -16
- data/test/unit/resources/service_test.rb +0 -305
- data/test/unit/resources/shadow_test.rb +0 -67
- data/test/unit/resources/ssh_conf_test.rb +0 -33
- data/test/unit/resources/user_test.rb +0 -124
- data/test/unit/resources/vbscript_test.rb +0 -18
- data/test/unit/resources/windows_feature.rb +0 -17
- data/test/unit/resources/wmi_test.rb +0 -42
- data/test/unit/resources/xinetd_test.rb +0 -60
- data/test/unit/resources/yaml_test.rb +0 -34
- data/test/unit/resources/yum_test.rb +0 -68
- data/test/unit/shell_detector_test.rb +0 -78
- data/test/unit/source_reader_test.rb +0 -17
- data/test/unit/source_readers/flat_test.rb +0 -61
- data/test/unit/source_readers/inspec_test.rb +0 -38
- data/test/unit/utils/filter_array_test.rb +0 -59
- data/test/unit/utils/filter_table_test.rb +0 -177
- data/test/unit/utils/find_files_test.rb +0 -23
- data/test/unit/utils/passwd_parser_test.rb +0 -32
- data/test/unit/utils/simpleconfig_test.rb +0 -80
- data/test/unit/utils/solaris_netstat_parser.rb +0 -124
|
@@ -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::SecurityPolicy' do
|
|
9
|
-
it 'verify processes resource' do
|
|
10
|
-
resource = load_resource('security_policy')
|
|
11
|
-
_(resource.MaximumPasswordAge).must_equal 42
|
|
12
|
-
_(resource.send('MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Setup\RecoveryConsole\SecurityLevel')).must_equal '4,0'
|
|
13
|
-
_(resource.SeUndockPrivilege).must_equal '*S-1-5-32-544'
|
|
14
|
-
_(resource.SeRemoteInteractiveLogonRight).must_equal '*S-1-5-32-544,*S-1-5-32-555'
|
|
15
|
-
end
|
|
16
|
-
end
|
|
@@ -1,305 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# author: Christoph Hartmann
|
|
3
|
-
# author: Dominik Richter
|
|
4
|
-
|
|
5
|
-
require 'helper'
|
|
6
|
-
require 'inspec/resource'
|
|
7
|
-
require 'hashie'
|
|
8
|
-
|
|
9
|
-
describe 'Inspec::Resources::Service' do
|
|
10
|
-
let(:runlevels) { {0=>false, 1=>false, 2=>true, 3=>true, 4=>true, 5=>true, 6=>false} }
|
|
11
|
-
|
|
12
|
-
# windows
|
|
13
|
-
it 'verify service parsing' do
|
|
14
|
-
resource = MockLoader.new(:windows).load_resource('service', 'dhcp')
|
|
15
|
-
params = Hashie::Mash.new({})
|
|
16
|
-
_(resource.type).must_equal 'windows'
|
|
17
|
-
_(resource.name).must_equal 'dhcp'
|
|
18
|
-
_(resource.description).must_equal 'DHCP Client'
|
|
19
|
-
_(resource.installed?).must_equal true
|
|
20
|
-
_(resource.enabled?).must_equal true
|
|
21
|
-
_(resource.running?).must_equal true
|
|
22
|
-
_(resource.params).must_equal params
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# ubuntu 14.04 with upstart
|
|
26
|
-
it 'verify ubuntu package parsing' do
|
|
27
|
-
resource = MockLoader.new(:ubuntu1404).load_resource('service', 'ssh')
|
|
28
|
-
params = Hashie::Mash.new({})
|
|
29
|
-
_(resource.type).must_equal 'upstart'
|
|
30
|
-
_(resource.name).must_equal 'ssh'
|
|
31
|
-
_(resource.description).must_equal nil
|
|
32
|
-
_(resource.installed?).must_equal true
|
|
33
|
-
_(resource.enabled?).must_equal true
|
|
34
|
-
_(resource.running?).must_equal true
|
|
35
|
-
_(resource.params).must_equal params
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it 'verify ubuntu package parsing with default upstart_service' do
|
|
39
|
-
resource = MockLoader.new(:ubuntu1404).load_resource('upstart_service', 'ssh')
|
|
40
|
-
params = Hashie::Mash.new({})
|
|
41
|
-
_(resource.type).must_equal 'upstart'
|
|
42
|
-
_(resource.name).must_equal 'ssh'
|
|
43
|
-
_(resource.description).must_equal nil
|
|
44
|
-
_(resource.installed?).must_equal true
|
|
45
|
-
_(resource.enabled?).must_equal true
|
|
46
|
-
_(resource.running?).must_equal true
|
|
47
|
-
_(resource.params).must_equal params
|
|
48
|
-
_(resource.params.UnitFileState).must_equal nil
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
# ubuntu 15.04 with systemd
|
|
52
|
-
it 'verify ubuntu package parsing' do
|
|
53
|
-
resource = MockLoader.new(:ubuntu1504).load_resource('service', 'sshd')
|
|
54
|
-
params = Hashie::Mash.new({ 'ActiveState' => 'active', 'Description' => 'OpenSSH server daemon', 'Id' => 'sshd.service', 'LoadState' => 'loaded', 'Names' => 'sshd.service', 'SubState' => 'running', 'UnitFileState' => 'enabled' })
|
|
55
|
-
_(resource.type).must_equal 'systemd'
|
|
56
|
-
_(resource.name).must_equal 'sshd.service'
|
|
57
|
-
_(resource.description).must_equal 'OpenSSH server daemon'
|
|
58
|
-
_(resource.installed?).must_equal true
|
|
59
|
-
_(resource.enabled?).must_equal true
|
|
60
|
-
_(resource.running?).must_equal true
|
|
61
|
-
_(resource.params).must_equal params
|
|
62
|
-
_(resource.params.SubState).must_equal 'running'
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
it 'verify ubuntu package parsing with default systemd_service' do
|
|
66
|
-
resource = MockLoader.new(:ubuntu1504).load_resource('systemd_service', 'sshd')
|
|
67
|
-
params = Hashie::Mash.new({ 'ActiveState' => 'active', 'Description' => 'OpenSSH server daemon', 'Id' => 'sshd.service', 'LoadState' => 'loaded', 'Names' => 'sshd.service', 'SubState' => 'running', 'UnitFileState' => 'enabled' })
|
|
68
|
-
_(resource.type).must_equal 'systemd'
|
|
69
|
-
_(resource.name).must_equal 'sshd.service'
|
|
70
|
-
_(resource.description).must_equal 'OpenSSH server daemon'
|
|
71
|
-
_(resource.installed?).must_equal true
|
|
72
|
-
_(resource.enabled?).must_equal true
|
|
73
|
-
_(resource.running?).must_equal true
|
|
74
|
-
_(resource.params).must_equal params
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
# centos 6 with sysv
|
|
78
|
-
it 'verify centos 6 package parsing' do
|
|
79
|
-
resource = MockLoader.new(:centos6).load_resource('service', 'sshd')
|
|
80
|
-
params = Hashie::Mash.new({})
|
|
81
|
-
_(resource.type).must_equal 'sysv'
|
|
82
|
-
_(resource.name).must_equal 'sshd'
|
|
83
|
-
_(resource.description).must_equal nil
|
|
84
|
-
_(resource.installed?).must_equal true
|
|
85
|
-
_(resource.enabled?).must_equal true
|
|
86
|
-
_(resource.running?).must_equal true
|
|
87
|
-
_(resource.params).must_equal params
|
|
88
|
-
_(resource.params.SubState).must_equal nil
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
it 'verify centos 6 package parsing with default sysv_service' do
|
|
92
|
-
resource = MockLoader.new(:centos6).load_resource('sysv_service', 'sshd')
|
|
93
|
-
params = Hashie::Mash.new({})
|
|
94
|
-
_(resource.type).must_equal 'sysv'
|
|
95
|
-
_(resource.name).must_equal 'sshd'
|
|
96
|
-
_(resource.description).must_equal nil
|
|
97
|
-
_(resource.installed?).must_equal true
|
|
98
|
-
_(resource.enabled?).must_equal true
|
|
99
|
-
_(resource.running?).must_equal true
|
|
100
|
-
_(resource.params).must_equal params
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
# centos 7 with systemd
|
|
104
|
-
it 'verify centos 7 package parsing' do
|
|
105
|
-
resource = MockLoader.new(:centos7).load_resource('service', 'sshd')
|
|
106
|
-
params = Hashie::Mash.new({ 'ActiveState' => 'active', 'Description' => 'OpenSSH server daemon', 'Id' => 'sshd.service', 'LoadState' => 'loaded', 'Names' => 'sshd.service', 'SubState' => 'running', 'UnitFileState' => 'enabled' })
|
|
107
|
-
_(resource.type).must_equal 'systemd'
|
|
108
|
-
_(resource.name).must_equal 'sshd.service'
|
|
109
|
-
_(resource.description).must_equal 'OpenSSH server daemon'
|
|
110
|
-
_(resource.installed?).must_equal true
|
|
111
|
-
_(resource.enabled?).must_equal true
|
|
112
|
-
_(resource.running?).must_equal true
|
|
113
|
-
_(resource.params).must_equal params
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
it 'verify centos 7 package parsing with systemd_service and service_ctl override' do
|
|
117
|
-
resource = MockLoader.new(:centos7).load_resource('systemd_service', 'sshd', '/path/to/systemctl')
|
|
118
|
-
params = Hashie::Mash.new({ 'ActiveState' => 'active', 'Description' => 'OpenSSH server daemon', 'Id' => 'sshd.service', 'LoadState' => 'loaded', 'Names' => 'sshd.service', 'UnitFileState' => 'enabled', 'SubState' => 'running' })
|
|
119
|
-
_(resource.type).must_equal 'systemd'
|
|
120
|
-
_(resource.name).must_equal 'sshd.service'
|
|
121
|
-
_(resource.description).must_equal 'OpenSSH server daemon'
|
|
122
|
-
_(resource.installed?).must_equal true
|
|
123
|
-
_(resource.enabled?).must_equal true
|
|
124
|
-
_(resource.running?).must_equal true
|
|
125
|
-
_(resource.params).must_equal params
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
it 'verify centos 7 package parsing with static loaded service' do
|
|
129
|
-
resource = MockLoader.new(:centos7).load_resource('service', 'dbus')
|
|
130
|
-
params = Hashie::Mash.new({ 'Description' => 'D-Bus System Message Bus', 'Id' => 'dbus.service', 'LoadState' => 'loaded', 'Names' => 'messagebus.service dbus.service', 'SubState' => 'running', 'UnitFileState' => 'static' })
|
|
131
|
-
_(resource.type).must_equal 'systemd'
|
|
132
|
-
_(resource.name).must_equal 'dbus.service'
|
|
133
|
-
_(resource.description).must_equal 'D-Bus System Message Bus'
|
|
134
|
-
_(resource.installed?).must_equal true
|
|
135
|
-
_(resource.enabled?).must_equal true
|
|
136
|
-
_(resource.running?).must_equal true
|
|
137
|
-
_(resource.params).must_equal params
|
|
138
|
-
_(resource.params.UnitFileState).must_equal 'static'
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
# freebsd
|
|
142
|
-
it 'verify freebsd10 package parsing' do
|
|
143
|
-
resource = MockLoader.new(:freebsd10).load_resource('service', 'sendmail')
|
|
144
|
-
params = Hashie::Mash.new({})
|
|
145
|
-
_(resource.type).must_equal 'bsd-init'
|
|
146
|
-
_(resource.name).must_equal 'sendmail'
|
|
147
|
-
_(resource.description).must_equal nil
|
|
148
|
-
_(resource.installed?).must_equal true
|
|
149
|
-
_(resource.enabled?).must_equal true
|
|
150
|
-
_(resource.running?).must_equal true
|
|
151
|
-
_(resource.params).must_equal params
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
it 'verify freebsd10 package parsing with default bsd_service' do
|
|
155
|
-
resource = MockLoader.new(:freebsd10).load_resource('bsd_service', 'sendmail')
|
|
156
|
-
params = Hashie::Mash.new({})
|
|
157
|
-
_(resource.type).must_equal 'bsd-init'
|
|
158
|
-
_(resource.name).must_equal 'sendmail'
|
|
159
|
-
_(resource.description).must_equal nil
|
|
160
|
-
_(resource.installed?).must_equal true
|
|
161
|
-
_(resource.enabled?).must_equal true
|
|
162
|
-
_(resource.running?).must_equal true
|
|
163
|
-
_(resource.params).must_equal params
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
# arch linux with systemd
|
|
167
|
-
it 'verify arch linux package parsing' do
|
|
168
|
-
resource = MockLoader.new(:arch).load_resource('service', 'sshd')
|
|
169
|
-
params = Hashie::Mash.new({ 'ActiveState' => 'active', 'Description' => 'OpenSSH server daemon', 'Id' => 'sshd.service', 'LoadState' => 'loaded', 'Names' => 'sshd.service', 'SubState' => 'running', 'UnitFileState' => 'enabled' })
|
|
170
|
-
_(resource.type).must_equal 'systemd'
|
|
171
|
-
_(resource.name).must_equal 'sshd.service'
|
|
172
|
-
_(resource.description).must_equal 'OpenSSH server daemon'
|
|
173
|
-
_(resource.installed?).must_equal true
|
|
174
|
-
_(resource.enabled?).must_equal true
|
|
175
|
-
_(resource.running?).must_equal true
|
|
176
|
-
_(resource.params).must_equal params
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
# debian 7 with systemv
|
|
180
|
-
it 'verify debian 7 package parsing' do
|
|
181
|
-
resource = MockLoader.new(:debian7).load_resource('service', 'sshd')
|
|
182
|
-
params = Hashie::Mash.new({})
|
|
183
|
-
_(resource.type).must_equal 'sysv'
|
|
184
|
-
_(resource.name).must_equal 'sshd'
|
|
185
|
-
_(resource.description).must_equal nil
|
|
186
|
-
_(resource.installed?).must_equal true
|
|
187
|
-
_(resource.enabled?).must_equal true
|
|
188
|
-
_(resource.running?).must_equal true
|
|
189
|
-
_(resource.params).must_equal params
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
# debian 8 with systemd
|
|
193
|
-
it 'verify debian 8 package parsing' do
|
|
194
|
-
resource = MockLoader.new(:debian8).load_resource('service', 'sshd')
|
|
195
|
-
params = Hashie::Mash.new({ 'ActiveState' => 'active', 'Description' => 'OpenSSH server daemon', 'Id' => 'sshd.service', 'LoadState' => 'loaded', 'Names' => 'sshd.service', 'SubState' => 'running', 'UnitFileState' => 'enabled' })
|
|
196
|
-
_(resource.type).must_equal 'systemd'
|
|
197
|
-
_(resource.name).must_equal 'sshd.service'
|
|
198
|
-
_(resource.description).must_equal 'OpenSSH server daemon'
|
|
199
|
-
_(resource.installed?).must_equal true
|
|
200
|
-
_(resource.enabled?).must_equal true
|
|
201
|
-
_(resource.running?).must_equal true
|
|
202
|
-
_(resource.params).must_equal params
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
# macos test
|
|
206
|
-
it 'verify mac osx package parsing' do
|
|
207
|
-
resource = MockLoader.new(:osx104).load_resource('service', 'ssh')
|
|
208
|
-
params = Hashie::Mash.new({})
|
|
209
|
-
_(resource.type).must_equal 'darwin'
|
|
210
|
-
_(resource.name).must_equal 'org.openbsd.ssh-agent'
|
|
211
|
-
_(resource.description).must_equal nil
|
|
212
|
-
_(resource.installed?).must_equal true
|
|
213
|
-
_(resource.enabled?).must_equal true
|
|
214
|
-
_(resource.running?).must_equal true
|
|
215
|
-
_(resource.params).must_equal params
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
it 'verify mac osx package parsing with not-running service' do
|
|
219
|
-
resource = MockLoader.new(:osx104).load_resource('service', 'FilesystemUI')
|
|
220
|
-
params = Hashie::Mash.new({})
|
|
221
|
-
_(resource.type).must_equal 'darwin'
|
|
222
|
-
_(resource.name).must_equal 'com.apple.FilesystemUI'
|
|
223
|
-
_(resource.description).must_equal nil
|
|
224
|
-
_(resource.installed?).must_equal true
|
|
225
|
-
_(resource.enabled?).must_equal true
|
|
226
|
-
_(resource.running?).must_equal false
|
|
227
|
-
_(resource.params).must_equal params
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
it 'verify mac osx package parsing with default launchd_service' do
|
|
231
|
-
resource = MockLoader.new(:osx104).load_resource('launchd_service', 'ssh')
|
|
232
|
-
params = Hashie::Mash.new({})
|
|
233
|
-
_(resource.type).must_equal 'darwin'
|
|
234
|
-
_(resource.name).must_equal 'org.openbsd.ssh-agent'
|
|
235
|
-
_(resource.description).must_equal nil
|
|
236
|
-
_(resource.installed?).must_equal true
|
|
237
|
-
_(resource.enabled?).must_equal true
|
|
238
|
-
_(resource.running?).must_equal true
|
|
239
|
-
_(resource.params).must_equal params
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
# wrlinux
|
|
243
|
-
it 'verify wrlinux package parsing' do
|
|
244
|
-
resource = MockLoader.new(:wrlinux).load_resource('service', 'sshd')
|
|
245
|
-
params = Hashie::Mash.new({})
|
|
246
|
-
_(resource.type).must_equal 'sysv'
|
|
247
|
-
_(resource.name).must_equal 'sshd'
|
|
248
|
-
_(resource.description).must_equal nil
|
|
249
|
-
_(resource.installed?).must_equal true
|
|
250
|
-
_(resource.enabled?).must_equal true
|
|
251
|
-
_(resource.running?).must_equal true
|
|
252
|
-
_(resource.params).must_equal params
|
|
253
|
-
end
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
# unknown OS
|
|
257
|
-
it 'verify package handling on unsupported os' do
|
|
258
|
-
resource = MockLoader.new(:undefined).load_resource('service', 'dhcp')
|
|
259
|
-
params = Hashie::Mash.new({})
|
|
260
|
-
_(resource.installed?).must_equal false
|
|
261
|
-
_(resource.description).must_equal nil
|
|
262
|
-
_(resource.params).must_equal params
|
|
263
|
-
end
|
|
264
|
-
|
|
265
|
-
# runlevel detection
|
|
266
|
-
describe 'runlevels on centos 6 (system V)' do
|
|
267
|
-
let(:service) { MockLoader.new(:centos6).load_resource('service', 'sshd') }
|
|
268
|
-
|
|
269
|
-
it 'grabs all runlevels' do
|
|
270
|
-
service.runlevels.keys.must_equal [0, 1, 2, 3, 4, 5, 6]
|
|
271
|
-
end
|
|
272
|
-
|
|
273
|
-
it 'grabs runlevels via filter nil' do
|
|
274
|
-
service.runlevels(nil).keys.must_equal [0, 1, 2, 3, 4, 5, 6]
|
|
275
|
-
end
|
|
276
|
-
|
|
277
|
-
it 'grabs runlevels by number' do
|
|
278
|
-
service.runlevels(3).keys.must_equal [3]
|
|
279
|
-
end
|
|
280
|
-
|
|
281
|
-
it 'grabs runlevels by multiple numbers' do
|
|
282
|
-
service.runlevels(3, 4, 8).keys.must_equal [3, 4]
|
|
283
|
-
end
|
|
284
|
-
|
|
285
|
-
it 'grabs runlevels via regex' do
|
|
286
|
-
service.runlevels(/[5-9]/).keys.must_equal [5, 6]
|
|
287
|
-
end
|
|
288
|
-
|
|
289
|
-
it 'checks enabled true if all services are enabled' do
|
|
290
|
-
service.runlevels(2, 4).enabled?.must_equal true
|
|
291
|
-
end
|
|
292
|
-
|
|
293
|
-
it 'checks enabled false if some services are not enabled' do
|
|
294
|
-
service.runlevels(1, 4).enabled?.must_equal false
|
|
295
|
-
end
|
|
296
|
-
|
|
297
|
-
it 'checks disabled true if all services are disabled' do
|
|
298
|
-
service.runlevels(0, 1).disabled?.must_equal true
|
|
299
|
-
end
|
|
300
|
-
|
|
301
|
-
it 'checks disabled false if some services are not disabled' do
|
|
302
|
-
service.runlevels(0, 4).enabled?.must_equal false
|
|
303
|
-
end
|
|
304
|
-
end
|
|
305
|
-
end
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
# author: Dominik Richter
|
|
3
|
-
# author: Christoph Hartmann
|
|
4
|
-
|
|
5
|
-
require 'helper'
|
|
6
|
-
require 'inspec/resource'
|
|
7
|
-
|
|
8
|
-
describe 'Inspec::Resources::Shadow' do
|
|
9
|
-
let(:shadow) { load_resource('shadow') }
|
|
10
|
-
|
|
11
|
-
it 'retrieve users via field' do
|
|
12
|
-
_(shadow.users).must_equal %w{root www-data}
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
it 'retrieve passwords via field' do
|
|
16
|
-
_(shadow.passwords).must_equal %w{x !!}
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it 'retrieve last password change via field' do
|
|
20
|
-
_(shadow.last_changes).must_equal %w{1 10}
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it 'retrieve min password days via field' do
|
|
24
|
-
_(shadow.min_days).must_equal %w{2 20}
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it 'retrieve max password days via field' do
|
|
28
|
-
_(shadow.max_days).must_equal %w{3 30}
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it 'retrieve warning days for password expiry via field' do
|
|
32
|
-
_(shadow.warn_days).must_equal [nil, "40"]
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it 'retrieve days before account is inactive via field' do
|
|
36
|
-
_(shadow.inactive_days).must_equal [nil, "50"]
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it 'retrieve dates when account will expire via field' do
|
|
40
|
-
_(shadow.expiry_dates).must_equal [nil, "60"]
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it 'access all lines of the file' do
|
|
44
|
-
_(shadow.lines[0]).must_equal 'root:x:1:2:3::::'
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it 'access all params of the file' do
|
|
48
|
-
_(shadow.params[0]).must_equal({
|
|
49
|
-
'user' => 'root', 'password' => 'x', 'last_change' => '1',
|
|
50
|
-
'min_days' => '2', 'max_days' => '3', 'warn_days' => nil,
|
|
51
|
-
'inactive_days' => nil, 'expiry_date' => nil, 'reserved' => nil,
|
|
52
|
-
})
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
describe 'filter via name =~ /^www/' do
|
|
56
|
-
let(:child) { shadow.users(/^www/) }
|
|
57
|
-
|
|
58
|
-
it 'filters by user via name (regex)' do
|
|
59
|
-
_(child.users).must_equal ['www-data']
|
|
60
|
-
_(child.count).must_equal 1
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
it 'prints a nice to_s string' do
|
|
64
|
-
_(child.to_s).must_equal '/etc/shadow with user = /^www/'
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
@@ -1,33 +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::SshConf' do
|
|
9
|
-
|
|
10
|
-
describe 'ssh_config' do
|
|
11
|
-
it 'check ssh config parsing' do
|
|
12
|
-
resource = load_resource('ssh_config')
|
|
13
|
-
_(resource.Host).must_equal '*'
|
|
14
|
-
_(resource.Tunnel).must_equal nil
|
|
15
|
-
_(resource.SendEnv).must_equal 'LANG LC_*'
|
|
16
|
-
_(resource.HashKnownHosts).must_equal 'yes'
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
describe 'sshd_config' do
|
|
21
|
-
it 'check protocol version' do
|
|
22
|
-
resource = load_resource('sshd_config')
|
|
23
|
-
_(resource.Port).must_equal '22'
|
|
24
|
-
_(resource.UsePAM).must_equal 'yes'
|
|
25
|
-
_(resource.ListenAddress).must_equal nil
|
|
26
|
-
_(resource.HostKey).must_equal [
|
|
27
|
-
'/etc/ssh/ssh_host_rsa_key',
|
|
28
|
-
'/etc/ssh/ssh_host_dsa_key',
|
|
29
|
-
'/etc/ssh/ssh_host_ecdsa_key',
|
|
30
|
-
]
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
@@ -1,124 +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::User' do
|
|
9
|
-
|
|
10
|
-
# ubuntu 14.04 with upstart
|
|
11
|
-
it 'read user on ubuntu' do
|
|
12
|
-
resource = MockLoader.new(:ubuntu1404).load_resource('user', 'root')
|
|
13
|
-
_(resource.exists?).must_equal true
|
|
14
|
-
_(resource.group).must_equal 'root'
|
|
15
|
-
_(resource.groups).must_equal ['root']
|
|
16
|
-
_(resource.home).must_equal '/root'
|
|
17
|
-
_(resource.shell).must_equal '/bin/bash'
|
|
18
|
-
_(resource.mindays).must_equal 0
|
|
19
|
-
_(resource.maxdays).must_equal 99999
|
|
20
|
-
_(resource.warndays).must_equal 7
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# ubuntu 14.04 test with ldap user
|
|
24
|
-
it 'read user on ubuntu' do
|
|
25
|
-
resource = MockLoader.new(:ubuntu1404).load_resource('user', 'jfolmer')
|
|
26
|
-
_(resource.exists?).must_equal true
|
|
27
|
-
_(resource.group).must_equal 'domain users'
|
|
28
|
-
_(resource.groups).must_equal ['domain users', 'domain admins', 'denied rodc password replication group']
|
|
29
|
-
_(resource.home).must_equal '/jfolmer'
|
|
30
|
-
_(resource.shell).must_equal '/bin/bash'
|
|
31
|
-
_(resource.mindays).must_equal 0
|
|
32
|
-
_(resource.maxdays).must_equal 99999
|
|
33
|
-
_(resource.warndays).must_equal 7
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# serverspec compatibility tests (do not test matcher)
|
|
37
|
-
it 'verify serverspec compatibility' do
|
|
38
|
-
resource = MockLoader.new(:ubuntu1404).load_resource('user', 'root')
|
|
39
|
-
_(resource.has_uid?(0)).must_equal true
|
|
40
|
-
_(resource.has_home_directory?('/root')).must_equal true
|
|
41
|
-
_(resource.has_login_shell?('/bin/bash')).must_equal true
|
|
42
|
-
_(resource.minimum_days_between_password_change).must_equal 0
|
|
43
|
-
_(resource.maximum_days_between_password_change).must_equal 99999
|
|
44
|
-
# _(resource.has_authorized_key?('abc')).must_equal true
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it 'read user on centos7' do
|
|
48
|
-
resource = MockLoader.new(:centos7).load_resource('user', 'root')
|
|
49
|
-
_(resource.exists?).must_equal true
|
|
50
|
-
_(resource.group).must_equal 'root'
|
|
51
|
-
_(resource.groups).must_equal ['root']
|
|
52
|
-
_(resource.home).must_equal '/root'
|
|
53
|
-
_(resource.shell).must_equal '/bin/bash'
|
|
54
|
-
_(resource.mindays).must_equal 0
|
|
55
|
-
_(resource.maxdays).must_equal 99999
|
|
56
|
-
_(resource.warndays).must_equal 7
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it 'read user on centos7' do
|
|
60
|
-
resource = MockLoader.new(:wrlinux).load_resource('user', 'root')
|
|
61
|
-
_(resource.exists?).must_equal true
|
|
62
|
-
_(resource.group).must_equal 'root'
|
|
63
|
-
_(resource.groups).must_equal ['root']
|
|
64
|
-
_(resource.home).must_equal '/root'
|
|
65
|
-
_(resource.shell).must_equal '/bin/bash'
|
|
66
|
-
_(resource.mindays).must_equal 0
|
|
67
|
-
_(resource.maxdays).must_equal 99999
|
|
68
|
-
_(resource.warndays).must_equal 7
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it 'read user on hpux' do
|
|
72
|
-
resource = MockLoader.new(:hpux).load_resource('user', 'root')
|
|
73
|
-
_(resource.home).must_equal '/'
|
|
74
|
-
_(resource.shell).must_equal '/sbin/sh'
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it 'read user on freebsd' do
|
|
78
|
-
resource = MockLoader.new(:freebsd10).load_resource('user', 'root')
|
|
79
|
-
_(resource.exists?).must_equal true
|
|
80
|
-
_(resource.group).must_equal 'root'
|
|
81
|
-
_(resource.groups).must_equal ['root']
|
|
82
|
-
_(resource.home).must_equal '/root'
|
|
83
|
-
_(resource.shell).must_equal '/bin/csh'
|
|
84
|
-
_(resource.mindays).must_equal nil
|
|
85
|
-
_(resource.maxdays).must_equal nil
|
|
86
|
-
_(resource.warndays).must_equal nil
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it 'read user on OSX' do
|
|
90
|
-
resource = MockLoader.new(:osx104).load_resource('user', 'chartmann')
|
|
91
|
-
_(resource.exists?).must_equal true
|
|
92
|
-
_(resource.group).must_equal 'staff'
|
|
93
|
-
_(resource.groups).must_equal ['staff', 'com.apple.sharepoint.group.1', 'everyone']
|
|
94
|
-
_(resource.home).must_equal '/Users/chartmann'
|
|
95
|
-
_(resource.shell).must_equal '/bin/zsh'
|
|
96
|
-
_(resource.mindays).must_equal nil
|
|
97
|
-
_(resource.maxdays).must_equal nil
|
|
98
|
-
_(resource.warndays).must_equal nil
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
it 'read user on Windows' do
|
|
102
|
-
resource = MockLoader.new(:windows).load_resource('user', 'example/Administrator')
|
|
103
|
-
_(resource.exists?).must_equal true
|
|
104
|
-
_(resource.group).must_equal nil
|
|
105
|
-
_(resource.groups).must_equal ['WIN-K0AKLED332V\\Administrators', 'EXAMPLE\\Domain Admins']
|
|
106
|
-
_(resource.home).must_equal nil
|
|
107
|
-
_(resource.shell).must_equal nil
|
|
108
|
-
_(resource.mindays).must_equal nil
|
|
109
|
-
_(resource.maxdays).must_equal nil
|
|
110
|
-
_(resource.warndays).must_equal nil
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
it 'read user on undefined os' do
|
|
114
|
-
resource = MockLoader.new(:undefined).load_resource('user', 'example/Administrator')
|
|
115
|
-
_(resource.exists?).must_equal false
|
|
116
|
-
_(resource.group).must_equal nil
|
|
117
|
-
_(resource.groups).must_equal nil
|
|
118
|
-
_(resource.home).must_equal nil
|
|
119
|
-
_(resource.shell).must_equal nil
|
|
120
|
-
_(resource.mindays).must_equal nil
|
|
121
|
-
_(resource.maxdays).must_equal nil
|
|
122
|
-
_(resource.warndays).must_equal nil
|
|
123
|
-
end
|
|
124
|
-
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::VbScript' do
|
|
9
|
-
|
|
10
|
-
vb_script = <<-EOH
|
|
11
|
-
WScript.Echo "hello vbscript"
|
|
12
|
-
EOH
|
|
13
|
-
|
|
14
|
-
it 'check if `vbscript` for windows is properly generated ' do
|
|
15
|
-
resource = MockLoader.new(:windows).load_resource('vbscript', vb_script)
|
|
16
|
-
_(resource.command).must_equal 'powershell -encodedCommand JABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQA9ACcAUwBpAGwAZQBuAHQAbAB5AEMAbwBuAHQAaQBuAHUAZQAnADsAJAB2AGIAcwBjAHIAaQBwAHQAIAA9ACAAQAAiAAoAIAAgACAAIABXAFMAYwByAGkAcAB0AC4ARQBjAGgAbwAgACIAaABlAGwAbABvACAAdgBiAHMAYwByAGkAcAB0ACIACgAKACIAQAAKACQAZgBpAGwAZQBuAGEAbQBlACAAPQAgAFsAUwB5AHMAdABlAG0ALgBJAE8ALgBQAGEAdABoAF0AOgA6AEcAZQB0AFQAZQBtAHAARgBpAGwAZQBOAGEAbQBlACgAKQAgACsAIAAiAC4AdgBiAHMAIgAKAE4AZQB3AC0ASQB0AGUAbQAgACQAZgBpAGwAZQBuAGEAbQBlACAALQB0AHkAcABlACAAZgBpAGwAZQAgAC0AZgBvAHIAYwBlACAALQB2AGEAbAB1AGUAIAAkAHYAYgBzAGMAcgBpAHAAdAAgAHwAIABPAHUAdAAtAE4AdQBsAGwACgBjAHMAYwByAGkAcAB0AC4AZQB4AGUAIAAvAG4AbwBsAG8AZwBvACAAJABmAGkAbABlAG4AYQBtAGUACgBSAGUAbQBvAHYAZQAtAEkAdABlAG0AIAAkAGYAaQBsAGUAbgBhAG0AZQAgAHwAIABPAHUAdAAtAE4AdQBsAGwACgA='
|
|
17
|
-
end
|
|
18
|
-
end
|
|
@@ -1,17 +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::Feature' do
|
|
9
|
-
describe 'feature' do
|
|
10
|
-
it 'verify windows feature parsing' do
|
|
11
|
-
resource = MockLoader.new(:windows).load_resource('windows_feature', 'dhcp')
|
|
12
|
-
pkg = { name: 'DHCP', description: 'Dynamic Host Configuration Protocol (DHCP) Server enables you to centrally configure, manage, and provide temporary IP addresses and related information for client computers.', installed: false, type: 'windows-feature' }
|
|
13
|
-
_(resource.info).must_equal pkg
|
|
14
|
-
_(resource.installed?).must_equal false
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,42 +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::WMI' do
|
|
9
|
-
|
|
10
|
-
# Check the following as unit test
|
|
11
|
-
# describe wmi({
|
|
12
|
-
# class: 'win32_service',
|
|
13
|
-
# filter: "name like '%winrm%'"
|
|
14
|
-
# }) do
|
|
15
|
-
# its(['Path','ClassName']) { should eq 'Win32_Service' }
|
|
16
|
-
# its('DisplayName') { should eq 'Windows Remote Management (WS-Management)'}
|
|
17
|
-
# end
|
|
18
|
-
|
|
19
|
-
# windows
|
|
20
|
-
it 'verify wmi parsing on windows' do
|
|
21
|
-
resource = MockLoader.new(:windows).load_resource('wmi', {class: 'win32_service', filter: "name like '%winrm%'" })
|
|
22
|
-
_(resource.send('DisplayName')).must_equal 'Windows Remote Management (WS-Management)'
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# ubuntu 14.04 with upstart
|
|
26
|
-
it 'fail wmi on ubuntu' do
|
|
27
|
-
resource = MockLoader.new(:ubuntu1404).load_resource('wmi', {class: 'win32_service', filter: "name like '%winrm%'" })
|
|
28
|
-
_(resource.send('DisplayName')).must_equal nil
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
# centos 7 with systemd
|
|
32
|
-
it 'fail wmi on centos' do
|
|
33
|
-
resource = MockLoader.new(:centos7).load_resource('wmi', {class: 'win32_service', filter: "name like '%winrm%'" })
|
|
34
|
-
_(resource.send('DisplayName')).must_equal nil
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# unknown OS
|
|
38
|
-
it 'fail wmi on unknown os' do
|
|
39
|
-
resource = MockLoader.new(:undefined).load_resource('wmi', {class: 'win32_service', filter: "name like '%winrm%'" })
|
|
40
|
-
_(resource.send('DisplayName')).must_equal nil
|
|
41
|
-
end
|
|
42
|
-
end
|