serverspec 0.11.5 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (230) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -5
  3. data/lib/serverspec.rb +2 -36
  4. data/lib/serverspec/helper.rb +2 -32
  5. data/lib/serverspec/helper/backend.rb +11 -0
  6. data/lib/serverspec/helper/os.rb +25 -0
  7. data/lib/serverspec/setup.rb +3 -3
  8. data/lib/serverspec/version.rb +1 -1
  9. data/serverspec.gemspec +1 -0
  10. data/spec/aix/command_spec.rb +1 -1
  11. data/spec/aix/cron_spec.rb +1 -1
  12. data/spec/aix/default_gateway_spec.rb +1 -1
  13. data/spec/aix/file_spec.rb +1 -1
  14. data/spec/aix/group_spec.rb +1 -1
  15. data/spec/aix/host_spec.rb +1 -1
  16. data/spec/aix/package_spec.rb +1 -1
  17. data/spec/aix/php_config_spec.rb +1 -1
  18. data/spec/aix/port_spec.rb +1 -1
  19. data/spec/aix/routing_table_spec.rb +1 -1
  20. data/spec/aix/service_spec.rb +1 -1
  21. data/spec/aix/user_spec.rb +1 -1
  22. data/spec/backend/cmd/configuration_spec.rb +2 -2
  23. data/spec/backend/exec/build_command_spec.rb +1 -1
  24. data/spec/backend/exec/configuration_spec.rb +2 -3
  25. data/spec/backend/powershell/script_helper_spec.rb +4 -4
  26. data/spec/backend/ssh/build_command_spec.rb +1 -1
  27. data/spec/backend/ssh/configuration_spec.rb +2 -3
  28. data/spec/backend/winrm/configuration_spec.rb +2 -2
  29. data/spec/darwin/command_spec.rb +1 -1
  30. data/spec/darwin/cron_spec.rb +1 -1
  31. data/spec/darwin/default_gateway_spec.rb +1 -1
  32. data/spec/darwin/file_spec.rb +1 -1
  33. data/spec/darwin/group_spec.rb +1 -1
  34. data/spec/darwin/host_spec.rb +1 -1
  35. data/spec/darwin/mail_alias_spec.rb +1 -1
  36. data/spec/darwin/package_spec.rb +1 -1
  37. data/spec/darwin/php_config_spec.rb +1 -1
  38. data/spec/darwin/port_spec.rb +1 -1
  39. data/spec/darwin/routing_table_spec.rb +1 -1
  40. data/spec/darwin/service_spec.rb +1 -1
  41. data/spec/darwin/user_spec.rb +1 -1
  42. data/spec/debian/cgroup_spec.rb +1 -1
  43. data/spec/debian/command_spec.rb +1 -1
  44. data/spec/debian/cron_spec.rb +1 -1
  45. data/spec/debian/default_gateway_spec.rb +1 -1
  46. data/spec/debian/file_spec.rb +1 -1
  47. data/spec/debian/group_spec.rb +1 -1
  48. data/spec/debian/host_spec.rb +1 -1
  49. data/spec/debian/interface_spec.rb +1 -1
  50. data/spec/debian/iptables_spec.rb +1 -1
  51. data/spec/debian/kernel_module_spec.rb +1 -1
  52. data/spec/debian/linux_kernel_parameter_spec.rb +1 -1
  53. data/spec/debian/lxc_spec.rb +1 -1
  54. data/spec/debian/mail_alias_spec.rb +1 -1
  55. data/spec/debian/package_spec.rb +1 -1
  56. data/spec/debian/php_config_spec.rb +1 -1
  57. data/spec/debian/port_spec.rb +1 -1
  58. data/spec/debian/routing_table_spec.rb +1 -1
  59. data/spec/debian/selinux_spec.rb +1 -1
  60. data/spec/debian/service_spec.rb +1 -1
  61. data/spec/debian/user_spec.rb +1 -1
  62. data/spec/debian/zfs_spec.rb +1 -1
  63. data/spec/freebsd/command_spec.rb +1 -1
  64. data/spec/freebsd/cron_spec.rb +1 -1
  65. data/spec/freebsd/default_gateway_spec.rb +1 -1
  66. data/spec/freebsd/file_spec.rb +1 -1
  67. data/spec/freebsd/group_spec.rb +1 -1
  68. data/spec/freebsd/host_spec.rb +1 -1
  69. data/spec/freebsd/package_spec.rb +1 -1
  70. data/spec/freebsd/php_config_spec.rb +1 -1
  71. data/spec/freebsd/port_spec.rb +1 -1
  72. data/spec/freebsd/routing_table_spec.rb +1 -1
  73. data/spec/freebsd/service_spec.rb +1 -1
  74. data/spec/freebsd/user_spec.rb +1 -1
  75. data/spec/gentoo/cgroup_spec.rb +1 -1
  76. data/spec/gentoo/command_spec.rb +1 -1
  77. data/spec/gentoo/cron_spec.rb +1 -1
  78. data/spec/gentoo/default_gateway_spec.rb +1 -1
  79. data/spec/gentoo/file_spec.rb +1 -1
  80. data/spec/gentoo/group_spec.rb +1 -1
  81. data/spec/gentoo/host_spec.rb +1 -1
  82. data/spec/gentoo/interface_spec.rb +1 -1
  83. data/spec/gentoo/iptables_spec.rb +1 -1
  84. data/spec/gentoo/kernel_module_spec.rb +1 -1
  85. data/spec/gentoo/linux_kernel_parameter_spec.rb +1 -1
  86. data/spec/gentoo/lxc_spec.rb +1 -1
  87. data/spec/gentoo/mail_alias_spec.rb +1 -1
  88. data/spec/gentoo/package_spec.rb +1 -1
  89. data/spec/gentoo/php_config_spec.rb +1 -1
  90. data/spec/gentoo/port_spec.rb +1 -1
  91. data/spec/gentoo/routing_table_spec.rb +1 -1
  92. data/spec/gentoo/selinux_spec.rb +1 -1
  93. data/spec/gentoo/service_spec.rb +1 -1
  94. data/spec/gentoo/user_spec.rb +1 -1
  95. data/spec/gentoo/zfs_spec.rb +1 -1
  96. data/spec/plamo/cgroup_spec.rb +1 -1
  97. data/spec/plamo/command_spec.rb +1 -1
  98. data/spec/plamo/cron_spec.rb +1 -1
  99. data/spec/plamo/default_gateway_spec.rb +1 -1
  100. data/spec/plamo/file_spec.rb +1 -1
  101. data/spec/plamo/group_spec.rb +1 -1
  102. data/spec/plamo/host_spec.rb +1 -1
  103. data/spec/plamo/interface_spec.rb +1 -1
  104. data/spec/plamo/iptables_spec.rb +1 -1
  105. data/spec/plamo/kernel_module_spec.rb +1 -1
  106. data/spec/plamo/linux_kernel_parameter_spec.rb +1 -1
  107. data/spec/plamo/lxc_spec.rb +1 -1
  108. data/spec/plamo/mail_alias_spec.rb +1 -1
  109. data/spec/plamo/package_spec.rb +1 -1
  110. data/spec/plamo/php_config_spec.rb +1 -1
  111. data/spec/plamo/port_spec.rb +1 -1
  112. data/spec/plamo/routing_table_spec.rb +1 -1
  113. data/spec/plamo/selinux_spec.rb +1 -1
  114. data/spec/plamo/service_spec.rb +1 -1
  115. data/spec/plamo/user_spec.rb +1 -1
  116. data/spec/plamo/zfs_spec.rb +1 -1
  117. data/spec/redhat/cgroup_spec.rb +1 -1
  118. data/spec/redhat/command_spec.rb +1 -1
  119. data/spec/redhat/cron_spec.rb +1 -1
  120. data/spec/redhat/default_gateway_spec.rb +1 -1
  121. data/spec/redhat/file_spec.rb +1 -1
  122. data/spec/redhat/group_spec.rb +1 -1
  123. data/spec/redhat/host_spec.rb +1 -1
  124. data/spec/redhat/interface_spec.rb +1 -1
  125. data/spec/redhat/iptables_spec.rb +1 -1
  126. data/spec/redhat/kernel_module_spec.rb +1 -1
  127. data/spec/redhat/linux_kernel_parameter_spec.rb +1 -1
  128. data/spec/redhat/lxc_spec.rb +1 -1
  129. data/spec/redhat/mail_alias_spec.rb +1 -1
  130. data/spec/redhat/package_spec.rb +1 -1
  131. data/spec/redhat/php_config_spec.rb +1 -1
  132. data/spec/redhat/port_spec.rb +1 -1
  133. data/spec/redhat/routing_table_spec.rb +1 -1
  134. data/spec/redhat/selinux_spec.rb +1 -1
  135. data/spec/redhat/service_spec.rb +1 -1
  136. data/spec/redhat/user_spec.rb +1 -1
  137. data/spec/redhat/yumrepo_spec.rb +1 -1
  138. data/spec/redhat/zfs_spec.rb +1 -1
  139. data/spec/smartos/mail_alias_spec.rb +1 -1
  140. data/spec/solaris/command_spec.rb +1 -1
  141. data/spec/solaris/cron_spec.rb +1 -1
  142. data/spec/solaris/default_gateway_spec.rb +1 -1
  143. data/spec/solaris/file_spec.rb +1 -1
  144. data/spec/solaris/group_spec.rb +1 -1
  145. data/spec/solaris/host_spec.rb +1 -1
  146. data/spec/solaris/ipfilter_spec.rb +1 -1
  147. data/spec/solaris/ipnat_spec.rb +1 -1
  148. data/spec/solaris/mail_alias_spec.rb +1 -1
  149. data/spec/solaris/package_spec.rb +1 -1
  150. data/spec/solaris/php_config_spec.rb +1 -1
  151. data/spec/solaris/port_spec.rb +1 -1
  152. data/spec/solaris/routing_table_spec.rb +1 -1
  153. data/spec/solaris/service_spec.rb +1 -1
  154. data/spec/solaris/svcprop_spec.rb +1 -1
  155. data/spec/solaris/user_spec.rb +1 -1
  156. data/spec/solaris/zfs_spec.rb +1 -1
  157. data/spec/solaris10/file_spec.rb +1 -1
  158. data/spec/solaris10/group_spec.rb +1 -1
  159. data/spec/solaris10/mail_alias_spec.rb +1 -1
  160. data/spec/solaris10/package_spec.rb +1 -1
  161. data/spec/solaris10/php_config_spec.rb +1 -1
  162. data/spec/solaris10/user_spec.rb +1 -1
  163. data/spec/solaris11/command_spec.rb +1 -1
  164. data/spec/solaris11/cron_spec.rb +1 -1
  165. data/spec/solaris11/default_gateway_spec.rb +1 -1
  166. data/spec/solaris11/file_spec.rb +1 -1
  167. data/spec/solaris11/group_spec.rb +1 -1
  168. data/spec/solaris11/host_spec.rb +1 -1
  169. data/spec/solaris11/ipfilter_spec.rb +1 -1
  170. data/spec/solaris11/ipnat_spec.rb +1 -1
  171. data/spec/solaris11/mail_alias_spec.rb +1 -1
  172. data/spec/solaris11/package_spec.rb +1 -1
  173. data/spec/solaris11/php_config_spec.rb +1 -1
  174. data/spec/solaris11/port_spec.rb +1 -1
  175. data/spec/solaris11/routing_table_spec.rb +1 -1
  176. data/spec/solaris11/service_spec.rb +1 -1
  177. data/spec/solaris11/svcprop_spec.rb +1 -1
  178. data/spec/solaris11/user_spec.rb +1 -1
  179. data/spec/solaris11/zfs_spec.rb +1 -1
  180. data/spec/spec_helper.rb +8 -6
  181. data/spec/windows/command_spec.rb +2 -2
  182. data/spec/windows/file_spec.rb +2 -2
  183. data/spec/windows/group_spec.rb +2 -2
  184. data/spec/windows/port_spec.rb +2 -2
  185. data/spec/windows/service_spec.rb +2 -2
  186. data/spec/windows/user_spec.rb +2 -2
  187. data/spec/windows/windows_registry_key_spec.rb +2 -2
  188. metadata +18 -45
  189. data/lib/serverspec/attributes.rb +0 -17
  190. data/lib/serverspec/backend.rb +0 -7
  191. data/lib/serverspec/backend/base.rb +0 -31
  192. data/lib/serverspec/backend/cmd.rb +0 -39
  193. data/lib/serverspec/backend/exec.rb +0 -218
  194. data/lib/serverspec/backend/powershell/command.rb +0 -40
  195. data/lib/serverspec/backend/powershell/script_helper.rb +0 -85
  196. data/lib/serverspec/backend/powershell/support/check_file_access_rules.ps1 +0 -8
  197. data/lib/serverspec/backend/powershell/support/crop_text.ps1 +0 -11
  198. data/lib/serverspec/backend/powershell/support/find_group.ps1 +0 -8
  199. data/lib/serverspec/backend/powershell/support/find_installed_application.ps1 +0 -7
  200. data/lib/serverspec/backend/powershell/support/find_service.ps1 +0 -5
  201. data/lib/serverspec/backend/powershell/support/find_user.ps1 +0 -8
  202. data/lib/serverspec/backend/powershell/support/find_usergroup.ps1 +0 -9
  203. data/lib/serverspec/backend/powershell/support/is_port_listening.ps1 +0 -13
  204. data/lib/serverspec/backend/ssh.rb +0 -93
  205. data/lib/serverspec/backend/winrm.rb +0 -26
  206. data/lib/serverspec/configuration.rb +0 -12
  207. data/lib/serverspec/helper/aix.rb +0 -9
  208. data/lib/serverspec/helper/attributes.rb +0 -16
  209. data/lib/serverspec/helper/base.rb +0 -9
  210. data/lib/serverspec/helper/cmd.rb +0 -15
  211. data/lib/serverspec/helper/configuration.rb +0 -37
  212. data/lib/serverspec/helper/darwin.rb +0 -9
  213. data/lib/serverspec/helper/debian.rb +0 -9
  214. data/lib/serverspec/helper/detect_os.rb +0 -19
  215. data/lib/serverspec/helper/exec.rb +0 -14
  216. data/lib/serverspec/helper/freebsd.rb +0 -9
  217. data/lib/serverspec/helper/gentoo.rb +0 -9
  218. data/lib/serverspec/helper/plamo.rb +0 -9
  219. data/lib/serverspec/helper/properties.rb +0 -14
  220. data/lib/serverspec/helper/puppet.rb +0 -9
  221. data/lib/serverspec/helper/redhat.rb +0 -9
  222. data/lib/serverspec/helper/smartos.rb +0 -10
  223. data/lib/serverspec/helper/solaris.rb +0 -9
  224. data/lib/serverspec/helper/solaris10.rb +0 -9
  225. data/lib/serverspec/helper/solaris11.rb +0 -9
  226. data/lib/serverspec/helper/ssh.rb +0 -15
  227. data/lib/serverspec/helper/windows.rb +0 -9
  228. data/lib/serverspec/helper/winrm.rb +0 -15
  229. data/lib/serverspec/properties.rb +0 -17
  230. data/spec/helpers/properties_spec.rb +0 -11
