serverspec-cem-acpt 2.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. checksums.yaml +7 -0
  2. data/.github/stale.yml +18 -0
  3. data/.gitignore +28 -0
  4. data/.gitmodules +3 -0
  5. data/.travis.yml +25 -0
  6. data/Gemfile +9 -0
  7. data/Guardfile +4 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +36 -0
  10. data/Rakefile +31 -0
  11. data/WINDOWS_SUPPORT.md +131 -0
  12. data/appveyor.yml +70 -0
  13. data/bin/serverspec-init +7 -0
  14. data/lib/serverspec/commands/base.rb +7 -0
  15. data/lib/serverspec/helper/type.rb +25 -0
  16. data/lib/serverspec/helper.rb +8 -0
  17. data/lib/serverspec/matcher/be_enabled.rb +24 -0
  18. data/lib/serverspec/matcher/be_enforcing.rb +10 -0
  19. data/lib/serverspec/matcher/be_executable.rb +13 -0
  20. data/lib/serverspec/matcher/be_installed.rb +24 -0
  21. data/lib/serverspec/matcher/be_listening.rb +20 -0
  22. data/lib/serverspec/matcher/be_monitored_by.rb +17 -0
  23. data/lib/serverspec/matcher/be_mounted.rb +15 -0
  24. data/lib/serverspec/matcher/be_permissive.rb +10 -0
  25. data/lib/serverspec/matcher/be_reachable.rb +17 -0
  26. data/lib/serverspec/matcher/be_readable.rb +13 -0
  27. data/lib/serverspec/matcher/be_resolvable.rb +9 -0
  28. data/lib/serverspec/matcher/be_running.rb +19 -0
  29. data/lib/serverspec/matcher/be_writable.rb +13 -0
  30. data/lib/serverspec/matcher/belong_to_group.rb +5 -0
  31. data/lib/serverspec/matcher/belong_to_primary_group.rb +5 -0
  32. data/lib/serverspec/matcher/contain.rb +28 -0
  33. data/lib/serverspec/matcher/have_entry.rb +14 -0
  34. data/lib/serverspec/matcher/have_rule.rb +25 -0
  35. data/lib/serverspec/matcher/have_site_application.rb +18 -0
  36. data/lib/serverspec/matcher/have_site_bindings.rb +22 -0
  37. data/lib/serverspec/matcher/have_virtual_dir.rb +14 -0
  38. data/lib/serverspec/matcher.rb +40 -0
  39. data/lib/serverspec/power_assert.rb +14 -0
  40. data/lib/serverspec/setup.rb +351 -0
  41. data/lib/serverspec/subject.rb +12 -0
  42. data/lib/serverspec/type/base.rb +31 -0
  43. data/lib/serverspec/type/bond.rb +11 -0
  44. data/lib/serverspec/type/bridge.rb +11 -0
  45. data/lib/serverspec/type/cgroup.rb +17 -0
  46. data/lib/serverspec/type/command.rb +31 -0
  47. data/lib/serverspec/type/cron.rb +15 -0
  48. data/lib/serverspec/type/default_gateway.rb +15 -0
  49. data/lib/serverspec/type/docker_base.rb +27 -0
  50. data/lib/serverspec/type/docker_container.rb +27 -0
  51. data/lib/serverspec/type/docker_image.rb +4 -0
  52. data/lib/serverspec/type/file.rb +161 -0
  53. data/lib/serverspec/type/fstab.rb +11 -0
  54. data/lib/serverspec/type/group.rb +15 -0
  55. data/lib/serverspec/type/hadoop_config.rb +27 -0
  56. data/lib/serverspec/type/host.rb +21 -0
  57. data/lib/serverspec/type/iis_app_pool.rb +43 -0
  58. data/lib/serverspec/type/iis_website.rb +40 -0
  59. data/lib/serverspec/type/interface.rb +47 -0
  60. data/lib/serverspec/type/ip6tables.rb +13 -0
  61. data/lib/serverspec/type/ipfilter.rb +11 -0
  62. data/lib/serverspec/type/ipnat.rb +11 -0
  63. data/lib/serverspec/type/iptables.rb +11 -0
  64. data/lib/serverspec/type/json_file.rb +9 -0
  65. data/lib/serverspec/type/kernel_module.rb +7 -0
  66. data/lib/serverspec/type/kvm.rb +19 -0
  67. data/lib/serverspec/type/linux_audit_system.rb +45 -0
  68. data/lib/serverspec/type/linux_kernel_parameter.rb +10 -0
  69. data/lib/serverspec/type/lxc.rb +15 -0
  70. data/lib/serverspec/type/mail_alias.rb +7 -0
  71. data/lib/serverspec/type/mysql_config.rb +10 -0
  72. data/lib/serverspec/type/package.rb +66 -0
  73. data/lib/serverspec/type/php_config.rb +12 -0
  74. data/lib/serverspec/type/php_extension.rb +11 -0
  75. data/lib/serverspec/type/port.rb +40 -0
  76. data/lib/serverspec/type/ppa.rb +11 -0
  77. data/lib/serverspec/type/process.rb +31 -0
  78. data/lib/serverspec/type/routing_table.rb +11 -0
  79. data/lib/serverspec/type/selinux.rb +19 -0
  80. data/lib/serverspec/type/selinux_module.rb +15 -0
  81. data/lib/serverspec/type/service.rb +57 -0
  82. data/lib/serverspec/type/user.rb +47 -0
  83. data/lib/serverspec/type/windows_feature.rb +7 -0
  84. data/lib/serverspec/type/windows_firewall.rb +28 -0
  85. data/lib/serverspec/type/windows_hot_fix.rb +7 -0
  86. data/lib/serverspec/type/windows_registry_key.rb +19 -0
  87. data/lib/serverspec/type/windows_scheduled_task.rb +7 -0
  88. data/lib/serverspec/type/x509_certificate.rb +92 -0
  89. data/lib/serverspec/type/x509_private_key.rb +20 -0
  90. data/lib/serverspec/type/yumrepo.rb +11 -0
  91. data/lib/serverspec/type/zfs.rb +29 -0
  92. data/lib/serverspec/version.rb +3 -0
  93. data/lib/serverspec.rb +61 -0
  94. data/serverspec.gemspec +27 -0
  95. data/spec/helper/type_spec.rb +6 -0
  96. data/spec/spec_helper.rb +28 -0
  97. data/spec/type/aix/file_spec.rb +27 -0
  98. data/spec/type/aix/group_spec.rb +7 -0
  99. data/spec/type/aix/package_spec.rb +7 -0
  100. data/spec/type/aix/port_spec.rb +20 -0
  101. data/spec/type/aix/service_spec.rb +12 -0
  102. data/spec/type/aix/user_spec.rb +16 -0
  103. data/spec/type/arch/file_spec.rb +15 -0
  104. data/spec/type/arch/package_spec.rb +19 -0
  105. data/spec/type/arch/service_spec.rb +9 -0
  106. data/spec/type/base/command_spec.rb +106 -0
  107. data/spec/type/base/cron_spec.rb +11 -0
  108. data/spec/type/base/default_gateway_spec.rb +11 -0
  109. data/spec/type/base/file_spec.rb +418 -0
  110. data/spec/type/base/group_spec.rb +16 -0
  111. data/spec/type/base/host_spec.rb +47 -0
  112. data/spec/type/base/json_file_spec.rb +27 -0
  113. data/spec/type/base/mail_alias_spec.rb +7 -0
  114. data/spec/type/base/mysql_config_spec.rb +13 -0
  115. data/spec/type/base/package_spec.rb +51 -0
  116. data/spec/type/base/php_config_spec.rb +37 -0
  117. data/spec/type/base/php_extension_spec.rb +13 -0
  118. data/spec/type/base/port_spec.rb +34 -0
  119. data/spec/type/base/process_spec.rb +35 -0
  120. data/spec/type/base/routing_table_spec.rb +63 -0
  121. data/spec/type/base/service_spec.rb +54 -0
  122. data/spec/type/base/user_spec.rb +49 -0
  123. data/spec/type/darwin/file_spec.rb +41 -0
  124. data/spec/type/darwin/package_spec.rb +19 -0
  125. data/spec/type/darwin/port_spec.rb +27 -0
  126. data/spec/type/darwin/service_spec.rb +16 -0
  127. data/spec/type/debian/package_spec.rb +23 -0
  128. data/spec/type/debian/service_spec.rb +11 -0
  129. data/spec/type/fedora/service_spec.rb +15 -0
  130. data/spec/type/fedora15/service_spec.rb +15 -0
  131. data/spec/type/fedora20/service_spec.rb +15 -0
  132. data/spec/type/freebsd/file_spec.rb +29 -0
  133. data/spec/type/freebsd/package_spec.rb +19 -0
  134. data/spec/type/freebsd/port_spec.rb +27 -0
  135. data/spec/type/freebsd/service_spec.rb +8 -0
  136. data/spec/type/freebsd10/package_spec.rb +19 -0
  137. data/spec/type/gentoo/package_spec.rb +7 -0
  138. data/spec/type/gentoo/service_spec.rb +12 -0
  139. data/spec/type/linux/bond_spec.rb +12 -0
  140. data/spec/type/linux/bridge_spec.rb +12 -0
  141. data/spec/type/linux/cgroup_spec.rb +13 -0
  142. data/spec/type/linux/docker_container_pre_1_8_spec.rb +124 -0
  143. data/spec/type/linux/docker_container_spec.rb +131 -0
  144. data/spec/type/linux/docker_image_spec.rb +94 -0
  145. data/spec/type/linux/file_spec.rb +27 -0
  146. data/spec/type/linux/fstab_spec.rb +31 -0
  147. data/spec/type/linux/interface_spec.rb +50 -0
  148. data/spec/type/linux/ip6tables_spec.rb +19 -0
  149. data/spec/type/linux/iptables_spec.rb +11 -0
  150. data/spec/type/linux/kernel_module_spec.rb +7 -0
  151. data/spec/type/linux/kvm_guest_spec.rb +15 -0
  152. data/spec/type/linux/linux_audit_system_spec.rb +139 -0
  153. data/spec/type/linux/linux_kernel_parameter_spec.rb +33 -0
  154. data/spec/type/linux/lxc_container_spec.rb +12 -0
  155. data/spec/type/linux/selinux_module_spec.rb +15 -0
  156. data/spec/type/linux/selinux_spec.rb +23 -0
  157. data/spec/type/linux/x509_certificate_spec.rb +100 -0
  158. data/spec/type/linux/x509_private_key_spec.rb +31 -0
  159. data/spec/type/linux/zfs_spec.rb +15 -0
  160. data/spec/type/nixos/package_spec.rb +15 -0
  161. data/spec/type/nixos/service_spec.rb +9 -0
  162. data/spec/type/openbsd/file_spec.rb +134 -0
  163. data/spec/type/openbsd/interface_spec.rb +31 -0
  164. data/spec/type/openbsd/mail_alias_spec.rb +7 -0
  165. data/spec/type/openbsd/package_spec.rb +11 -0
  166. data/spec/type/openbsd/port_spec.rb +7 -0
  167. data/spec/type/openbsd/service_spec.rb +13 -0
  168. data/spec/type/openbsd/user_spec.rb +12 -0
  169. data/spec/type/opensuse/service_spec.rb +16 -0
  170. data/spec/type/plamo/package_spec.rb +8 -0
  171. data/spec/type/plamo/service_spec.rb +8 -0
  172. data/spec/type/redhat/file_spec.rb +19 -0
  173. data/spec/type/redhat/package_spec.rb +23 -0
  174. data/spec/type/redhat/service_spec.rb +11 -0
  175. data/spec/type/redhat/yumrepo_spec.rb +11 -0
  176. data/spec/type/redhat5/iptables_spec.rb +11 -0
  177. data/spec/type/redhat7/service_spec.rb +9 -0
  178. data/spec/type/smartos/package_spec.rb +19 -0
  179. data/spec/type/smartos/service_spec.rb +16 -0
  180. data/spec/type/solaris/cron_spec.rb +11 -0
  181. data/spec/type/solaris/file_spec.rb +15 -0
  182. data/spec/type/solaris/group_spec.rb +7 -0
  183. data/spec/type/solaris/host_spec.rb +19 -0
  184. data/spec/type/solaris/ipfilter_spec.rb +7 -0
  185. data/spec/type/solaris/ipnat_spec.rb +7 -0
  186. data/spec/type/solaris/package_spec.rb +7 -0
  187. data/spec/type/solaris/port_spec.rb +34 -0
  188. data/spec/type/solaris/service_spec.rb +16 -0
  189. data/spec/type/solaris/user_spec.rb +16 -0
  190. data/spec/type/solaris/zfs_spec.rb +15 -0
  191. data/spec/type/solaris10/file_spec.rb +313 -0
  192. data/spec/type/solaris10/group_spec.rb +8 -0
  193. data/spec/type/solaris10/host_spec.rb +16 -0
  194. data/spec/type/solaris10/package_spec.rb +8 -0
  195. data/spec/type/solaris10/user_spec.rb +8 -0
  196. data/spec/type/suse/package_spec.rb +23 -0
  197. data/spec/type/suse/service_spec.rb +11 -0
  198. data/spec/type/ubuntu/ppa_spec.rb +11 -0
  199. data/spec/type/ubuntu/service_spec.rb +7 -0
  200. data/spec/type/windows/command_spec.rb +64 -0
  201. data/spec/type/windows/feature_spec.rb +17 -0
  202. data/spec/type/windows/file_spec.rb +127 -0
  203. data/spec/type/windows/group_spec.rb +23 -0
  204. data/spec/type/windows/host_spec.rb +32 -0
  205. data/spec/type/windows/hot_fix_spec.rb +22 -0
  206. data/spec/type/windows/iis_app_pool_spec.rb +17 -0
  207. data/spec/type/windows/iis_webisite_spec.rb +16 -0
  208. data/spec/type/windows/package_spec.rb +10 -0
  209. data/spec/type/windows/port_spec.rb +25 -0
  210. data/spec/type/windows/registry_key_spec.rb +58 -0
  211. data/spec/type/windows/scheduled_task_spec.rb +9 -0
  212. data/spec/type/windows/service_spec.rb +30 -0
  213. data/spec/type/windows/user_spec.rb +33 -0
  214. data/wercker.yml +13 -0
  215. metadata +446 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: b24229071011ded982d183c702a5b9f8cacffeb34205aa9bcbdf5f85b487a121
