serverspec-cem-acpt 2.42.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/stale.yml +18 -0
- data/.gitignore +28 -0
- data/.gitmodules +3 -0
- data/.travis.yml +25 -0
- data/Gemfile +9 -0
- data/Guardfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +36 -0
- data/Rakefile +31 -0
- data/WINDOWS_SUPPORT.md +131 -0
- data/appveyor.yml +70 -0
- data/bin/serverspec-init +7 -0
- data/lib/serverspec/commands/base.rb +7 -0
- data/lib/serverspec/helper/type.rb +25 -0
- data/lib/serverspec/helper.rb +8 -0
- data/lib/serverspec/matcher/be_enabled.rb +24 -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 +24 -0
- data/lib/serverspec/matcher/be_listening.rb +20 -0
- data/lib/serverspec/matcher/be_monitored_by.rb +17 -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 +19 -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 +25 -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/matcher.rb +40 -0
- data/lib/serverspec/power_assert.rb +14 -0
- data/lib/serverspec/setup.rb +351 -0
- data/lib/serverspec/subject.rb +12 -0
- data/lib/serverspec/type/base.rb +31 -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 +31 -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 +27 -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 +161 -0
- data/lib/serverspec/type/fstab.rb +11 -0
- data/lib/serverspec/type/group.rb +15 -0
- data/lib/serverspec/type/hadoop_config.rb +27 -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 +47 -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/json_file.rb +9 -0
- data/lib/serverspec/type/kernel_module.rb +7 -0
- data/lib/serverspec/type/kvm.rb +19 -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 +12 -0
- data/lib/serverspec/type/php_extension.rb +11 -0
- data/lib/serverspec/type/port.rb +40 -0
- data/lib/serverspec/type/ppa.rb +11 -0
- data/lib/serverspec/type/process.rb +31 -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 +15 -0
- data/lib/serverspec/type/service.rb +57 -0
- data/lib/serverspec/type/user.rb +47 -0
- data/lib/serverspec/type/windows_feature.rb +7 -0
- data/lib/serverspec/type/windows_firewall.rb +28 -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 +92 -0
- data/lib/serverspec/type/x509_private_key.rb +20 -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/lib/serverspec.rb +61 -0
- data/serverspec.gemspec +27 -0
- data/spec/helper/type_spec.rb +6 -0
- data/spec/spec_helper.rb +28 -0
- data/spec/type/aix/file_spec.rb +27 -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 +106 -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 +418 -0
- data/spec/type/base/group_spec.rb +16 -0
- data/spec/type/base/host_spec.rb +47 -0
- data/spec/type/base/json_file_spec.rb +27 -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 +37 -0
- data/spec/type/base/php_extension_spec.rb +13 -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 +54 -0
- data/spec/type/base/user_spec.rb +49 -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 +131 -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 +50 -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/kvm_guest_spec.rb +15 -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 +15 -0
- data/spec/type/linux/selinux_spec.rb +23 -0
- data/spec/type/linux/x509_certificate_spec.rb +100 -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 +31 -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 +127 -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 +13 -0
- 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
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
data/Guardfile
ADDED
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
|
data/WINDOWS_SUPPORT.md
ADDED
@@ -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
|
data/bin/serverspec-init
ADDED
@@ -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,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,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,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,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
|