@@ -1,40 +0,0 @@
1
- module Serverspec
2
- module Backend
3
- module PowerShell
4
- class Command
5
- attr_reader :import_functions, :script
6
- def initialize &block
7
- @import_functions = []
8
- @script = ""
9
- instance_eval &block if block_given?
10
- end
11
-
12
- def using *functions
13
- functions.each { |f| import_functions << f }
14
- end
15
-
16
- def exec code
17
- @script = code
18
- end
19
-
20
- def convert_regexp(target)
21
- case target
22
- when Regexp
23
- target.source
24
- else
25
- target.to_s.gsub '/', ''
26
- end
27
- end
28
-
29
- def get_identity id
30
- raise "You must provide a specific Windows user/group" if id =~ /(owner|group|others)/
31
- identity = id || 'Everyone'
32
- end
33
-
34
- def to_s
35
- @script
36
- end
37
- end
38
- end
39
- end
40
- end
@@ -1,85 +0,0 @@
1
- require 'base64'
2
-
3
- module Serverspec
4
- module Backend
5
- module PowerShell
6
- module ScriptHelper
7
- def build_command(cmd)
8
- path = Serverspec.configuration.path || RSpec.configuration.path
9
- if path
10
- cmd.strip!
11
- cmd =
12
- <<-EOF
13
- $env:path = "#{path};$env:path"
14
- #{cmd}
15
- EOF
16
- end
17
- cmd
18
- end
19
-
20
- def add_pre_command(cmd)
21
- path = Serverspec.configuration.path || RSpec.configuration.path
22
- if Serverspec.configuration.pre_command
23
- cmd.strip!
24
- cmd =
25
- <<-EOF
26
- if (#{Serverspec.configuration.pre_command})
27
- {
28
- #{cmd}
29
- }
30
- EOF
31
- cmd = "$env:path = \"#{path};$env:path\"\n#{cmd}" if path
32
- end
33
- cmd
34
- end
35
-
36
- def encode_script script
37
- script_text = script.chars.to_a.join("\x00").chomp
38
- script_text << "\x00" unless script_text[-1].eql? "\x00"
39
- if script_text.respond_to?(:encode)
40
- script_text = script_text.encode('ASCII-8BIT')
41
- end
42
- if Base64.respond_to?(:strict_encode64)
43
- Base64.strict_encode64(script_text)
44
- else
45
- [ script_text ].pack("m").strip
46
- end
47
- end
48
-
49
- def create_script command
50
- if command.is_a? Command
51
- ps_functions = command.import_functions.map { |f| File.read(File.join(File.dirname(__FILE__), 'support', f)) }
52
- script = build_command(command.script)
53
- script = add_pre_command(script)
54
- <<-EOF
55
- $exitCode = 1
56
- try {
57
- #{ps_functions.join("\n")}
58
- $success = (#{script})
59
- if ($success -is [Boolean] -and $success) { $exitCode = 0 }
60
- } catch {
61
- Write-Output $_.Exception.Message
62
- }
63
- Write-Output "Exiting with code: $exitCode"
64
- exit $exitCode
65
- EOF
66
- else
67
- script = build_command(command.to_s)
68
- add_pre_command(script)
69
- end
70
- end
71
-
72
- def check_running(process)
73
- ret = run_command(commands.check_running(process))
74
-
75
- # If the service is not registered, check the process
76
- if ret[:exit_status] == 1
77
- ret = run_command(commands.check_process(process))
78
- end
79
-
80
- ret[:exit_status] == 0
81
- end
82
- end
83
- end
84
- end
85
- end
@@ -1,8 +0,0 @@
1
- function CheckFileAccessRules
2
- {
3
- param($path, $identity, $rules)
4
-
5
- $accessRules = @((Get-Acl $path).access | Where-Object {$_.AccessControlType -eq 'Allow' -and $_.IdentityReference -eq $identity })
6
- $match = @($accessRules | Where-Object {($_.FileSystemRights.ToString().Split(',') | % {$_.trim()} | ? {$rules -contains $_}) -ne $null})
7
- $match.count -gt 0
8
- }
@@ -1,11 +0,0 @@
1
- function CropText
2
- {
3
- param($text, $fromPattern, $toPattern)
4
-
5
- $from, $to = ([regex]::matches($text, $fromPattern)), ([regex]::matches($text, $toPattern))
6
- if ($from.count -gt 0 -and $to.count -gt 0) {
7
- $text.substring($from[0].index, $to[0].index + $to[0].length - $from[0].index)
8
- } else {
9
- ""
10
- }
11
- }
@@ -1,8 +0,0 @@
1
- function FindGroup
2
- {
3
- param($groupName, $domain)
4
- if ($domain -eq $null) {$selectionCriteria = " and LocalAccount = true"}
5
- else {$selectionCriteria = " and Domain = '$domain'"}
6
-
7
- Get-WmiObject Win32_Group -filter "Name = '$groupName' $selectionCriteria"
8
- }
@@ -1,7 +0,0 @@
1
- function FindInstalledApplication
2
- {
3
- param($appName, $appVersion)
4
- $selectionCriteria = "(Name like '$appName' or PackageName like '$appName') and InstallState = 5"
5
- if ($appVersion -ne $null) { $selectionCriteria += " and version = '$appVersion'"}
6
- Get-WmiObject Win32_Product -filter $selectionCriteria
7
- }
@@ -1,5 +0,0 @@
1
- function FindService
2
- {
3
- param($name)
4
- Get-WmiObject Win32_Service | Where-Object {$_.Name -eq $name -or $_.DisplayName -eq $name}
5
- }
@@ -1,8 +0,0 @@
1
- function FindUser
2
- {
3
- param($userName, $domain)
4
- if ($domain -eq $null) {$selectionCriteria = " and LocalAccount = true"}
5
- else {$selectionCriteria = " and Domain = '$domain'"}
6
-
7
- Get-WmiObject Win32_UserAccount -filter "Name = '$userName' $selectionCriteria"
8
- }
@@ -1,9 +0,0 @@
1
- function FindUserGroup
2
- {
3
- param($userName, $groupName, $userDomain, $groupDomain)
4
- $user = FindUser -userName $userName -domain $userDomain
5
- $group = FindGroup -groupName $groupName -domain $groupDomain
6
- if ($user -and $group) {
7
- Get-WmiObject Win32_GroupUser -filter ("GroupComponent = 'Win32_Group.Domain=`"" + $group.domain + "`",Name=`"" + $group.name + "`"' and PartComponent = 'Win32_UserAccount.Domain=`"" + $user.domain + "`",Name=`"" + $user.name + "`"'")
8
- }
9
- }
@@ -1,13 +0,0 @@
1
- function IsPortListening
2
- {
3
- param($portNumber, $protocol)
4
- $netstatOutput = netstat -an | Out-String
5
- $networkIPs = (Get-WmiObject Win32_NetworkAdapterConfiguration | ? {$_.IPEnabled}) | %{ $_.IPAddress[0] }
6
- foreach ($ipaddress in $networkIPs)
7
- {
8
- $matchExpression = ("$ipaddress" + ":" + $portNumber)
9
- if ($protocol) { $matchExpression = ($protocol.toUpper() + "\s+$matchExpression") }
10
- if ($netstatOutput -match $matchExpression) { return $true }
11
- }
12
- $false
13
- }
@@ -1,93 +0,0 @@
1
- require 'serverspec/backend/exec'
2
-
3
- module Serverspec
4
- module Backend
5
- class Ssh < Exec
6
- def run_command(cmd, opt={})
7
- cmd = build_command(cmd)
8
- cmd = add_pre_command(cmd)
9
- ret = ssh_exec!(cmd)
10
-
11
- ret[:stdout].gsub!(/\r\n/, "\n")
12
-
13
- if @example
14
- @example.metadata[:command] = cmd
15
- @example.metadata[:stdout] = ret[:stdout]
16
- end
17
-
18
- ret
19
- end
20
-
21
- def build_command(cmd)
22
- cmd = super(cmd)
23
- if RSpec.configuration.ssh.options[:user] != 'root'
24
- cmd = "#{sudo} #{cmd}"
25
- cmd.gsub!(/(\&\&\s*!?\(?\s*)/, "\\1#{sudo} ")
26
- cmd.gsub!(/(\|\|\s*!?\(?\s*)/, "\\1#{sudo} ")
27
- end
28
- cmd
29
- end
30
-
31
- def add_pre_command(cmd)
32
- cmd = super(cmd)
33
- user = RSpec.configuration.ssh.options[:user]
34
- pre_command = Serverspec.configuration.pre_command
35
- if pre_command && user != 'root'
36
- cmd = "#{sudo} #{cmd}"
37
- end
38
- cmd
39
- end
40
-
41
- private
42
- def ssh_exec!(command)
43
- stdout_data = ''
44
- stderr_data = ''
45
- exit_status = nil
46
- exit_signal = nil
47
- pass_prompt = RSpec.configuration.pass_prompt || /^\[sudo\] password for/
48
-
49
- ssh = RSpec.configuration.ssh
50
- ssh.open_channel do |channel|
51
- channel.request_pty do |ch, success|
52
- abort "Could not obtain pty " if !success
53
- end
54
- channel.exec("#{command}") do |ch, success|
55
- abort "FAILED: couldn't execute command (ssh.channel.exec)" if !success
56
- channel.on_data do |ch, data|
57
- if data.match pass_prompt
58
- abort "Please set sudo password by using SUDO_PASSWORD or ASK_SUDO_PASSWORD environment variable" if RSpec.configuration.sudo_password.nil?
59
- channel.send_data "#{RSpec.configuration.sudo_password}\n"
60
- else
61
- stdout_data += data
62
- end
63
- end
64
-
65
- channel.on_extended_data do |ch, type, data|
66
- stderr_data += data
67
- end
68
-
69
- channel.on_request("exit-status") do |ch, data|
70
- exit_status = data.read_long
71
- end
72
-
73
- channel.on_request("exit-signal") do |ch, data|
74
- exit_signal = data.read_long
75
- end
76
- end
77
- end
78
- ssh.loop
79
- { :stdout => stdout_data, :stderr => stderr_data, :exit_status => exit_status, :exit_signal => exit_signal }
80
- end
81
-
82
- def sudo
83
- sudo_path = Serverspec.configuration.sudo_path || RSpec.configuration.sudo_path
84
- if sudo_path
85
- "#{sudo_path}/sudo"
86
- else
87
- 'sudo'
88
- end
89
- end
90
-
91
- end
92
- end
93
- end
@@ -1,26 +0,0 @@
1
- module Serverspec
2
- module Backend
3
- class WinRM < Base
4
- include PowerShell::ScriptHelper
5
-
6
- def run_command(cmd, opts={})
7
- script = create_script(cmd)
8
- winrm = RSpec.configuration.winrm
9
-
10
- result = winrm.powershell(script)
11
- stdout, stderr = [:stdout, :stderr].map do |s|
12
- result[:data].select {|item| item.key? s}.map {|item| item[s]}.join
13
- end
14
- result[:exitcode] = 1 if result[:exitcode] == 0 and !stderr.empty?
15
-
16
- if @example
17
- @example.metadata[:command] = script
18
- @example.metadata[:stdout] = stdout + stderr
19
- end
20
-
21
- { :stdout => stdout, :stderr => stderr,
22
- :exit_status => result[:exitcode], :exit_signal => nil }
23
- end
24
- end
25
- end
26
- end
@@ -1,12 +0,0 @@
1
- module Serverspec
2
- module Configuration
3
- class << self
4
- VALID_OPTIONS_KEYS = [:path, :pre_command, :stdout, :stderr, :sudo_path, :pass_prompt].freeze
5
- attr_accessor(*VALID_OPTIONS_KEYS)
6
-
7
- def defaults
8
- VALID_OPTIONS_KEYS.inject({}) { |o, k| o.merge!(k => send(k)) }
9
- end
10
- end
11
- end
12
- end
@@ -1,9 +0,0 @@
1
- module Serverspec
2
- module Helper
3
- module AIX
4
- def commands
5
- Serverspec::Commands::AIX.new
6
- end
7
- end
8
- end
9
- end
@@ -1,16 +0,0 @@
1
- require 'serverspec/attributes'
2
-
3
- module Serverspec
4
- module Helper
5
- module Attributes
6
- def attr
7
- puts "Warning: attr method will be obsoleted. Please use property method instead."
8
- Serverspec::Attributes.instance.attributes
9
- end
10
- def attr_set(attr)
11
- puts "Warning: attr_set method will be obsoleted. Please use set_property method instead."
12
- Serverspec::Attributes.instance.attributes(attr)
13
- end
14
- end
15
- end
16
- end
@@ -1,9 +0,0 @@
1
- module Serverspec
2
- module Helper
3
- module Base
4
- def commands
5
- Serverspec::Commands::Base.new
6
- end
7
- end
8
- end
9
- end
@@ -1,15 +0,0 @@
1
- module Serverspec
2
- module Helper
3
- module Cmd
4
- def backend(commands_object=nil)
5
- if ! respond_to?(:commands)
6
- commands_object = Serverspec::Commands::Windows.new
7
- end
8
- instance = Serverspec::Backend::Cmd.instance
9
- instance.set_commands(commands_object || commands)
10
- instance
11
- end
12
- end
13
- end
14
- end
15
-
@@ -1,37 +0,0 @@
1
- module Serverspec
2
- module Helper
3
- module Configuration
4
- def subject
5
- example.metadata[:subject] = described_class
6
- build_configurations
7
- super
8
- end
9
-
10
- # You can create a set of configurations provided to all specs in your spec_helper:
11
- #
12
- # RSpec.configure { |c| c.pre_command = "source ~/.zshrc" }
13
- #
14
- # Any configurations you provide with `let(:option_name)` in a spec will
15
- # automatically be merged on top of the configurations.
16
- #
17
- # @example
18
- #
19
- # describe 'Gem' do
20
- # let(:pre_command) { "source ~/.zshrc" }
21
- #
22
- # %w(pry awesome_print bundler).each do |p|
23
- # describe package(p) do
24
- # it { should be_installed.by('gem') }
25
- # end
26
- # end
27
- # end
28
- def build_configurations
29
- Serverspec::Configuration.defaults.keys.each do |c|
30
- value = self.respond_to?(c.to_sym) ?
31
- self.send(c) : RSpec.configuration.send(c)
32
- Serverspec::Configuration.send(:"#{c}=", value)
33
- end
34
- end
35
- end
36
- end
37
- end