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,60 +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::XinetdConf' do
|
9
|
-
let(:resource) { load_resource('xinetd_conf') }
|
10
|
-
it 'reads default params' do
|
11
|
-
d = resource.params['defaults']
|
12
|
-
_(d).must_be_kind_of SimpleConfig
|
13
|
-
_(d.params['instances']).must_equal '50'
|
14
|
-
_(d.params['log_type']).must_equal 'SYSLOG daemon info'
|
15
|
-
_(d.params.length).must_equal 2
|
16
|
-
end
|
17
|
-
|
18
|
-
describe 'with services from child configs' do
|
19
|
-
it 'has one service name' do
|
20
|
-
_(resource.services.uniq).must_equal %w{chargen}
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'has multiple service definitions' do
|
24
|
-
_(resource.ids).must_equal %w{chargen-stream chargen-dgram}
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'can filter by name' do
|
28
|
-
_(resource.services('not here').services).must_be_empty
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'can chain filters' do
|
32
|
-
one = resource.services('chargen').socket_types('dgram')
|
33
|
-
_(one.services.length).must_equal 1
|
34
|
-
_(one.ids).must_equal %w{chargen-dgram}
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'checks if all are disabled on one disabled service' do
|
38
|
-
one = resource.ids('chargen-stream')
|
39
|
-
_(one.disabled?).must_equal true
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'checks if all are disabled on multiple mixed' do
|
43
|
-
_(resource.disabled?).must_equal false
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'checks if all are enabled on one enabled service' do
|
47
|
-
one = resource.ids(/dgram$/)
|
48
|
-
_(one.enabled?).must_equal true
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'checks if all are enabled on one enabled service' do
|
52
|
-
one = resource.ids(/stream$/)
|
53
|
-
_(one.enabled?).must_equal false
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'checks if all are enabled on multiple mixed' do
|
57
|
-
_(resource.enabled?).must_equal false
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
require 'inspec/resource'
|
5
|
-
|
6
|
-
describe 'Inspec::Resources::YAML' do
|
7
|
-
describe 'when loading a valid yaml' do
|
8
|
-
let (:resource) { load_resource('yaml', 'kitchen.yml') }
|
9
|
-
|
10
|
-
it 'gets params as a hashmap' do
|
11
|
-
_(resource.params).must_be_kind_of Hash
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'retrieves nil if a param is missing' do
|
15
|
-
_(resource.params['missing']).must_be_nil
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'retrieves params by name' do
|
19
|
-
_(resource.send('name')).must_equal 'vagrant'
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'retrieves an array by name' do
|
23
|
-
_(resource.send('platforms')).must_equal %w{linux mac}
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'doesnt resolve dot-notation names' do
|
27
|
-
_(resource.send('driver.customize.memory')).must_be_nil
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'doesnt resolve symbol-notation names' do
|
31
|
-
_(resource.send(:'driver.customize.memory')).must_be_nil
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,68 +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::YumRepo' do
|
9
|
-
it 'get repository details' do
|
10
|
-
resource = MockLoader.new(:centos7).load_resource('yum')
|
11
|
-
_(resource.repositories).must_equal [{
|
12
|
-
'id'=>'base/7/x86_64',
|
13
|
-
'name'=>'CentOS-7 - Base',
|
14
|
-
'status'=>'enabled',
|
15
|
-
'revision'=>'1427842153',
|
16
|
-
'updated'=>'Tue Mar 31 22:50:46 2015',
|
17
|
-
'pkgs'=>'8652',
|
18
|
-
'size'=>'6.3 G',
|
19
|
-
'mirrors'=>'http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock',
|
20
|
-
'baseurl'=>'http://ftp.hosteurope.de/mirror/centos.org/7.1.1503/os/x86_64/ (9 more)',
|
21
|
-
'expire'=>'21600 second(s) (last: Sun Sep 6 10:20:46 2015)',
|
22
|
-
'filename'=>'/etc/yum.repos.d/CentOS-Base.repo',
|
23
|
-
}, {
|
24
|
-
'id'=>'base-debuginfo/x86_64',
|
25
|
-
'name'=>'CentOS-7 - Debuginfo',
|
26
|
-
'status'=>'disabled',
|
27
|
-
'baseurl'=>'http://debuginfo.centos.org/7/x86_64/',
|
28
|
-
'expire'=>'21600 second(s) (last: Unknown)',
|
29
|
-
'filename'=>'/etc/yum.repos.d/CentOS-Debuginfo.repo',
|
30
|
-
}, {
|
31
|
-
'id'=>'extras/7/x86_64',
|
32
|
-
'name'=>'CentOS-7 - Extras',
|
33
|
-
'status'=>'enabled',
|
34
|
-
'revision'=>'1441314199',
|
35
|
-
'updated'=>'Thu Sep 3 21:03:33 2015',
|
36
|
-
'pkgs'=>'181',
|
37
|
-
'size'=>'742 M',
|
38
|
-
'mirrors'=>'http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=extras&infra=stock',
|
39
|
-
'baseurl'=>'http://mirror.informatik.hs-fulda.de/centos7.1.1503/extras/x86_64/ (9 more)',
|
40
|
-
'expire'=>'21600 second(s) (last: Sun Sep 6 10:20:48 2015)',
|
41
|
-
'filename'=>'/etc/yum.repos.d/CentOS-Base.repo',
|
42
|
-
}]
|
43
|
-
_(resource.repos.length).must_equal 3
|
44
|
-
# get repository details
|
45
|
-
_(resource.repos).must_equal %w{base/7/x86_64 base-debuginfo/x86_64 extras/7/x86_64}
|
46
|
-
# test its syntax repo
|
47
|
-
_(resource.extras.exist?).must_equal true
|
48
|
-
_(resource.extras.enabled?).must_equal true
|
49
|
-
# test enabled extra repo
|
50
|
-
extras = resource.repo('extras/7/x86_64')
|
51
|
-
_(extras.exist?).must_equal true
|
52
|
-
_(extras.enabled?).must_equal true
|
53
|
-
# test enabled extra repo with short name
|
54
|
-
extras = resource.repo('extras')
|
55
|
-
_(extras.exist?).must_equal true
|
56
|
-
_(extras.enabled?).must_equal true
|
57
|
-
# test disabled extra-source repo
|
58
|
-
extras = resource.repo('base-debuginfo/x86_64')
|
59
|
-
_(extras.exist?).must_equal true
|
60
|
-
_(extras.enabled?).must_equal false
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'test enabled extra repo (serverspec backwards comptability)' do
|
64
|
-
serverspec = load_resource('yumrepo', 'extras')
|
65
|
-
_(serverspec.exists?).must_equal true
|
66
|
-
_(serverspec.enabled?).must_equal true
|
67
|
-
end
|
68
|
-
end
|
@@ -1,78 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# author: Steven Danna <steve@chef.io>
|
3
|
-
#
|
4
|
-
require 'helper'
|
5
|
-
require 'rbconfig'
|
6
|
-
require 'mocha/test_unit'
|
7
|
-
require 'inspec/shell_detector'
|
8
|
-
|
9
|
-
module ShellDetectorTestHelpers
|
10
|
-
def no_proc
|
11
|
-
Dir.expects(:exist?).with('/proc').returns(false)
|
12
|
-
end
|
13
|
-
|
14
|
-
def with_proc(shell)
|
15
|
-
Dir.expects(:exist?).with('/proc').returns(true)
|
16
|
-
File.expects(:readlink).with("/proc/#{ppid}/exe").returns(shell)
|
17
|
-
end
|
18
|
-
|
19
|
-
def with_ps(output)
|
20
|
-
subject.expects(:'`').with("ps -cp #{ppid} -o command=").returns(output)
|
21
|
-
end
|
22
|
-
|
23
|
-
def with_env(shell)
|
24
|
-
ENV.expects(:[]).with('SHELL').returns(shell)
|
25
|
-
end
|
26
|
-
|
27
|
-
def with_pwuid(shell)
|
28
|
-
Process.expects(:uid).returns(9999)
|
29
|
-
@mock_user = Minitest::Mock.new
|
30
|
-
@mock_user.expect :shell, shell
|
31
|
-
Etc.expects(:getpwuid).with(9999).returns(@mock_user)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe Inspec::ShellDetector do
|
36
|
-
include ShellDetectorTestHelpers
|
37
|
-
|
38
|
-
let(:subject) { Inspec::ShellDetector.new }
|
39
|
-
let(:ppid) { Process.ppid }
|
40
|
-
|
41
|
-
# Small hack to ensure we can test on windows
|
42
|
-
it "returns nil immediately if running on windows" do
|
43
|
-
RbConfig::CONFIG.expects(:[]).with('host_os').returns('mswin')
|
44
|
-
subject.shell!.must_equal(nil)
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "not on windows" do
|
48
|
-
before do
|
49
|
-
RbConfig::CONFIG.expects(:[]).with('host_os').returns('beos')
|
50
|
-
end
|
51
|
-
|
52
|
-
it "detects the shell via /proc if it exists" do
|
53
|
-
with_proc("/usr/bin/fish")
|
54
|
-
subject.shell!.must_equal("fish")
|
55
|
-
end
|
56
|
-
|
57
|
-
it "detects via `ps` if /proc doesn't exist" do
|
58
|
-
no_proc; with_ps("/usr/bin/ksh")
|
59
|
-
subject.shell!.must_equal("ksh")
|
60
|
-
end
|
61
|
-
|
62
|
-
it "detects via ENV if parent process methods failed" do
|
63
|
-
no_proc; with_ps(""); with_env("fish")
|
64
|
-
subject.shell!.must_equal("fish")
|
65
|
-
end
|
66
|
-
|
67
|
-
it "detects via getpwuid if all else fails" do
|
68
|
-
no_proc; with_ps(""); with_env(""); with_pwuid("/usr/bin/fish")
|
69
|
-
subject.shell!.must_equal("fish")
|
70
|
-
@mock_user.verify
|
71
|
-
end
|
72
|
-
|
73
|
-
it "returns nil if the shell isn't in the whitelist" do
|
74
|
-
no_proc; with_ps(""); with_env("badshell"); with_pwuid("/usr/bin/badshell")
|
75
|
-
subject.shell!.must_equal(nil)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# author: Dominik Richter
|
3
|
-
# author: Christoph Hartmann
|
4
|
-
|
5
|
-
require 'helper'
|
6
|
-
|
7
|
-
describe Inspec::SourceReader do
|
8
|
-
let(:reg) { Inspec::SourceReader }
|
9
|
-
|
10
|
-
it 'resolves nil-targets to nil' do
|
11
|
-
_(reg.resolve(nil)).must_be_nil
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'only supports Fetchers' do
|
15
|
-
proc { reg.resolve("not supported") }.must_raise StandardError
|
16
|
-
end
|
17
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# author: Dominik Richter
|
3
|
-
# author: Christoph Hartmann
|
4
|
-
|
5
|
-
require 'helper'
|
6
|
-
|
7
|
-
describe SourceReaders::Flat do
|
8
|
-
let(:reader) { SourceReaders::Flat }
|
9
|
-
|
10
|
-
it 'registers with the source readers registry' do
|
11
|
-
reg = Inspec::SourceReader.registry
|
12
|
-
_(reg['flat']).must_equal reader
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'with a flat file' do
|
16
|
-
let(:target) { Inspec::Fetcher.resolve(__FILE__) }
|
17
|
-
let(:res) { Inspec::SourceReader.resolve(target.relative_target) }
|
18
|
-
|
19
|
-
it 'resolves the target' do
|
20
|
-
_(res).must_be_kind_of reader
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'has no metadata' do
|
24
|
-
_(res.metadata.params).must_equal({})
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'retrieves all files' do
|
28
|
-
_(res.tests.keys).must_equal [File.basename(__FILE__)]
|
29
|
-
_(res.tests.values[0]).must_equal File.read(__FILE__)
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'has no libraries' do
|
33
|
-
_(res.libraries).must_be_empty
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe 'with a flat folder' do
|
38
|
-
let(:target) { Inspec::Fetcher.resolve(File.dirname(__FILE__)) }
|
39
|
-
let(:res) { Inspec::SourceReader.resolve(target.relative_target) }
|
40
|
-
|
41
|
-
it 'resolves the target' do
|
42
|
-
_(res).must_be_kind_of reader
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'has no metadata' do
|
46
|
-
_(res.metadata.params).must_equal({})
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'retrieves all files' do
|
50
|
-
dir = File.dirname(__FILE__)
|
51
|
-
full_files = Dir[File.join(dir, '**')]
|
52
|
-
files = full_files.map { |x| x.sub(dir+'/', '') }
|
53
|
-
_(res.tests.keys).must_equal files
|
54
|
-
_(res.tests.values[0]).must_equal File.read(full_files[0])
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'has no libraries' do
|
58
|
-
_(res.libraries).must_be_empty
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# author: Dominik Richter
|
3
|
-
# author: Christoph Hartmann
|
4
|
-
|
5
|
-
require 'helper'
|
6
|
-
|
7
|
-
describe SourceReaders::InspecReader do
|
8
|
-
let(:reader) { SourceReaders::InspecReader }
|
9
|
-
|
10
|
-
it 'registers with the source readers registry' do
|
11
|
-
reg = Inspec::SourceReader.registry
|
12
|
-
_(reg['inspec']).must_equal reader
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'with a valid profile' do
|
16
|
-
let(:mock_file) { mock_file = MockLoader.profile_tgz('complete-profile') }
|
17
|
-
let(:target) { Inspec::Fetcher.resolve(mock_file) }
|
18
|
-
let(:res) { Inspec::SourceReader.resolve(target) }
|
19
|
-
|
20
|
-
it 'resolves the target to inspec' do
|
21
|
-
_(res).must_be_kind_of reader
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'retrieves metadata' do
|
25
|
-
_(res.metadata.params[:name]).must_equal 'complete'
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'retrieves all files' do
|
29
|
-
_(res.tests.keys).must_equal %w{controls/filesystem_spec.rb}
|
30
|
-
_(res.tests.values[0]).must_match /^control 'test01' do$/
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'retrieves all libraries' do
|
34
|
-
_(res.libraries.keys).must_equal %w{libraries/testlib.rb}
|
35
|
-
_(res.libraries.values[0]).must_match /^# Library resource$/
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
# author: Stephan Renatus
|
2
|
-
|
3
|
-
require 'helper'
|
4
|
-
|
5
|
-
describe FilterArray do
|
6
|
-
let (:data) {[
|
7
|
-
{ foo: 3, bar: true, baz: 'yay' },
|
8
|
-
{ foo: 2, bar: false, baz: 'noo' },
|
9
|
-
{ foo: 2, bar: false, baz: 'whatever' },
|
10
|
-
]}
|
11
|
-
|
12
|
-
let (:instance) do
|
13
|
-
FilterArray.new data
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#content' do
|
17
|
-
it 'returns the current set' do
|
18
|
-
instance.content.must_equal data
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'can also be referred to as #rules' do
|
22
|
-
instance.rules.must_equal instance.content
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe '#field' do
|
27
|
-
it 'retrieves (unique) values' do
|
28
|
-
instance.field('foo').must_equal [3, 2]
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'filters the current set' do
|
32
|
-
instance.field('foo', 2).content.must_equal [
|
33
|
-
{ foo: 2, bar: false, baz: 'noo' },
|
34
|
-
{ foo: 2, bar: false, baz: 'whatever' },
|
35
|
-
]
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'can be chained' do
|
39
|
-
instance.field('foo', 2).field('baz', 'noo').content.must_equal [
|
40
|
-
{ foo: 2, bar: false, baz: 'noo' },
|
41
|
-
]
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'can be abbreviated for retrieval' do
|
45
|
-
instance.foo.must_equal [3, 2]
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'can be abbreviated for querying' do
|
49
|
-
instance.foo(2).content.must_equal [
|
50
|
-
{ foo: 2, bar: false, baz: 'noo' },
|
51
|
-
{ foo: 2, bar: false, baz: 'whatever' },
|
52
|
-
]
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'returns `[nil]` when queried for a non-existing key' do
|
56
|
-
instance.what.must_equal [nil]
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,177 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# author: Dominik Richter
|
3
|
-
# author: Stephan Renatus
|
4
|
-
# author: Christoph Hartmann
|
5
|
-
|
6
|
-
require 'helper'
|
7
|
-
|
8
|
-
describe FilterTable do
|
9
|
-
let (:data) {[
|
10
|
-
{ foo: 3, bar: true, baz: 'yay', num: nil, snum: "0" },
|
11
|
-
{ foo: 2, bar: false, baz: 'noo', num: 1, snum: nil },
|
12
|
-
{ foo: 2, bar: false, baz: 'whatever', num: 2, snum: "1.00" },
|
13
|
-
]}
|
14
|
-
|
15
|
-
let (:resource) {
|
16
|
-
Class.new do
|
17
|
-
attr_reader :data
|
18
|
-
def initialize(data)
|
19
|
-
@data = data
|
20
|
-
end
|
21
|
-
end
|
22
|
-
}
|
23
|
-
|
24
|
-
let (:factory) { FilterTable.create }
|
25
|
-
let (:instance) { resource.new(data) }
|
26
|
-
|
27
|
-
it 'has a create utility which creates a filter factory' do
|
28
|
-
factory.must_be_kind_of FilterTable::Factory
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'retrieves the resource from all entries' do
|
32
|
-
factory.add_accessor(:where)
|
33
|
-
.add(:baz?) { |x| x.resource }
|
34
|
-
.connect(resource, :data)
|
35
|
-
instance.baz?.must_equal instance
|
36
|
-
end
|
37
|
-
|
38
|
-
describe 'when calling add_accessor' do
|
39
|
-
it 'is chainable' do
|
40
|
-
factory.add_accessor(:sth).must_equal factory
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'wont add nil' do
|
44
|
-
proc { factory.add_accessor(nil) }.must_throw RuntimeError
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'can expose the where method' do
|
48
|
-
factory.add_accessor(:where).connect(resource, :data)
|
49
|
-
_(instance.respond_to?(:where)).must_equal true
|
50
|
-
instance.where({ baz: 'yay' }).params.must_equal [data[0]]
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'will delegate even non-existing methods' do
|
54
|
-
factory.add_accessor(:not_here).connect(resource, :data)
|
55
|
-
_(instance.respond_to?(:not_here)).must_equal true
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe 'when calling add' do
|
60
|
-
it 'is chainable' do
|
61
|
-
factory.add(:sth).must_equal factory
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'wont add nil' do
|
65
|
-
proc { factory.add(nil) }.must_throw RuntimeError
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'can expose a data column' do
|
69
|
-
factory.add(:baz).connect(resource, :data)
|
70
|
-
instance.baz(123).must_be_kind_of(FilterTable::Table)
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'retrieves all entries' do
|
74
|
-
factory.add(:foo).connect(resource, :data)
|
75
|
-
instance.foo.must_equal([3, 2, 2])
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'retrieves entries with simple style' do
|
79
|
-
factory.add(:foo, style: :simple)
|
80
|
-
.add(:num, style: :simple)
|
81
|
-
.connect(resource, :data)
|
82
|
-
instance.foo.must_equal([3, 2])
|
83
|
-
instance.num.must_equal([1, 2])
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe 'when calling entries' do
|
88
|
-
before { factory.add(:baz).connect(resource, :data) }
|
89
|
-
let(:entries) { instance.baz(/.*/).entries }
|
90
|
-
let(:entry) { instance.baz('yay').entries }
|
91
|
-
|
92
|
-
it 'retrieves all entries with this field' do
|
93
|
-
entries.length.must_equal 3
|
94
|
-
entry.length.must_equal 1
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'retrieves all entries with this field' do
|
98
|
-
entry[0].must_be_kind_of(Struct)
|
99
|
-
end
|
100
|
-
|
101
|
-
it 'retrieves all entries with this field' do
|
102
|
-
entry[0].baz.must_equal 'yay'
|
103
|
-
end
|
104
|
-
|
105
|
-
it 'prints nicely' do
|
106
|
-
entry[0].to_s.must_match(/ with baz == "yay" one entry/)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
describe 'with the number field' do
|
111
|
-
before { factory.add(:num).connect(resource, :data) }
|
112
|
-
|
113
|
-
it 'filter by nil' do
|
114
|
-
instance.num(nil).params.must_equal [data[0]]
|
115
|
-
end
|
116
|
-
|
117
|
-
it 'filter by existing numbers' do
|
118
|
-
instance.num(1).params.must_equal [data[1]]
|
119
|
-
end
|
120
|
-
|
121
|
-
it 'filter by missing number' do
|
122
|
-
instance.num(-1).params.must_equal []
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
describe 'with the string-number field' do
|
127
|
-
before { factory.add(:snum).connect(resource, :data) }
|
128
|
-
|
129
|
-
it 'retrieves the number 0' do
|
130
|
-
instance.snum(0).params.must_equal [data[0]]
|
131
|
-
end
|
132
|
-
|
133
|
-
it 'retrieves the number 1' do
|
134
|
-
instance.snum(1).params.must_equal []
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
describe 'with the string-float field' do
|
139
|
-
before { factory.add(:snum).connect(resource, :data) }
|
140
|
-
|
141
|
-
it 'retrieves the float 0.0' do
|
142
|
-
instance.snum(0.0).params.must_equal [data[0]]
|
143
|
-
end
|
144
|
-
|
145
|
-
it 'retrieves the float 1.0' do
|
146
|
-
instance.snum(1.0).params.must_equal [data[2]]
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
describe 'with a regex check' do
|
151
|
-
before { factory.add(:baz).connect(resource, :data) }
|
152
|
-
|
153
|
-
it 'retrieves the number 0' do
|
154
|
-
instance.baz(/ever$/).params.must_equal [data[2]]
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
describe 'with the string field' do
|
159
|
-
before { factory.add(:baz).connect(resource, :data) }
|
160
|
-
|
161
|
-
it 'filter by existing strings' do
|
162
|
-
instance.baz('yay').params.must_equal [data[0]]
|
163
|
-
end
|
164
|
-
|
165
|
-
it 'filter by missing string' do
|
166
|
-
instance.baz('num').params.must_equal []
|
167
|
-
end
|
168
|
-
|
169
|
-
it 'filter by existing regex' do
|
170
|
-
instance.baz(/A/i).params.must_equal [data[0], data[2]]
|
171
|
-
end
|
172
|
-
|
173
|
-
it 'filter by missing regex' do
|
174
|
-
instance.baz(/zzz/).params.must_equal []
|
175
|
-
end
|
176
|
-
end
|
177
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# author: Stephan Renatus
|
3
|
-
|
4
|
-
require 'helper'
|
5
|
-
|
6
|
-
describe FindFiles do
|
7
|
-
let (:findfiles) do
|
8
|
-
class FindFilesTest
|
9
|
-
include FindFiles
|
10
|
-
def inspec
|
11
|
-
Inspec::Backend.create(backend: :mock)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
FindFilesTest.new
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '#find_files' do
|
18
|
-
it 'returns an array (of findings)' do
|
19
|
-
files = findfiles.find_files('/no/such/mock', type: 'file', depth: 1)
|
20
|
-
files.must_equal([])
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# author: Dominik Richter
|
3
|
-
# author: Christoph Hartmann
|
4
|
-
|
5
|
-
require 'helper'
|
6
|
-
|
7
|
-
describe PasswdParser do
|
8
|
-
let (:parser) { Class.new() { include PasswdParser }.new }
|
9
|
-
|
10
|
-
describe '#parse_passwd' do
|
11
|
-
it 'parses nil content' do
|
12
|
-
parser.parse_passwd(nil).must_equal([])
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'parses an empty passwd line' do
|
16
|
-
parser.parse_passwd('').must_equal([])
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'parses a valid passwd line' do
|
20
|
-
info = [{
|
21
|
-
"user"=>"root",
|
22
|
-
"password"=>"x",
|
23
|
-
"uid"=>"0",
|
24
|
-
"gid"=>"0",
|
25
|
-
"desc"=>"root",
|
26
|
-
"home"=>"/root",
|
27
|
-
"shell"=>"/bin/sh"
|
28
|
-
}]
|
29
|
-
parser.parse_passwd('root:x:0:0:root:/root:/bin/sh').must_equal(info)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|