4
+ data.tar.gz: 999ea0fd5855dedb6621709b78508219dbaa11667ff1db4baa671513e6653b34
5
+ SHA512:
6
+ metadata.gz: eb1ff001e25f1797ee58cade7108dc37fbfb285c9d47aa25133d7739051d15d06a12a911171ea51fe5ad07900fb5916edb6541b392cf66f14bea877aa3d2da51
7
+ data.tar.gz: d7ab9c8ca457f56aee8488a8c168fe42e38992f1e486ebdc94f4eaf27e00a9153be8d7d37facdd3f12c2189594232030b2c748f5fbcd519790dc57806c1c33e5
data/.github/stale.yml ADDED
@@ -0,0 +1,18 @@
1
+ # Number of days of inactivity before an issue becomes stale
2
+ daysUntilStale: 60
3
+ # Number of days of inactivity before a stale issue is closed
4
+ daysUntilClose: 7
5
+ # Issues with these labels will never be considered stale
6
+ exemptLabels:
7
+ - pinned
8
+ - security
9
+ # Label to use when marking an issue as stale
10
+ staleLabel: wontfix
11
+ # Comment to post when marking an issue as stale. Set to `false` to disable
12
+ markComment: >
13
+ This issue has been automatically marked as stale because it has not had
14
+ recent activity. It will be closed if no further activity occurs. Thank you
15
+ for your contributions.
16
+ # Comment to post when closing a stale issue. Set to `false` to disable
17
+ closeComment: false
18
+
data/.gitignore ADDED
@@ -0,0 +1,28 @@
1
+ *.gem
2
+ *.rbc
3
+ *.swp
4
+ .bundle
5
+ .rvmrc
6
+ .versions.conf
7
+ .config
8
+ .yardoc
9
+ .rspec
10
+ .idea/
11
+ Gemfile.lock
12
+ InstalledFiles
13
+ _yardoc
14
+ coverage
15
+ doc/
16
+ lib/bundler/man
17
+ pkg
18
+ rdoc
19
+ spec/reports
20
+ test/tmp
21
+ test/version_tmp
22
+ tmp
23
+ Vagrantfile
24
+ vendor/
25
+ .DS_Store
26
+ Gemfile.local
27
+ upstream.sh
28
+
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "integration-test"]
2
+ path = integration-test
3
+ url = https://github.com/serverspec/serverspec-integration-test.git
data/.travis.yml ADDED
@@ -0,0 +1,25 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.1
7
+ - 2.2.4
8
+ - 2.3.6
9
+ - 2.4.3
10
+ - 2.5.0
11
+
12
+ before_install:
13
+ - travis_retry gem update --system 2.7.8
14
+ - travis_retry gem install bundler -v 1.17.3
15
+ - travis_retry gem uninstall -i /home/travis/.rvm/gems/ruby-2.3.7@global bundler || echo
16
+
17
+ script:
18
+ - bundle exec rake spec
19
+
20
+ dist: trusty
21
+ sudo: false
22
+ cache: bundler
23
+ notifications:
24
+ slack:
25
+ secure: X1umGErES0zd+LXX1EqZZxrPZv2YOzbCNxiLLiSGmJLlZAEtlSkMPyr+M00Lrs2DFhn4blwKPm+5YCBvU7f9F4K5GthSl0qZYNpNX/lGNn6EGeBnzJ8rFVgwXPUv1rvrJq0NjeSGni3yAK69K/uX6QohGojAI3iI28/EbJ+uYQM=
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in serverspec.gemspec
4
+ gemspec
5
+
6
+ if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
7
+ # net-ssh 3.x dropped Ruby 1.8 and 1.9 support.
8
+ gem 'net-ssh', '~> 2.7'
9
+ end
data/Guardfile ADDED
@@ -0,0 +1,4 @@
1
+ guard :rspec do
2
+ watch(%r{^spec/.+/.+_spec\.rb$})
3
+ watch('spec/spec_helper.rb') { "spec" }
4
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Gosuke Miyashita
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Serverspec [![Gem Version](https://badge.fury.io/rb/serverspec.svg)](http://badge.fury.io/rb/serverspec) [![BuildStatus](https://secure.travis-ci.org/mizzy/serverspec.svg)](http://travis-ci.org/mizzy/serverspec) [![wercker status](https://app.wercker.com/status/526d1ff4df6eadaa793dca1affcaed35/s/ "wercker status")](https://app.wercker.com/project/bykey/526d1ff4df6eadaa793dca1affcaed35)
2
+
3
+ RSpec tests for your servers configured by Puppet, Chef or anything else
4
+
5
+ You can see the details of serverspec on [serverspec.org](http://serverspec.org/).
6
+
7
+ ----
8
+
9
+ ## Running the gem's tests
10
+
11
+ Use
12
+
13
+ ```bundle exec rake```
14
+
15
+ (Using ```rspec``` alone will not work).
16
+
17
+
18
+
19
+ ## Maintenance policy of Serverspec/Specinfra
20
+
21
+ * The person who found a bug should fix the bug by themself.
22
+ * If you find a bug and cannot fix it by yourself, send a pull request and attach test code to reproduce the bug, please.
23
+ * The person who want a new feature should implement it by themself.
24
+ * For above reasons, I accept pull requests only and disable issues.
25
+ * If you'd like to discuss about a new feature before implement it, make an empty commit and send [a WIP pull request](http://ben.straub.cc/2015/04/02/wip-pull-request/). But It is better that the WIP PR has some code than an empty commit.
26
+
27
+
28
+ ----
29
+
30
+ ## Contributing
31
+
32
+ 1. Fork it
33
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
34
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
35
+ 4. Push to the branch (`git push origin my-new-feature`)
36
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,31 @@
1
+ require "bundler/gem_tasks"
2
+ begin
3
+ require "rspec/core/rake_task"
4
+ require "octorelease"
5
+ rescue LoadError
6
+ end
7
+
8
+ if defined?(RSpec)
9
+ task :default => 'spec:all'
10
+ task :spec => 'spec:all'
11
+
12
+ namespace :spec do
13
+ task :all => [ 'spec:type:all', 'spec:helper' ]
14
+
15
+ namespace :type do
16
+ oses = Dir.glob('spec/type/*').map {|d| File.basename(d)}
17
+
18
+ task :all => oses.map {|os| "spec:type:#{os}" }
19
+
20
+ oses.each do |os|
21
+ RSpec::Core::RakeTask.new(os.to_sym) do |t|
22
+ t.pattern = "spec/type/#{os}/*_spec.rb"
23
+ end
24
+ end
25
+ end
26
+
27
+ RSpec::Core::RakeTask.new(:helper) do |t|
28
+ t.pattern = "spec/helper/*_spec.rb"
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,131 @@
1
+ ## Windows support
2
+
3
+ Serverspec is now providing a limited support for Microsoft Windows.
4
+
5
+ If you want to test Windows based machines you need to set the target host's OS explicitly in your `spec/spec_helper.rb`
6
+
7
+ For local testing (equivalent to the Exec option in Linux/Unix systems) simply do:
8
+
9
+ ```ruby
10
+ require 'serverspec'
11
+
12
+ set :backend, :cmd
13
+ set :os, :family => 'windows'
14
+ ```
15
+
16
+ For remote testing you have to configure Windows Remote Management in order to communicate to the target host:
17
+
18
+ ```ruby
19
+ require 'serverspec'
20
+ require 'winrm'
21
+
22
+ set :backend, :winrm
23
+ set :os, :family => 'windows'
24
+
25
+ user = <username>
26
+ pass = <password>
27
+ endpoint = "http://#{ENV['TARGET_HOST']}:5985/wsman"
28
+
29
+ if Gem::Version.new(WinRM::VERSION) < Gem::Version.new('2')
30
+ winrm = ::WinRM::WinRMWebService.new(endpoint, :ssl, :user => user, :pass => pass, :basic_auth_only => true)
31
+ winrm.set_timeout 300 # 5 minutes max timeout for any operation
32
+ else
33
+ opts = {
34
+ user: user,
35
+ password: pass,
36
+ endpoint: endpoint,
37
+ operation_timeout: 300,
38
+ no_ssl_peer_verification: false,
39
+ }
40
+
41
+ winrm = ::WinRM::Connection.new(opts)
42
+ end
43
+
44
+ Specinfra.configuration.winrm = winrm
45
+ ```
46
+
47
+ For how to configure the guest to accept WinRM connections and the different authentication mechanisms check the Microsoft WinRM documentation and verify the ones that are supported by [WinRb/WinRM](https://github.com/WinRb/WinRM).
48
+
49
+
50
+ ###RSpec Examples for windows target hosts
51
+ ```ruby
52
+ describe file('c:/windows') do
53
+ it { should be_directory }
54
+ it { should be_readable }
55
+ it { should_not be_writable.by('Everyone') }
56
+ end
57
+
58
+ describe file('c:/temp/test.txt') do
59
+ it { should be_file }
60
+ it { should contain "some text" }
61
+ end
62
+
63
+ describe package('Adobe AIR') do
64
+ it { should be_installed}
65
+ end
66
+
67
+ describe service('DNS Client') do
68
+ it { should be_installed }
69
+ it { should be_enabled }
70
+ it { should be_running }
71
+ it { should have_start_mode("Manual") }
72
+ end
73
+
74
+ describe port(139) do
75
+ it { should be_listening }
76
+ end
77
+
78
+ describe user('some.admin') do
79
+ it { should exist }
80
+ it { should belong_to_group('Administrators')}
81
+ end
82
+
83
+ describe group('Guests') do
84
+ it { should exist }
85
+ end
86
+
87
+ describe group('MYDOMAIN\Domain Users') do
88
+ it { should exist }
89
+ end
90
+
91
+ describe command('& "ipconfig"') do
92
+ its(:stdout) { should match /IPv4 Address(\.| )*: 192\.168\.1\.100/ }
93
+ end
94
+
95
+ describe windows_registry_key('HKEY_USERS\S-1-5-21-1319311448-2088773778-316617838-32407\Test MyKey') do
96
+ it { should exist }
97
+ it { should have_property('string value') }
98
+ it { should have_property('binary value', :type_binary) }
99
+ it { should have_property('dword value', :type_dword) }
100
+ it { should have_value('test default data') }
101
+ it { should have_property_value('multistring value', :type_multistring, "test\nmulti\nstring\ndata") }
102
+ it { should have_property_value('qword value', :type_qword, 'adff32') }
103
+ it { should have_property_value('binary value', :type_binary, 'dfa0f066') }
104
+ end
105
+
106
+ describe windows_feature('Minesweeper') do
107
+ it{ should be_installed }
108
+ it{ should be_installed.by("dism") }
109
+ it{ should be_installed.by("powershell") }
110
+ end
111
+
112
+ describe iis_website("Default Website") do
113
+ it { should exist }
114
+ it { should be_enabled }
115
+ it { should be_running }
116
+ it { should be_in_app_pool "DefaultAppPool" }
117
+ it { should have_physical_path "c:/inetpub/wwwroot" }
118
+ end
119
+
120
+ describe iis_app_pool("DefaultAppPool") do
121
+ it { should exist }
122
+ it { should have_dotnet_version "2.0" }
123
+ end
124
+
125
+ ```
126
+
127
+ ###Notes:
128
+ * Not all the matchers you are used to in Linux-like OS are supported in Windows, some because of differences between the operating systems (e.g. users and permissions model), some because they haven't been yet implemented.
129
+ * All commands in the windows backend are run via powershell, so the output in case of stderr is a pretty ugly xml-like thing. Still it should contain some information to help troubleshooting.
130
+ * The *command* type is executed again through powershell, so bear that in mind if you mean to run old CMD windows batch or programs. (i.e run the command using the **Invoke-Expression** Cmdlet, or the **&** Call Operator)
131
+ * You may have to change Exectution Policy on the machine at both, machine and user level in order for tests to run: Get-ExecutionPolicy -list|%{set-executionpolicy bypass -scope $_.scope}
data/appveyor.yml ADDED
@@ -0,0 +1,70 @@
1
+ version: "{build}"
2
+ image: Previous Visual Studio 2015
3
+
4
+ platform:
5
+ - x64
6
+
7
+ environment:
8
+ bundle_gemfile: integration-test/Gemfile.winrm
9
+ bundler_url: https://rubygems.org/downloads/bundler-1.9.9.gem
10
+
11
+ matrix:
12
+ - ruby_version: "193"
13
+ - ruby_version: "200"
14
+ - ruby_version: "21"
15
+ - ruby_version: "22"
16
+ - ruby_version: "23"
17
+ - ruby_version: "24"
18
+ - ruby_version: "25"
19
+ - ruby_version: "26"
20
+
21
+ matrix:
22
+ allow_failures:
23
+ - ruby_version: "193"
24
+
25
+ clone_depth: 5
26
+
27
+ cache:
28
+ - C:\Ruby193\lib\ruby\gems\1.9.1 -> appveyor.yml
29
+ - C:\Ruby193\bin -> appveyor.yml
30
+ - C:\Ruby200\lib\ruby\gems\2.0.0 -> appveyor.yml
31
+ - C:\Ruby200\bin -> appveyor.yml
32
+ - C:\Ruby21\lib\ruby\gems\2.1.0 -> appveyor.yml
33
+ - C:\Ruby21\bin -> appveyor.yml
34
+ - C:\Ruby22\lib\ruby\gems\2.2.0 -> appveyor.yml
35
+ - C:\Ruby22\bin -> appveyor.yml
36
+ - C:\Ruby23\lib\ruby\gems\2.2.0 -> appveyor.yml
37
+ - C:\Ruby23\bin -> appveyor.yml
38
+ - C:\Ruby24\lib\ruby\gems\2.4.0 -> appveyor.yml
39
+ - C:\Ruby24\bin -> appveyor.yml
40
+ - C:\Ruby25\lib\ruby\gems\2.5.0 -> appveyor.yml
41
+ - C:\Ruby25\bin -> appveyor.yml
42
+ - C:\Ruby26\lib\ruby\gems\2.6.0 -> appveyor.yml
43
+ - C:\Ruby26\bin
44
+
45
+ install:
46
+ - git submodule update --init --recursive
47
+ - ps: Enable-PSRemoting -Force
48
+ - winrm quickconfig -q
49
+ - winrm set winrm/config/client @{TrustedHosts="*"}
50
+ - winrm set winrm/config/client/auth @{Basic="true"}
51
+ - winrm set winrm/config/service/auth @{Basic="true"}
52
+ - winrm set winrm/config/service @{AllowUnencrypted="true"}
53
+ - SET PATH=C:\Ruby%ruby_version%\bin;%PATH%
54
+ - echo %PATH%
55
+ - ruby --version
56
+ - gem --version
57
+ - appveyor DownloadFile -Url %bundler_url% -FileName bundler.gem
58
+ - gem install --local bundler.gem --no-document --force ## appveyor often stops `gem install bundler`..?
59
+ - ps: $PSVersionTable
60
+
61
+ build_script:
62
+ - set SSL_CERT_FILE=C:/ruby24-x64/ssl/cert.pem
63
+ - ruby -rfileutils -e 'FileUtils.rm_r(File.join(Gem.dir, "cache", "bundler")) if Dir.exists?(File.join(Gem.dir, "cache", "bundler"))'
64
+ - bundle install --jobs 3 --retry 3
65
+ - net user
66
+ - net localgroup
67
+
68
+ test_script:
69
+ - net user appveyor %WINDOWS_PASSWORD% # set by webui
70
+ - bundle exec rspec -fd --backtrace -r .\integration-test\winrm\spec_helper.rb .\integration-test\winrm
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
4
+
5
+ require 'serverspec'
6
+
7
+ Serverspec::Setup.run
@@ -0,0 +1,7 @@
1
+ module Serverspec
2
+ module Commands
3
+ class Base < Specinfra::Command::Base
4
+ end
5
+ end
6
+ end
7
+
@@ -0,0 +1,25 @@
1
+ module Serverspec
2
+ module Helper
3
+ module Type
4
+ types = %w(
5
+ base bridge bond cgroup command cron default_gateway file fstab
6
+ group host iis_website iis_app_pool interface ipfilter ipnat
7
+ iptables ip6tables json_file kernel_module kvm linux_kernel_parameter lxc
8
+ mail_alias mysql_config package php_config port ppa process
9
+ routing_table selinux selinux_module service user yumrepo
10
+ windows_feature windows_hot_fix windows_registry_key
11
+ windows_scheduled_task zfs docker_base docker_image
12
+ docker_container x509_certificate x509_private_key
13
+ linux_audit_system hadoop_config php_extension windows_firewall
14
+ )
15
+
16
+ types.each {|type| require "serverspec/type/#{type}" }
17
+
18
+ types.each do |type|
19
+ define_method type do |*args|
20
+ eval "Serverspec::Type::#{type.to_camel_case}.new(*args)"
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,8 @@
1
+ # Subject type helper
2
+ require 'serverspec/helper/type'
3
+ extend Serverspec::Helper::Type
4
+ class RSpec::Core::ExampleGroup
5
+ extend Serverspec::Helper::Type
6
+ include Serverspec::Helper::Type
7
+ end
8
+
@@ -0,0 +1,24 @@
1
+ RSpec::Matchers.define :be_enabled do
2
+ match do |subject|
3
+ if subject.class.name == 'Serverspec::Type::Service'
4
+ subject.enabled?(@level, @under)
5
+ else
6
+ subject.enabled?
7
+ end
8
+ end
9
+
10
+ description do
11
+ message = 'be enabled'
12
+ message << " under #{@under}" if @under
13
+ message << " with level #{@level}" if @level
14
+ message
15
+ end
16
+
17
+ chain :with_level do |level|
18
+ @level = level
19
+ end
20
+
21
+ chain :under do |under|
22
+ @under = under
23
+ end
24
+ end
@@ -0,0 +1,10 @@
1
+ RSpec::Matchers.define :be_enforcing do
2
+ match do |selinux|
3
+ selinux.enforcing?(@with_policy)
4
+ end
5
+
6
+ chain :with_policy do |with_policy|
7
+ @with_policy = with_policy
8
+ end
9
+
10
+ end
@@ -0,0 +1,13 @@
1
+ RSpec::Matchers.define :be_executable do
2
+ match do |file|
3
+ file.executable?(@by_whom, @by_user)
4
+ end
5
+
6
+ chain :by do |by_whom|
7
+ @by_whom = by_whom
8
+ end
9
+
10
+ chain :by_user do |by_user|
11
+ @by_user = by_user
12
+ end
13
+ end
@@ -0,0 +1,24 @@
1
+ RSpec::Matchers.define :be_installed do
2
+ match do |subject|
3
+ if subject.class.name == 'Serverspec::Type::SelinuxModule'
4
+ subject.installed?(@version)
5
+ else
6
+ subject.installed?(@provider, @version)
7
+ end
8
+ end
9
+
10
+ description do
11
+ message = 'be installed'
12
+ message << %( by "#{@provider}") if @provider
13
+ message << %( with version "#{@version}") if @version
14
+ message
15
+ end
16
+
17
+ chain :by do |provider|
18
+ @provider = provider
19
+ end
20
+
21
+ chain :with_version do |version|
22
+ @version = version
23
+ end
24
+ end
@@ -0,0 +1,20 @@
1
+ RSpec::Matchers.define :be_listening do
2
+ match do |port|
3
+ port.listening? @with, @local_address
4
+ end
5
+
6
+ description do
7
+ message = 'be listening'
8
+ message << " on #{@local_address}" if @local_address
9
+ message << " with #{@with}" if @with
10
+ message
11
+ end
12
+
13
+ chain :with do |with|
14
+ @with = with
15
+ end
16
+
17
+ chain :on do |local_address|
18
+ @local_address = local_address
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ RSpec::Matchers.define :be_monitored_by do |monitor|
2
+ match do |service|
3
+ service.monitored_by?(monitor, @monitor_name)
4
+ end
5
+ description do
6
+ if @monitor_name
7
+ "be monitored by #{monitor} with name #{@monitor_name}"
8
+ else
9
+ "be monitored by #{monitor}"
10
+ end
11
+ end
12
+
13
+ chain :with_name do |name|
14
+ @monitor_name = (name ? name : nil)
15
+ end
16
+
17
+ end
@@ -0,0 +1,15 @@
1
+ RSpec::Matchers.define :be_mounted do
2
+ match do |path|
3
+ path.mounted?(@attr, @only_with)
4
+ end
5
+
6
+ chain :with do |attr|
7
+ @attr = attr
8
+ @only_with = false
9
+ end
10
+
11
+ chain :only_with do |attr|
12
+ @attr = attr
13
+ @only_with = true
14
+ end
15
+ end
@@ -0,0 +1,10 @@
1
+ RSpec::Matchers.define :be_permissive do
2
+ match do |selinux|
3
+ selinux.permissive?(@with_policy)
4
+ end
5
+
6
+ chain :with_policy do |with_policy|
7
+ @with_policy = with_policy
8
+ end
9
+
10
+ end
@@ -0,0 +1,17 @@
1
+ RSpec::Matchers.define :be_reachable do
2
+ match do |host|
3
+ proto = 'tcp'
4
+ timeout = 5
5
+ if @attr
6
+ port = @attr[:port]
7
+ proto = @attr[:proto] if @attr[:proto]
8
+ timeout = @attr[:timeout] if @attr[:timeout]
9
+ end
10
+
11
+ host.reachable?(port, proto, timeout)
12
+ end
13
+
14
+ chain :with do |attr|
15
+ @attr = attr
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ RSpec::Matchers.define :be_readable do
2
+ match do |file|
3
+ file.readable?(@by_whom, @by_user)
4
+ end
5
+
6
+ chain :by do |by_whom|
7
+ @by_whom = by_whom
8
+ end
9
+
10
+ chain :by_user do |by_user|
11
+ @by_user = by_user
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ RSpec::Matchers.define :be_resolvable do
2
+ match do |name|
3
+ name.resolvable?(@type)
4
+ end
5
+
6
+ chain :by do |type|
7
+ @type = type
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ RSpec::Matchers.define :be_running do
2
+ match do |subject|
3
+ if subject.class.name == 'Serverspec::Type::Service'
4
+ subject.running?(@under)
5
+ else
6
+ subject.running?
7
+ end
8
+ end
9
+
10
+ description do
11
+ message = 'be running'
12
+ message << " under #{@under}" if @under
13
+ message
14
+ end
15
+
16
+ chain :under do |under|
17
+ @under = under
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ RSpec::Matchers.define :be_writable do
2
+ match do |file|
3
+ file.writable?(@by_whom, @by_user)
4
+ end
5
+
6
+ chain :by do |by_whom|
7
+ @by_whom = by_whom
8
+ end
9
+
10
+ chain :by_user do |by_user|
11
+ @by_user = by_user
12
+ end
13
+ end