inspec 0.30.0 → 0.31.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,202 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# author: Christoph Hartmann
|
3
|
-
# author: Dominik Richter
|
4
|
-
|
5
|
-
require 'helper'
|
6
|
-
require 'inspec/resource'
|
7
|
-
|
8
|
-
def shared_file_permission_tests(method_under_test)
|
9
|
-
it 'returns false if the file does not exist' do
|
10
|
-
resource.stubs(:exist?).returns(false)
|
11
|
-
resource.send(method_under_test, nil, nil).must_equal(false)
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'returns the value of #file_permission_granted?' do
|
15
|
-
resource.stubs(:exist?).returns(true)
|
16
|
-
resource.stubs(:file_permission_granted?).returns('test_result')
|
17
|
-
resource.send(method_under_test, nil, nil).must_equal('test_result')
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe Inspec::Resources::FileResource do
|
22
|
-
let(:resource) { load_resource('file', '/fakepath/fakefile') }
|
23
|
-
|
24
|
-
describe '#readable?' do
|
25
|
-
shared_file_permission_tests(:readable?)
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '#writable?' do
|
29
|
-
shared_file_permission_tests(:writable?)
|
30
|
-
end
|
31
|
-
|
32
|
-
describe '#executable?' do
|
33
|
-
shared_file_permission_tests(:executable?)
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '#basename' do
|
37
|
-
it 'returns the basename' do
|
38
|
-
resource.stubs(:basename).returns('fakefile')
|
39
|
-
resource.basename.must_equal('fakefile')
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe '#to_s' do
|
44
|
-
it 'returns a properly formatted string' do
|
45
|
-
resource.to_s.must_equal('File /fakepath/fakefile')
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe '#file_permission_granted?' do
|
50
|
-
describe 'when not on a unix OS' do
|
51
|
-
it 'raises an exception' do
|
52
|
-
MockLoader.mock_os(resource, :windows)
|
53
|
-
proc { resource.send(:file_permission_granted?, 'flag', nil, nil) }.must_raise(RuntimeError)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe 'when on a unix OS' do
|
58
|
-
before do
|
59
|
-
MockLoader.mock_os(resource, :centos7)
|
60
|
-
end
|
61
|
-
|
62
|
-
describe 'when no user is provided' do
|
63
|
-
it 'checks file permission by mask' do
|
64
|
-
resource.expects(:check_file_permission_by_mask).with('usergroup', 'flag')
|
65
|
-
resource.send(:file_permission_granted?, 'flag', 'usergroup', nil)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
describe 'when a user is provided' do
|
70
|
-
it 'checks file permission by user' do
|
71
|
-
resource.expects(:check_file_permission_by_user).with('user', 'flag')
|
72
|
-
resource.send(:file_permission_granted?, 'flag', nil, 'user')
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe '#check_file_permission_by_mask' do
|
79
|
-
describe 'when no mask is returned' do
|
80
|
-
let(:file) { stub(unix_mode_mask: nil) }
|
81
|
-
|
82
|
-
it 'raises an exception' do
|
83
|
-
file = stub(unix_mode_mask: nil)
|
84
|
-
resource.stubs(:file).returns(file)
|
85
|
-
proc { resource.send(:check_file_permission_by_mask, 'usergroup', 'flag') }.must_raise(RuntimeError)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
describe 'when a mask is returned' do
|
90
|
-
describe 'when the bitwise AND returns a non-zero' do
|
91
|
-
let(:file) { stub(unix_mode_mask: 292, mode: 420) }
|
92
|
-
it 'returns true' do
|
93
|
-
resource.stubs(:file).returns(file)
|
94
|
-
resource.send(:check_file_permission_by_mask, 'usergroup', 'flag').must_equal(true)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
describe 'when the bitwise AND returns zero' do
|
99
|
-
let(:file) { stub(unix_mode_mask: 73, mode: 420) }
|
100
|
-
it 'returns false' do
|
101
|
-
resource.stubs(:file).returns(file)
|
102
|
-
resource.send(:check_file_permission_by_mask, 'usergroup', 'flag').must_equal(false)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
describe 'check_file_permission_by_user' do
|
109
|
-
describe 'when on linux' do
|
110
|
-
before do
|
111
|
-
MockLoader.mock_os(resource, :centos7)
|
112
|
-
end
|
113
|
-
|
114
|
-
it 'executes a properly formatted command' do
|
115
|
-
MockLoader.mock_command(resource,
|
116
|
-
'su -s /bin/sh -c "test -flag /fakepath/fakefile" user',
|
117
|
-
exit_status: 0)
|
118
|
-
resource.send(:check_file_permission_by_user, 'user', 'flag')
|
119
|
-
end
|
120
|
-
|
121
|
-
it 'returns true when the cmd exits 0' do
|
122
|
-
MockLoader.mock_command(resource, 'su -s /bin/sh -c "test -flag /fakepath/fakefile" user', exit_status: 0)
|
123
|
-
resource.send(:check_file_permission_by_user, 'user', 'flag').must_equal(true)
|
124
|
-
end
|
125
|
-
|
126
|
-
it 'returns false when the cmd exits non-zero' do
|
127
|
-
MockLoader.mock_command(resource, 'su -s /bin/sh -c "test -flag /fakepath/fakefile" user', exit_status: 1)
|
128
|
-
resource.send(:check_file_permission_by_user, 'user', 'flag').must_equal(false)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
describe 'when on freebsd' do
|
133
|
-
before do
|
134
|
-
MockLoader.mock_os(resource, :freebsd10)
|
135
|
-
end
|
136
|
-
|
137
|
-
it 'executes a properly formatted command' do
|
138
|
-
MockLoader.mock_command(resource, 'sudo -u user test -flag /fakepath/fakefile', exit_status: 0)
|
139
|
-
resource.send(:check_file_permission_by_user, 'user', 'flag')
|
140
|
-
end
|
141
|
-
|
142
|
-
it 'returns true when the cmd exits 0' do
|
143
|
-
MockLoader.mock_command(resource, 'sudo -u user test -flag /fakepath/fakefile', exit_status: 0)
|
144
|
-
resource.send(:check_file_permission_by_user, 'user', 'flag').must_equal(true)
|
145
|
-
end
|
146
|
-
|
147
|
-
it 'returns false when the cmd exits non-zero' do
|
148
|
-
MockLoader.mock_command(resource, 'sudo -u user test -flag /fakepath/fakefile', exit_status: 1)
|
149
|
-
resource.send(:check_file_permission_by_user, 'user', 'flag').must_equal(false)
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
describe 'when on hpux' do
|
154
|
-
before do
|
155
|
-
MockLoader.mock_os(resource, :hpux)
|
156
|
-
end
|
157
|
-
|
158
|
-
it 'executes a properly formatted command' do
|
159
|
-
MockLoader.mock_command(resource, "su user -c \"test -flag /fakepath/fakefile\"", exit_status: 0)
|
160
|
-
resource.send(:check_file_permission_by_user, 'user', 'flag')
|
161
|
-
end
|
162
|
-
|
163
|
-
it 'returns true when the cmd exits 0' do
|
164
|
-
MockLoader.mock_command(resource, "su user -c \"test -flag /fakepath/fakefile\"", exit_status: 0)
|
165
|
-
resource.send(:check_file_permission_by_user, 'user', 'flag').must_equal(true)
|
166
|
-
end
|
167
|
-
|
168
|
-
it 'returns false when the cmd exits non-zero' do
|
169
|
-
MockLoader.mock_command(resource, "su user -c \"test -flag /fakepath/fakefile\"", exit_status: 1)
|
170
|
-
resource.send(:check_file_permission_by_user, 'user', 'flag').must_equal(false)
|
171
|
-
end
|
172
|
-
end
|
173
|
-
|
174
|
-
describe 'when not on linux or freebsd' do
|
175
|
-
before do
|
176
|
-
MockLoader.mock_os(resource, :undefined)
|
177
|
-
end
|
178
|
-
|
179
|
-
it 'returns an error string' do
|
180
|
-
resource.send(:check_file_permission_by_user, 'user', 'flag').must_equal('The `file` resource does not support `by_user` on your OS.')
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
describe '#usergroup_for' do
|
186
|
-
it 'returns "other" if "others" is provided' do
|
187
|
-
resource.send(:usergroup_for, 'others', nil).must_equal('other')
|
188
|
-
end
|
189
|
-
|
190
|
-
it 'returns "all" if no usergroup or user is specified' do
|
191
|
-
resource.send(:usergroup_for, nil, nil).must_equal('all')
|
192
|
-
end
|
193
|
-
|
194
|
-
it 'returns nil if the usergroup is nil and a user is specified' do
|
195
|
-
resource.send(:usergroup_for, nil, 'user').must_equal(nil)
|
196
|
-
end
|
197
|
-
|
198
|
-
it 'returns the passed-in usergroup if usergroup is not nil and user is nil' do
|
199
|
-
resource.send(:usergroup_for, 'mygroup', nil).must_equal('mygroup')
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
@@ -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::Gem' do
|
9
|
-
it 'verify gem package detail parsing' do
|
10
|
-
resource = load_resource('gem', 'rubocop')
|
11
|
-
pkg = {
|
12
|
-
name: 'rubocop',
|
13
|
-
version: '0.33.0',
|
14
|
-
type: 'gem',
|
15
|
-
installed: true,
|
16
|
-
}
|
17
|
-
_(resource.installed?).must_equal true
|
18
|
-
_(resource.info).must_equal pkg
|
19
|
-
end
|
20
|
-
end
|
@@ -1,96 +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::Group' do
|
9
|
-
|
10
|
-
# ubuntu 14.04
|
11
|
-
it 'verify group on ubuntu' do
|
12
|
-
resource = MockLoader.new(:ubuntu1404).load_resource('group', 'root')
|
13
|
-
_(resource.exists?).must_equal true
|
14
|
-
_(resource.gid).must_equal 0
|
15
|
-
_(resource.has_gid?(0)).must_equal true
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'verify group on ubuntu with UPPER CASE' do
|
19
|
-
resource = MockLoader.new(:ubuntu1404).load_resource('group', 'ROOT')
|
20
|
-
_(resource.exists?).must_equal true
|
21
|
-
_(resource.gid).must_equal 0
|
22
|
-
_(resource.has_gid?(0)).must_equal true
|
23
|
-
end
|
24
|
-
|
25
|
-
# ubuntu with non-existent group
|
26
|
-
it 'verify group on ubuntu' do
|
27
|
-
resource = MockLoader.new(:ubuntu1404).load_resource('group', 'nogroup')
|
28
|
-
_(resource.exists?).must_equal false
|
29
|
-
_(resource.gid).must_equal nil
|
30
|
-
_(resource.has_gid?(0)).must_equal false
|
31
|
-
end
|
32
|
-
|
33
|
-
# mac
|
34
|
-
it 'verify group on mac' do
|
35
|
-
resource = MockLoader.new(:osx104).load_resource('group', 'root')
|
36
|
-
_(resource.exists?).must_equal true
|
37
|
-
_(resource.gid).must_equal 0
|
38
|
-
_(resource.has_gid?(0)).must_equal true
|
39
|
-
end
|
40
|
-
|
41
|
-
# freebsd
|
42
|
-
it 'verify group on freebsd' do
|
43
|
-
resource = MockLoader.new(:freebsd10).load_resource('group', 'root')
|
44
|
-
_(resource.exists?).must_equal true
|
45
|
-
_(resource.gid).must_equal 0
|
46
|
-
_(resource.has_gid?(0)).must_equal true
|
47
|
-
end
|
48
|
-
|
49
|
-
# windows with local group
|
50
|
-
it 'verify group on windows' do
|
51
|
-
resource = MockLoader.new(:windows).load_resource('group', 'Administrators')
|
52
|
-
_(resource.exists?).must_equal true
|
53
|
-
_(resource.gid).must_equal nil
|
54
|
-
_(resource.has_gid?(0)).must_equal false
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'verify group on windows' do
|
58
|
-
resource = MockLoader.new(:windows).load_resource('group', 'Administrators', 'WIN-K0AKLED332V')
|
59
|
-
_(resource.exists?).must_equal true
|
60
|
-
_(resource.gid).must_equal nil
|
61
|
-
_(resource.has_gid?(0)).must_equal false
|
62
|
-
end
|
63
|
-
|
64
|
-
# windows with domain group
|
65
|
-
it 'verify domain group on windows' do
|
66
|
-
resource = MockLoader.new(:windows).load_resource('group', 'Domain Admins', 'EXAMPLE')
|
67
|
-
_(resource.exists?).must_equal true
|
68
|
-
_(resource.gid).must_equal nil
|
69
|
-
_(resource.has_gid?(0)).must_equal false
|
70
|
-
end
|
71
|
-
|
72
|
-
# windows with domain group
|
73
|
-
it 'verify domain group on windows wiht lower case' do
|
74
|
-
resource = MockLoader.new(:windows).load_resource('group', 'domain admins', 'example')
|
75
|
-
_(resource.exists?).must_equal true
|
76
|
-
_(resource.gid).must_equal nil
|
77
|
-
_(resource.has_gid?(0)).must_equal false
|
78
|
-
end
|
79
|
-
|
80
|
-
# windows non-existent group
|
81
|
-
it 'verify non-existing group on windows' do
|
82
|
-
resource = MockLoader.new(:windows).load_resource('group', 'dhcp')
|
83
|
-
_(resource.exists?).must_equal false
|
84
|
-
_(resource.gid).must_equal nil
|
85
|
-
_(resource.has_gid?(0)).must_equal false
|
86
|
-
end
|
87
|
-
|
88
|
-
# undefined
|
89
|
-
it 'verify package handling on unsupported os' do
|
90
|
-
resource = MockLoader.new(:undefined).load_resource('group', 'root')
|
91
|
-
_(resource.exists?).must_equal false
|
92
|
-
_(resource.gid).must_equal nil
|
93
|
-
_(resource.has_gid?(0)).must_equal false
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# author: Thomas Cate
|
3
|
-
|
4
|
-
require 'helper'
|
5
|
-
require 'inspec/resource'
|
6
|
-
|
7
|
-
describe 'Inspec::Resources::GrubConfig' do
|
8
|
-
|
9
|
-
it 'verify kernel include' do
|
10
|
-
resource = MockLoader.new(:centos6).load_resource('grub_conf')
|
11
|
-
_(resource.kernel).must_be_kind_of Array
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'verify initrd include' do
|
15
|
-
resource = MockLoader.new(:centos6).load_resource('grub_conf')
|
16
|
-
_(resource.initrd).must_be_kind_of String
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'verify default' do
|
20
|
-
resource = MockLoader.new(:centos6).load_resource('grub_conf')
|
21
|
-
_(resource.default).must_equal '0'
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'verify timeout' do
|
25
|
-
resource = MockLoader.new(:centos6).load_resource('grub_conf')
|
26
|
-
_(resource.timeout).must_equal '5'
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
@@ -1,38 +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::Host' do
|
9
|
-
|
10
|
-
it 'check host on ubuntu' do
|
11
|
-
resource = MockLoader.new(:ubuntu1404).load_resource('host', 'example.com')
|
12
|
-
_(resource.resolvable?).must_equal true
|
13
|
-
_(resource.reachable?).must_equal true
|
14
|
-
_(resource.ipaddress).must_equal ['2606:2800:220:1:248:1893:25c8:1946']
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'check host on centos 7' do
|
18
|
-
resource = MockLoader.new(:centos7).load_resource('host', 'example.com')
|
19
|
-
_(resource.resolvable?).must_equal true
|
20
|
-
_(resource.reachable?).must_equal true
|
21
|
-
_(resource.ipaddress).must_equal ['2606:2800:220:1:248:1893:25c8:1946']
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'check host on windows' do
|
25
|
-
resource = MockLoader.new(:windows).load_resource('host', 'microsoft.com')
|
26
|
-
_(resource.resolvable?).must_equal true
|
27
|
-
_(resource.reachable?).must_equal false
|
28
|
-
_(resource.ipaddress).must_equal ['134.170.185.46', '134.170.188.221']
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'check host on unsupported os' do
|
32
|
-
resource = MockLoader.new(:undefined).load_resource('host', 'example.com')
|
33
|
-
_(resource.resolvable?).must_equal false
|
34
|
-
_(resource.reachable?).must_equal false
|
35
|
-
_(resource.ipaddress).must_equal nil
|
36
|
-
end
|
37
|
-
|
38
|
-
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::InetdConf' do
|
9
|
-
it 'verify limits.conf config parsing' do
|
10
|
-
resource = load_resource('inetd_conf')
|
11
|
-
_(resource.send('shell')).must_equal nil
|
12
|
-
_(resource.send('login')).must_equal nil
|
13
|
-
_(resource.send('ftp')).must_equal %w{stream tcp nowait root /usr/sbin/in.ftpd in.ftpd}
|
14
|
-
end
|
15
|
-
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::Ini' do
|
9
|
-
|
10
|
-
it 'check ini parsing on ubuntu' do
|
11
|
-
resource = MockLoader.new(:ubuntu1404).load_resource('ini', 'rootwrap.conf')
|
12
|
-
result = {"DEFAULT"=>{"filters_path"=>"/etc/cinder/rootwrap.d,/usr/share/cinder/rootwrap", "exec_dirs"=>"/sbin,/usr/sbin,/bin,/usr/bin,/usr/local/bin,/usr/local/sbin"}}
|
13
|
-
_(resource.params).must_equal result
|
14
|
-
_(resource.value(['DEFAULT','exec_dirs'])).must_equal '/sbin,/usr/sbin,/bin,/usr/bin,/usr/local/bin,/usr/local/sbin'
|
15
|
-
end
|
16
|
-
end
|
@@ -1,54 +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::Interface' do
|
9
|
-
|
10
|
-
# ubuntu 14.04
|
11
|
-
it 'verify interface on ubuntu' do
|
12
|
-
resource = MockLoader.new(:ubuntu1404).load_resource('interface', 'eth0')
|
13
|
-
_(resource.exists?).must_equal true
|
14
|
-
_(resource.up?).must_equal true
|
15
|
-
_(resource.speed).must_equal 10000
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'verify invalid interface on ubuntu' do
|
19
|
-
resource = MockLoader.new(:ubuntu1404).load_resource('interface', 'eth1')
|
20
|
-
_(resource.exists?).must_equal false
|
21
|
-
_(resource.up?).must_equal false
|
22
|
-
_(resource.speed).must_equal nil
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'verify interface on windows' do
|
26
|
-
resource = MockLoader.new(:windows).load_resource('interface', 'ethernet0')
|
27
|
-
_(resource.exists?).must_equal true
|
28
|
-
_(resource.up?).must_equal false
|
29
|
-
_(resource.speed).must_equal 0
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'verify interface on windows' do
|
33
|
-
resource = MockLoader.new(:windows).load_resource('interface', 'vEthernet (Intel(R) PRO 1000 MT Network Connection - Virtual Switch)')
|
34
|
-
_(resource.exists?).must_equal true
|
35
|
-
_(resource.up?).must_equal true
|
36
|
-
_(resource.speed).must_equal 10000000
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'verify invalid interface on windows' do
|
40
|
-
resource = MockLoader.new(:windows).load_resource('interface', 'eth1')
|
41
|
-
_(resource.exists?).must_equal false
|
42
|
-
_(resource.up?).must_equal false
|
43
|
-
_(resource.speed).must_equal nil
|
44
|
-
end
|
45
|
-
|
46
|
-
# undefined
|
47
|
-
it 'verify interface on unsupported os' do
|
48
|
-
resource = MockLoader.new(:undefined).load_resource('interface', 'eth0')
|
49
|
-
_(resource.exists?).must_equal false
|
50
|
-
_(resource.up?).must_equal false
|
51
|
-
_(resource.speed).must_equal nil
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
@@ -1,35 +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::Iptables' do
|
9
|
-
|
10
|
-
# ubuntu 14.04
|
11
|
-
it 'verify iptables on ubuntu' do
|
12
|
-
resource = MockLoader.new(:ubuntu1404).load_resource('iptables')
|
13
|
-
_(resource.has_rule?('-P OUTPUT ACCEPT')).must_equal true
|
14
|
-
_(resource.has_rule?('-P OUTPUT DROP')).must_equal false
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'verify iptables with comments on ubuntu' do
|
18
|
-
resource = MockLoader.new(:ubuntu1404).load_resource('iptables')
|
19
|
-
_(resource.has_rule?('-A INPUT -i eth0 -p tcp -m tcp --dport 80 -m state --state NEW -m comment --comment "http like its 1990" -j ACCEPT')).must_equal true
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'verify iptables on windows' do
|
23
|
-
resource = MockLoader.new(:windows).load_resource('iptables')
|
24
|
-
_(resource.has_rule?('-P OUTPUT ACCEPT')).must_equal false
|
25
|
-
_(resource.has_rule?('-P OUTPUT DROP')).must_equal false
|
26
|
-
end
|
27
|
-
|
28
|
-
# undefined
|
29
|
-
it 'verify iptables on unsupported os' do
|
30
|
-
resource = MockLoader.new(:undefined).load_resource('iptables')
|
31
|
-
_(resource.has_rule?('-P OUTPUT ACCEPT')).must_equal false
|
32
|
-
_(resource.has_rule?('-P OUTPUT DROP')).must_equal false
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
@@ -1,36 +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::JSON' do
|
9
|
-
describe 'when loading a valid json' do
|
10
|
-
let (:resource) { load_resource('json', 'policyfile.lock.json') }
|
11
|
-
|
12
|
-
it 'gets params as a hashmap' do
|
13
|
-
_(resource.params).must_be_kind_of Hash
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'retrieves nil if a param is missing' do
|
17
|
-
_(resource.params['missing']).must_be_nil
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'retrieves params by name' do
|
21
|
-
_(resource.send('name')).must_equal 'demo'
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'retrieves an array by name' do
|
25
|
-
_(resource.send('run_list')).must_equal %w{a b}
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'doesnt resolve dot-notation names' do
|
29
|
-
_(resource.send('x.y.z')).must_be_nil
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'doesnt resolve symbol-notation names' do
|
33
|
-
_(resource.send(:'x.y.z')).must_be_nil
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,23 +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::KernelModule' do
|
9
|
-
it 'verify kernel_module parsing' do
|
10
|
-
resource = load_resource('kernel_module', 'bridge')
|
11
|
-
_(resource.loaded?).must_equal true
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'verify kernel_module parsing' do
|
15
|
-
resource = load_resource('kernel_module', 'bridges')
|
16
|
-
_(resource.loaded?).must_equal false
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'verify kernel_module parsing' do
|
20
|
-
resource = load_resource('kernel_module', 'dhcp')
|
21
|
-
_(resource.loaded?).must_equal false
|
22
|
-
end
|
23
|
-
end
|
@@ -1,13 +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::KernelParameter' do
|
9
|
-
it 'verify kernel_parameter parsing' do
|
10
|
-
resource = load_resource('kernel_parameter', 'net.ipv4.conf.all.forwarding')
|
11
|
-
_(resource.value).must_equal 1
|
12
|
-
end
|
13
|
-
end
|
@@ -1,14 +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::LimitsConf' do
|
9
|
-
it 'verify limits.conf config parsing' do
|
10
|
-
resource = load_resource('limits_conf')
|
11
|
-
_(resource.send('*')).must_equal [['soft', 'core', '0'], ['hard', 'rss', '10000']]
|
12
|
-
_(resource.send('ftp')).must_equal [["hard", "nproc", "0"]]
|
13
|
-
end
|
14
|
-
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::LoginDef' do
|
9
|
-
it 'verify login.def config parsing' do
|
10
|
-
resource = load_resource('login_defs')
|
11
|
-
_(resource.UMASK).must_equal '022'
|
12
|
-
_(resource.PASS_MIN_DAYS).must_equal '0'
|
13
|
-
_(resource.PASS_WARN_AGE).must_equal '7'
|
14
|
-
_(resource.USERDEL_CMD).must_equal nil
|
15
|
-
end
|
16
|
-
end
|
@@ -1,26 +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::FileResource do
|
9
|
-
let(:root_resource) { load_resource('mount', '/') }
|
10
|
-
|
11
|
-
it 'parses the mount data properly' do
|
12
|
-
root_resource.send(:device).must_equal('/dev/xvda1')
|
13
|
-
root_resource.send(:type).must_equal('ext4')
|
14
|
-
root_resource.send(:options).must_equal(['rw','discard'])
|
15
|
-
root_resource.send(:count).must_equal(1)
|
16
|
-
end
|
17
|
-
|
18
|
-
let(:iso_resource) { load_resource('mount', '/mnt/iso-disk') }
|
19
|
-
|
20
|
-
it 'parses the mount data properly' do
|
21
|
-
iso_resource.send(:device).must_equal('/root/alpine-3.3.0-x86_64_2.iso')
|
22
|
-
iso_resource.send(:type).must_equal('iso9660')
|
23
|
-
iso_resource.send(:options).must_equal(['ro'])
|
24
|
-
iso_resource.send(:count).must_equal(2)
|
25
|
-
end
|
26
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# author: Christoph Hartmann
|
3
|
-
# author: Dominik Richter
|
4
|
-
|
5
|
-
require 'helper'
|
6
|
-
|
7
|
-
describe 'Inspec::Resources::MysqlConf' do
|
8
|
-
it 'verify mysql.conf config parsing' do
|
9
|
-
resource = load_resource('mysql_conf', '/etc/mysql/my.cnf')
|
10
|
-
_(resource.client['port']).must_equal '3306'
|
11
|
-
_(resource.mysqld['user']).must_equal 'mysql'
|
12
|
-
_(resource.mysqld['key_buffer_size']).must_equal '16M'
|
13
|
-
end
|
14
|
-
end
|