serverspec-ruby19 2.24.3
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 +7 -0
- data/.gitignore +26 -0
- data/.gitmodules +3 -0
- data/.travis.yml +19 -0
- data/Gemfile +8 -0
- data/Guardfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +26 -0
- data/Rakefile +30 -0
- data/WINDOWS_SUPPORT.md +118 -0
- data/appveyor.yml +56 -0
- data/bin/serverspec-init +7 -0
- data/lib/serverspec.rb +63 -0
- data/lib/serverspec/commands/base.rb +7 -0
- data/lib/serverspec/helper.rb +8 -0
- data/lib/serverspec/helper/type.rb +26 -0
- data/lib/serverspec/matcher.rb +39 -0
- data/lib/serverspec/matcher/be_enabled.rb +13 -0
- data/lib/serverspec/matcher/be_enforcing.rb +10 -0
- data/lib/serverspec/matcher/be_executable.rb +13 -0
- data/lib/serverspec/matcher/be_installed.rb +13 -0
- data/lib/serverspec/matcher/be_listening.rb +13 -0
- data/lib/serverspec/matcher/be_mounted.rb +15 -0
- data/lib/serverspec/matcher/be_permissive.rb +10 -0
- data/lib/serverspec/matcher/be_reachable.rb +17 -0
- data/lib/serverspec/matcher/be_readable.rb +13 -0
- data/lib/serverspec/matcher/be_resolvable.rb +9 -0
- data/lib/serverspec/matcher/be_running.rb +13 -0
- data/lib/serverspec/matcher/be_writable.rb +13 -0
- data/lib/serverspec/matcher/belong_to_group.rb +5 -0
- data/lib/serverspec/matcher/belong_to_primary_group.rb +5 -0
- data/lib/serverspec/matcher/contain.rb +28 -0
- data/lib/serverspec/matcher/have_entry.rb +14 -0
- data/lib/serverspec/matcher/have_rule.rb +17 -0
- data/lib/serverspec/matcher/have_site_application.rb +18 -0
- data/lib/serverspec/matcher/have_site_bindings.rb +22 -0
- data/lib/serverspec/matcher/have_virtual_dir.rb +14 -0
- data/lib/serverspec/power_assert.rb +14 -0
- data/lib/serverspec/setup.rb +338 -0
- data/lib/serverspec/subject.rb +12 -0
- data/lib/serverspec/type/base.rb +30 -0
- data/lib/serverspec/type/bond.rb +11 -0
- data/lib/serverspec/type/bridge.rb +11 -0
- data/lib/serverspec/type/cgroup.rb +17 -0
- data/lib/serverspec/type/command.rb +20 -0
- data/lib/serverspec/type/cron.rb +15 -0
- data/lib/serverspec/type/default_gateway.rb +15 -0
- data/lib/serverspec/type/docker_base.rb +29 -0
- data/lib/serverspec/type/docker_container.rb +27 -0
- data/lib/serverspec/type/docker_image.rb +4 -0
- data/lib/serverspec/type/file.rb +133 -0
- data/lib/serverspec/type/fstab.rb +11 -0
- data/lib/serverspec/type/group.rb +11 -0
- data/lib/serverspec/type/host.rb +21 -0
- data/lib/serverspec/type/iis_app_pool.rb +43 -0
- data/lib/serverspec/type/iis_website.rb +40 -0
- data/lib/serverspec/type/interface.rb +27 -0
- data/lib/serverspec/type/ip6tables.rb +13 -0
- data/lib/serverspec/type/ipfilter.rb +11 -0
- data/lib/serverspec/type/ipnat.rb +11 -0
- data/lib/serverspec/type/iptables.rb +11 -0
- data/lib/serverspec/type/kernel_module.rb +7 -0
- data/lib/serverspec/type/linux_audit_system.rb +45 -0
- data/lib/serverspec/type/linux_kernel_parameter.rb +10 -0
- data/lib/serverspec/type/lxc.rb +15 -0
- data/lib/serverspec/type/mail_alias.rb +7 -0
- data/lib/serverspec/type/mysql_config.rb +10 -0
- data/lib/serverspec/type/package.rb +66 -0
- data/lib/serverspec/type/php_config.rb +10 -0
- data/lib/serverspec/type/port.rb +40 -0
- data/lib/serverspec/type/ppa.rb +11 -0
- data/lib/serverspec/type/process.rb +27 -0
- data/lib/serverspec/type/routing_table.rb +11 -0
- data/lib/serverspec/type/selinux.rb +19 -0
- data/lib/serverspec/type/selinux_module.rb +11 -0
- data/lib/serverspec/type/service.rb +52 -0
- data/lib/serverspec/type/user.rb +43 -0
- data/lib/serverspec/type/windows_feature.rb +7 -0
- data/lib/serverspec/type/windows_hot_fix.rb +7 -0
- data/lib/serverspec/type/windows_registry_key.rb +19 -0
- data/lib/serverspec/type/windows_scheduled_task.rb +7 -0
- data/lib/serverspec/type/x509_certificate.rb +76 -0
- data/lib/serverspec/type/x509_private_key.rb +21 -0
- data/lib/serverspec/type/yumrepo.rb +11 -0
- data/lib/serverspec/type/zfs.rb +29 -0
- data/lib/serverspec/version.rb +3 -0
- data/serverspec.gemspec +28 -0
- data/spec/helper/type_spec.rb +6 -0
- data/spec/spec_helper.rb +28 -0
- data/spec/type/aix/file_spec.rb +31 -0
- data/spec/type/aix/group_spec.rb +7 -0
- data/spec/type/aix/package_spec.rb +7 -0
- data/spec/type/aix/port_spec.rb +20 -0
- data/spec/type/aix/service_spec.rb +12 -0
- data/spec/type/aix/user_spec.rb +16 -0
- data/spec/type/arch/file_spec.rb +15 -0
- data/spec/type/arch/package_spec.rb +19 -0
- data/spec/type/arch/service_spec.rb +9 -0
- data/spec/type/base/command_spec.rb +67 -0
- data/spec/type/base/cron_spec.rb +11 -0
- data/spec/type/base/default_gateway_spec.rb +11 -0
- data/spec/type/base/file_spec.rb +356 -0
- data/spec/type/base/group_spec.rb +11 -0
- data/spec/type/base/host_spec.rb +47 -0
- data/spec/type/base/mail_alias_spec.rb +7 -0
- data/spec/type/base/mysql_config_spec.rb +13 -0
- data/spec/type/base/package_spec.rb +51 -0
- data/spec/type/base/php_config_spec.rb +33 -0
- data/spec/type/base/port_spec.rb +34 -0
- data/spec/type/base/process_spec.rb +35 -0
- data/spec/type/base/routing_table_spec.rb +63 -0
- data/spec/type/base/service_spec.rb +49 -0
- data/spec/type/base/user_spec.rb +44 -0
- data/spec/type/darwin/file_spec.rb +41 -0
- data/spec/type/darwin/package_spec.rb +19 -0
- data/spec/type/darwin/port_spec.rb +27 -0
- data/spec/type/darwin/service_spec.rb +16 -0
- data/spec/type/debian/package_spec.rb +23 -0
- data/spec/type/debian/service_spec.rb +11 -0
- data/spec/type/fedora/service_spec.rb +15 -0
- data/spec/type/fedora15/service_spec.rb +15 -0
- data/spec/type/fedora20/service_spec.rb +15 -0
- data/spec/type/freebsd/file_spec.rb +29 -0
- data/spec/type/freebsd/package_spec.rb +19 -0
- data/spec/type/freebsd/port_spec.rb +27 -0
- data/spec/type/freebsd/service_spec.rb +8 -0
- data/spec/type/freebsd10/package_spec.rb +19 -0
- data/spec/type/gentoo/package_spec.rb +7 -0
- data/spec/type/gentoo/service_spec.rb +12 -0
- data/spec/type/linux/bond_spec.rb +12 -0
- data/spec/type/linux/bridge_spec.rb +12 -0
- data/spec/type/linux/cgroup_spec.rb +13 -0
- data/spec/type/linux/docker_container_pre_1_8_spec.rb +124 -0
- data/spec/type/linux/docker_container_spec.rb +126 -0
- data/spec/type/linux/docker_image_spec.rb +94 -0
- data/spec/type/linux/file_spec.rb +27 -0
- data/spec/type/linux/fstab_spec.rb +31 -0
- data/spec/type/linux/interface_spec.rb +30 -0
- data/spec/type/linux/ip6tables_spec.rb +19 -0
- data/spec/type/linux/iptables_spec.rb +11 -0
- data/spec/type/linux/kernel_module_spec.rb +7 -0
- data/spec/type/linux/linux_audit_system_spec.rb +139 -0
- data/spec/type/linux/linux_kernel_parameter_spec.rb +33 -0
- data/spec/type/linux/lxc_container_spec.rb +12 -0
- data/spec/type/linux/selinux_module_spec.rb +11 -0
- data/spec/type/linux/selinux_spec.rb +23 -0
- data/spec/type/linux/x509_certificate_spec.rb +62 -0
- data/spec/type/linux/x509_private_key_spec.rb +31 -0
- data/spec/type/linux/zfs_spec.rb +15 -0
- data/spec/type/nixos/package_spec.rb +15 -0
- data/spec/type/nixos/service_spec.rb +9 -0
- data/spec/type/openbsd/file_spec.rb +134 -0
- data/spec/type/openbsd/interface_spec.rb +21 -0
- data/spec/type/openbsd/mail_alias_spec.rb +7 -0
- data/spec/type/openbsd/package_spec.rb +11 -0
- data/spec/type/openbsd/port_spec.rb +7 -0
- data/spec/type/openbsd/service_spec.rb +13 -0
- data/spec/type/openbsd/user_spec.rb +12 -0
- data/spec/type/opensuse/service_spec.rb +16 -0
- data/spec/type/plamo/package_spec.rb +8 -0
- data/spec/type/plamo/service_spec.rb +8 -0
- data/spec/type/redhat/file_spec.rb +19 -0
- data/spec/type/redhat/package_spec.rb +23 -0
- data/spec/type/redhat/service_spec.rb +11 -0
- data/spec/type/redhat/yumrepo_spec.rb +11 -0
- data/spec/type/redhat5/iptables_spec.rb +11 -0
- data/spec/type/redhat7/service_spec.rb +9 -0
- data/spec/type/smartos/package_spec.rb +19 -0
- data/spec/type/smartos/service_spec.rb +16 -0
- data/spec/type/solaris/cron_spec.rb +11 -0
- data/spec/type/solaris/file_spec.rb +15 -0
- data/spec/type/solaris/group_spec.rb +7 -0
- data/spec/type/solaris/host_spec.rb +19 -0
- data/spec/type/solaris/ipfilter_spec.rb +7 -0
- data/spec/type/solaris/ipnat_spec.rb +7 -0
- data/spec/type/solaris/package_spec.rb +7 -0
- data/spec/type/solaris/port_spec.rb +34 -0
- data/spec/type/solaris/service_spec.rb +16 -0
- data/spec/type/solaris/user_spec.rb +16 -0
- data/spec/type/solaris/zfs_spec.rb +15 -0
- data/spec/type/solaris10/file_spec.rb +313 -0
- data/spec/type/solaris10/group_spec.rb +8 -0
- data/spec/type/solaris10/host_spec.rb +16 -0
- data/spec/type/solaris10/package_spec.rb +8 -0
- data/spec/type/solaris10/user_spec.rb +8 -0
- data/spec/type/suse/package_spec.rb +23 -0
- data/spec/type/suse/service_spec.rb +11 -0
- data/spec/type/ubuntu/ppa_spec.rb +11 -0
- data/spec/type/ubuntu/service_spec.rb +7 -0
- data/spec/type/windows/command_spec.rb +64 -0
- data/spec/type/windows/feature_spec.rb +17 -0
- data/spec/type/windows/file_spec.rb +120 -0
- data/spec/type/windows/group_spec.rb +23 -0
- data/spec/type/windows/host_spec.rb +32 -0
- data/spec/type/windows/hot_fix_spec.rb +22 -0
- data/spec/type/windows/iis_app_pool_spec.rb +17 -0
- data/spec/type/windows/iis_webisite_spec.rb +16 -0
- data/spec/type/windows/package_spec.rb +10 -0
- data/spec/type/windows/port_spec.rb +25 -0
- data/spec/type/windows/registry_key_spec.rb +58 -0
- data/spec/type/windows/scheduled_task_spec.rb +9 -0
- data/spec/type/windows/service_spec.rb +30 -0
- data/spec/type/windows/user_spec.rb +33 -0
- data/wercker.yml +1 -0
- metadata +450 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
module Serverspec::Type
|
|
2
|
+
class User < Base
|
|
3
|
+
def exists?
|
|
4
|
+
@runner.check_user_exists(@name)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def belongs_to_group?(group)
|
|
8
|
+
@runner.check_user_belongs_to_group(@name, group)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def belongs_to_primary_group?(group)
|
|
12
|
+
@runner.check_user_belongs_to_primary_group(@name, group)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def has_uid?(uid)
|
|
16
|
+
@runner.check_user_has_uid(@name, uid)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def has_home_directory?(path)
|
|
20
|
+
@runner.check_user_has_home_directory(@name, path)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def has_login_shell?(shell)
|
|
24
|
+
@runner.check_user_has_login_shell(@name, shell)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def has_authorized_key?(key)
|
|
28
|
+
@runner.check_user_has_authorized_key(@name, key)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def minimum_days_between_password_change
|
|
32
|
+
@runner.get_user_minimum_days_between_password_change(@name).stdout.to_i
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def maximum_days_between_password_change
|
|
36
|
+
@runner.get_user_maximum_days_between_password_change(@name).stdout.to_i
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def encrypted_password
|
|
40
|
+
@runner.get_user_encrypted_password(@name).stdout.strip
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Serverspec::Type
|
|
2
|
+
class WindowsRegistryKey < Base
|
|
3
|
+
def exists?
|
|
4
|
+
@runner.check_registry_key_exists(@name)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def has_property?(property_name, property_type = :type_string)
|
|
8
|
+
@runner.check_registry_key_has_property(@name, {:name => property_name, :type => property_type})
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def has_value?(value)
|
|
12
|
+
@runner.check_registry_key_has_value(@name, {:name => '', :type => :type_string, :value => value})
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def has_property_value?(property_name, property_type, value)
|
|
16
|
+
@runner.check_registry_key_has_value(@name, {:name => property_name, :type => property_type, :value => value})
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
require 'time'
|
|
2
|
+
|
|
3
|
+
module Serverspec::Type
|
|
4
|
+
class X509Certificate < Base
|
|
5
|
+
def certificate?
|
|
6
|
+
(run_openssl_command_with("-noout").exit_status == 0)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def subject
|
|
10
|
+
run_openssl_command_with("-subject -noout").stdout.chomp.gsub(/^subject= /,'')
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def issuer
|
|
14
|
+
run_openssl_command_with("-issuer -noout").stdout.chomp.gsub(/^issuer= /,'')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def email
|
|
18
|
+
run_openssl_command_with("-email -noout").stdout.chomp
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def fingerprint
|
|
22
|
+
run_openssl_command_with("-fingerprint -noout").stdout.chomp
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def alias
|
|
26
|
+
run_openssl_command_with("-alias -noout").stdout.chomp
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Modern openssl use following output format for key length:
|
|
30
|
+
# Public-Key: (4096 bit)
|
|
31
|
+
# while ancient (0.9.8 for example) use
|
|
32
|
+
# RSA Public Key: (2048 bit)
|
|
33
|
+
def keylength
|
|
34
|
+
len_str = run_openssl_command_with("-text -noout | grep -E 'Public(-| )Key: \\([[:digit:]]+ bit\\)'").stdout.chomp
|
|
35
|
+
len_str.gsub(/^.*\(/,'').gsub(/ bit\)$/,'').to_i
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def has_purpose?(p)
|
|
39
|
+
grep_str = "#{p} : Yes"
|
|
40
|
+
( run_openssl_command_with("-purpose -noout | grep -wq \"#{grep_str}\"").
|
|
41
|
+
exit_status == 0 )
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def valid?
|
|
45
|
+
runner_res = run_openssl_command_with("-startdate -enddate -noout")
|
|
46
|
+
return false if runner_res.exit_status != 0
|
|
47
|
+
|
|
48
|
+
date_map = parse_dates_str_to_map(runner_res.stdout)
|
|
49
|
+
|
|
50
|
+
now = Time.now
|
|
51
|
+
( now >= date_map[:notBefore] && now <= date_map[:notAfter])
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def validity_in_days
|
|
55
|
+
runner_res = run_openssl_command_with("-enddate -noout")
|
|
56
|
+
return 0 if runner_res.exit_status != 0
|
|
57
|
+
|
|
58
|
+
date_map = parse_dates_str_to_map(runner_res.stdout)
|
|
59
|
+
diff = date_map[:notAfter] - Time.now
|
|
60
|
+
( diff/(60*60*24) )
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
private
|
|
64
|
+
def run_openssl_command_with(param_str)
|
|
65
|
+
@runner.run_command("openssl x509 -in #{name} #{param_str}")
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def parse_dates_str_to_map(dates_str)
|
|
69
|
+
dates_str.split("\n").inject({}) do |res,line|
|
|
70
|
+
kv_arr = line.split '='
|
|
71
|
+
time = Time.strptime(kv_arr[1],'%b %e %T %Y %Z') rescue Time.parse(kv_arr[1] || '')
|
|
72
|
+
res.merge({ kv_arr[0].to_sym => time })
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require 'time'
|
|
2
|
+
|
|
3
|
+
module Serverspec::Type
|
|
4
|
+
class X509PrivateKey < Base
|
|
5
|
+
def valid?
|
|
6
|
+
runner_res = @runner.run_command("openssl rsa -in #{name} -check -noout")
|
|
7
|
+
( runner_res.exit_status == 0 && runner_res.stdout.chomp == 'RSA key ok' )
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def encrypted?
|
|
11
|
+
@runner.run_command("grep -wq \"^Proc-Type.*ENCRYPTED$\" #{name}").exit_status == 0
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def has_matching_certificate?(cert_file)
|
|
15
|
+
mac_op = "openssl sha -sha512"
|
|
16
|
+
h1 = @runner.run_command("openssl x509 -noout -modulus -in #{cert_file} | #{mac_op}")
|
|
17
|
+
h2 = @runner.run_command("openssl rsa -noout -modulus -in #{name} | #{mac_op}")
|
|
18
|
+
(h1.stdout == h2.stdout) && (h1.exit_status == 0) && (h2.exit_status == 0)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Serverspec::Type
|
|
2
|
+
class Zfs < Base
|
|
3
|
+
def exists?
|
|
4
|
+
@runner.check_zfs_exists(@name)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def has_property?(property)
|
|
8
|
+
@runner.check_zfs_has_property(@name, property)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def to_s
|
|
12
|
+
'ZFS'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def property
|
|
16
|
+
get_property if @property.nil?
|
|
17
|
+
@property
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
def get_property
|
|
22
|
+
@property = Hash.new
|
|
23
|
+
@runner.get_zfs_property(@name).stdout.split(/\n/).each do |line|
|
|
24
|
+
property, value = line.split(/\s+/)
|
|
25
|
+
@property[property] = value
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
data/serverspec.gemspec
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'serverspec/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "serverspec-ruby19"
|
|
8
|
+
spec.version = Serverspec::VERSION
|
|
9
|
+
spec.authors = [""]
|
|
10
|
+
spec.email = [""]
|
|
11
|
+
spec.description = %q{RSpec tests for your servers configured by Puppet, Chef, Itamae or anything else}
|
|
12
|
+
spec.summary = %q{RSpec tests for your servers configured by Puppet, Chef, Itamae or anything else}
|
|
13
|
+
spec.homepage = ""
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files`.split($/)
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_runtime_dependency "rspec", "3.4.0"
|
|
22
|
+
spec.add_runtime_dependency "rspec-its", "1.2.0"
|
|
23
|
+
spec.add_runtime_dependency "multi_json", "1.11.2"
|
|
24
|
+
spec.add_runtime_dependency "specinfra-rb19", "2.44.7"
|
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
|
26
|
+
spec.add_development_dependency("json", "~> 1.8") if RUBY_VERSION < "1.9"
|
|
27
|
+
spec.add_development_dependency "rake", "~> 10.1.1"
|
|
28
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'serverspec'
|
|
2
|
+
|
|
3
|
+
set :backend, :exec
|
|
4
|
+
|
|
5
|
+
module Specinfra
|
|
6
|
+
module Backend
|
|
7
|
+
class Exec < Base
|
|
8
|
+
def run_command cmd
|
|
9
|
+
CommandResult.new({
|
|
10
|
+
:stdout => ::Specinfra.configuration.stdout,
|
|
11
|
+
:stderr => ::Specinfra.configuration.stderr,
|
|
12
|
+
:exit_status => ::Specinfra.configuration.exit_status,
|
|
13
|
+
:exit_signal => nil,
|
|
14
|
+
})
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
class Cmd < Base
|
|
18
|
+
def run_command cmd
|
|
19
|
+
CommandResult.new({
|
|
20
|
+
:stdout => ::Specinfra.configuration.stdout,
|
|
21
|
+
:stderr => ::Specinfra.configuration.stderr,
|
|
22
|
+
:exit_status => ::Specinfra.configuration.exit_status,
|
|
23
|
+
:exit_signal => nil,
|
|
24
|
+
})
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
set :os, {:family => 'aix'}
|
|
4
|
+
|
|
5
|
+
describe file('/tmp') do
|
|
6
|
+
it { should be_readable.by_user('mail') }
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe file('/tmp') do
|
|
10
|
+
it { should be_writable.by_user('mail') }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe file('/tmp') do
|
|
14
|
+
it { should be_executable.by_user('mail') }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe file('/etc/passwd') do
|
|
18
|
+
it 'be_mode is not implemented' do
|
|
19
|
+
expect {
|
|
20
|
+
should be_mode 644
|
|
21
|
+
}.to raise_exception
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe file('/etc/passwd') do
|
|
26
|
+
it { should be_owned_by 'root' }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe file('/etc/passwd') do
|
|
30
|
+
it { should be_grouped_into 'root' }
|
|
31
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
set :os, :family => 'aix'
|
|
4
|
+
|
|
5
|
+
describe port(80) do
|
|
6
|
+
it { should be_listening }
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe port(80) do
|
|
10
|
+
it { should be_listening.with('tcp') }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe port(80) do
|
|
14
|
+
it { should be_listening.on('127.0.0.1') }
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
describe port(53) do
|
|
18
|
+
it { should be_listening.with('udp') }
|
|
19
|
+
end
|
|
20
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
set :os, :family => 'aix'
|
|
4
|
+
|
|
5
|
+
describe user('root') do
|
|
6
|
+
it { should belong_to_group 'root' }
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe user('root') do
|
|
10
|
+
it { should have_login_shell '/bin/bash' }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe user('root') do
|
|
14
|
+
it { should have_home_directory '/root' }
|
|
15
|
+
end
|
|
16
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
set :os, :family => 'arch'
|
|
4
|
+
|
|
5
|
+
describe file('/tmp') do
|
|
6
|
+
it { should be_readable.by_user('mail') }
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe file('/tmp') do
|
|
10
|
+
it { should be_writable.by_user('mail') }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe file('/tmp') do
|
|
14
|
+
it { should be_executable.by_user('mail') }
|
|
15
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
set :os, :family => 'arch'
|
|
4
|
+
|
|
5
|
+
describe package('httpd') do
|
|
6
|
+
it { should be_installed }
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe package('httpd') do
|
|
10
|
+
it { should be_installed.with_version('2.2.15-28.el6') }
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe package('httpd') do
|
|
14
|
+
let(:stdout) { "2.2.15\n" }
|
|
15
|
+
its(:version) { should eq '2.2.15' }
|
|
16
|
+
its(:version) { should > '2.2.14' }
|
|
17
|
+
its(:version) { should < '2.2.16' }
|
|
18
|
+
its(:version) { should > '2.2.9' }
|
|
19
|
+
end
|