octopus-serverspec-extensions 0.14.0 → 0.15.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 255334ef695527b9f1e8034b9f3240edab17cf50
4
- data.tar.gz: 98d143368b10a8aae5afb96b65a34775983d3c31
2
+ SHA256:
3
+ metadata.gz: ff16256d99e210dad66ed64575efb0d03a76bdc9c056e1058d8f2b5151ccb588
4
+ data.tar.gz: ddbc0b51bf23a7ab2eb9fbaf2a2e1f23ae4eb3170a147149bb42af7bb0419fd0
5
5
  SHA512:
6
- metadata.gz: 544958a7d2d20b38f15e9b42d2ecb68db295c504abcafce0594c1c411d9811c0e6d4b7da5cafed8a8f7347df0ef3310dabee177a276c97e10bc091dba20fb524
7
- data.tar.gz: 2dc1ce341b828e00e22f860c5e93efa8c53a2094c4f71eba68c04618d13ae2a77d22f046246cc80598ed791a18f435744d909db6eef416c72e53cb5313f65cff
6
+ metadata.gz: ebf8555078424e70a55f79b666ac8591de12147ccb1c44cbabcd70986c006d7e82a8242b1840f688552650d740870d18f75c80a4b8529ee02539f100f483fe18
7
+ data.tar.gz: c951a8de41e573639a9b8e54c44c73e6c15be4ef9af774d3481e6aa7ddb123e0ceb046b98c0509308c859e52160b478a23d7b51b766a6b50d481a881f0b07c50
data/.gitignore CHANGED
@@ -1,11 +1,13 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- octopus-serverspec-extensions-*.gem
11
- vendor/
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ octopus-serverspec-extensions-*.gem
11
+ vendor/
12
+ /.idea/
13
+ publish.ps1
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
- --format documentation
2
- --color
1
+ --format documentation
2
+ --color
@@ -1,5 +1,5 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.3.1
5
- before_install: gem install bundler -v 1.13.6
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.13.6
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in octopus-serverspec-extensions.gemspec
4
- gemspec
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in octopus-serverspec-extensions.gemspec
4
+ gemspec
@@ -1,12 +1,12 @@
1
- Copyright (c) Octopus Deploy and contributors. All rights reserved.
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4
- these files except in compliance with the License. You may obtain a copy of the
5
- License at
6
-
7
- http://www.apache.org/licenses/LICENSE-2.0
8
-
9
- Unless required by applicable law or agreed to in writing, software distributed
10
- under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11
- CONDITIONS OF ANY KIND, either express or implied. See the License for the
12
- specific language governing permissions and limitations under the License.
1
+ Copyright (c) Octopus Deploy and contributors. All rights reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4
+ these files except in compliance with the License. You may obtain a copy of the
5
+ License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software distributed
10
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
12
+ specific language governing permissions and limitations under the License.
data/README.md CHANGED
@@ -1,39 +1,39 @@
1
- # Octopus::Serverspec::Extensions
2
-
3
- SeverSpec extensions for Windows, adding support for chocolatey packages, npm packages, service accounts and more.
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'octopus-serverspec-extensions'
11
- ```
12
-
13
- And then execute:
14
-
15
- $ bundle
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install octopus-serverspec-extensions
20
-
21
- ## Usage
22
-
23
- TODO: Write usage instructions here
24
-
25
- ## Development
26
-
27
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
-
29
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
-
31
- ## Contributing
32
-
33
- Bug reports and pull requests are welcome on GitHub at https://github.com/octopus-deploy/octopus-serverspec-extensions.
34
-
35
-
36
- ## License
37
-
38
- The gem is available as open source under the terms of the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0).
39
-
1
+ # Octopus::Serverspec::Extensions
2
+
3
+ SeverSpec extensions for Windows, adding support for chocolatey packages, npm packages, service accounts and more.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'octopus-serverspec-extensions'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install octopus-serverspec-extensions
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/octopus-deploy/octopus-serverspec-extensions.
34
+
35
+
36
+ ## License
37
+
38
+ The gem is available as open source under the terms of the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0).
39
+
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "octopus/serverspec/extensions"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "octopus/serverspec/extensions"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup CHANGED
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -1,13 +1,14 @@
1
- require 'octopus_serverspec_extensions/type/chocolatey_package.rb'
2
- require 'octopus_serverspec_extensions/type/npm_package.rb'
3
- require 'octopus_serverspec_extensions/type/java_property_file.rb'
4
- require 'octopus_serverspec_extensions/type/octopus_deploy_tentacle.rb'
5
- require 'octopus_serverspec_extensions/type/octopus_deploy_environment.rb'
6
- require 'octopus_serverspec_extensions/type/windows_dsc.rb'
7
- require 'octopus_serverspec_extensions/type/windows_firewall.rb'
8
- require 'octopus_serverspec_extensions/type/windows_scheduled_task.rb'
9
- require 'octopus_serverspec_extensions/matcher/have_version.rb'
10
- require 'octopus_serverspec_extensions/matcher/run_under_account.rb'
11
- require 'octopus_serverspec_extensions/matcher/have_windows_line_endings.rb'
12
- require 'octopus_serverspec_extensions/matcher/have_linux_line_endings.rb'
13
- require 'octopus_serverspec_extensions/version.rb'
1
+ require 'octopus_serverspec_extensions/type/chocolatey_package.rb'
2
+ require 'octopus_serverspec_extensions/type/npm_package.rb'
3
+ require 'octopus_serverspec_extensions/type/java_property_file.rb'
4
+ require 'octopus_serverspec_extensions/type/octopus_deploy_tentacle.rb'
5
+ require 'octopus_serverspec_extensions/type/octopus_deploy_environment.rb'
6
+ require 'octopus_serverspec_extensions/type/octopus_deploy_worker_pool.rb'
7
+ require 'octopus_serverspec_extensions/type/windows_dsc.rb'
8
+ require 'octopus_serverspec_extensions/type/windows_firewall.rb'
9
+ require 'octopus_serverspec_extensions/type/windows_scheduled_task.rb'
10
+ require 'octopus_serverspec_extensions/matcher/have_version.rb'
11
+ require 'octopus_serverspec_extensions/matcher/run_under_account.rb'
12
+ require 'octopus_serverspec_extensions/matcher/have_windows_line_endings.rb'
13
+ require 'octopus_serverspec_extensions/matcher/have_linux_line_endings.rb'
14
+ require 'octopus_serverspec_extensions/version.rb'
@@ -1,13 +1,13 @@
1
- RSpec::Matchers.define :have_linux_line_endings do
2
- match do |file|
3
- !file.content.include?("\r\n")
4
- end
5
-
6
- failure_message do |file|
7
- "Expected file '#{file.name}' to have linux line endings, but it didn't"
8
- end
9
-
10
- failure_message_when_negated do |file|
11
- "Expected file '#{file.name}' to not have linux line endings, but it did"
12
- end
13
- end
1
+ RSpec::Matchers.define :have_linux_line_endings do
2
+ match do |file|
3
+ !file.content.include?("\r\n")
4
+ end
5
+
6
+ failure_message do |file|
7
+ "Expected file '#{file.name}' to have linux line endings, but it didn't"
8
+ end
9
+
10
+ failure_message_when_negated do |file|
11
+ "Expected file '#{file.name}' to not have linux line endings, but it did"
12
+ end
13
+ end
@@ -1,36 +1,36 @@
1
- RSpec::Matchers.define :have_version do |version|
2
- match do |file|
3
- get_version(file) == version
4
- end
5
-
6
- failure_message do |file|
7
- "Expected file '#{file.name}' to have version '#{version}' but it had version '#{get_version}' instead"
8
- end
9
-
10
- failure_message_when_negated do |file|
11
- "Expected file '#{file.name}' to not have version '#{version}' but it did"
12
- end
13
-
14
- private
15
- def get_version(file)
16
- version_dll = Fiddle.dlopen('version.dll')
17
-
18
- s=''
19
- vsize = Fiddle::Function.new(version_dll['GetFileVersionInfoSize'],
20
- [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP],
21
- Fiddle::TYPE_LONG).call(file.name, s)
22
-
23
- raise 'Unable to determine the version number' unless vsize > 0
24
-
25
- result = ' '*vsize
26
- Fiddle::Function.new(version_dll['GetFileVersionInfo'],
27
- [Fiddle::TYPE_VOIDP, Fiddle::TYPE_LONG,
28
- Fiddle::TYPE_LONG, Fiddle::TYPE_VOIDP],
29
- Fiddle::TYPE_VOIDP).call(file.name, 0, vsize, result)
30
-
31
- rstring = result.unpack('v*').map{|s| s.chr if s<256}*''
32
- r = /FileVersion..(.*?)\000/.match(rstring)
33
-
34
- r[1]
35
- end
36
- end
1
+ RSpec::Matchers.define :have_version do |version|
2
+ match do |file|
3
+ get_version(file) == version
4
+ end
5
+
6
+ failure_message do |file|
7
+ "Expected file '#{file.name}' to have version '#{version}' but it had version '#{get_version}' instead"
8
+ end
9
+
10
+ failure_message_when_negated do |file|
11
+ "Expected file '#{file.name}' to not have version '#{version}' but it did"
12
+ end
13
+
14
+ private
15
+ def get_version(file)
16
+ version_dll = Fiddle.dlopen('version.dll')
17
+
18
+ s=''
19
+ vsize = Fiddle::Function.new(version_dll['GetFileVersionInfoSize'],
20
+ [Fiddle::TYPE_VOIDP, Fiddle::TYPE_VOIDP],
21
+ Fiddle::TYPE_LONG).call(file.name, s)
22
+
23
+ raise 'Unable to determine the version number' unless vsize > 0
24
+
25
+ result = ' '*vsize
26
+ Fiddle::Function.new(version_dll['GetFileVersionInfo'],
27
+ [Fiddle::TYPE_VOIDP, Fiddle::TYPE_LONG,
28
+ Fiddle::TYPE_LONG, Fiddle::TYPE_VOIDP],
29
+ Fiddle::TYPE_VOIDP).call(file.name, 0, vsize, result)
30
+
31
+ rstring = result.unpack('v*').map{|s| s.chr if s<256}*''
32
+ r = /FileVersion..(.*?)\000/.match(rstring)
33
+
34
+ r[1]
35
+ end
36
+ end
@@ -1,13 +1,13 @@
1
- RSpec::Matchers.define :have_windows_line_endings do
2
- match do |file|
3
- file.content.include?("\r\n")
4
- end
5
-
6
- failure_message do |file|
7
- "Expected file '#{file.name}' to have windows line endings, but it didn't"
8
- end
9
-
10
- failure_message_when_negated do |file|
11
- "Expected file '#{file.name}' to not have windows line endings, but it did"
12
- end
13
- end
1
+ RSpec::Matchers.define :have_windows_line_endings do
2
+ match do |file|
3
+ file.content.include?("\r\n")
4
+ end
5
+
6
+ failure_message do |file|
7
+ "Expected file '#{file.name}' to have windows line endings, but it didn't"
8
+ end
9
+
10
+ failure_message_when_negated do |file|
11
+ "Expected file '#{file.name}' to not have windows line endings, but it did"
12
+ end
13
+ end
@@ -1,17 +1,17 @@
1
- RSpec::Matchers.define :run_under_account do |account_name|
2
- match do |service|
3
- @runner = Specinfra::Runner
4
- command_result = @runner.run_command("$ProgressPreference = 'SilentlyContinue'; (Get-WmiObject Win32_Service | Where-Object {$_.Name -eq '#{service.name}'}).StartName -eq '#{account_name}'")
5
- command_result.stdout.strip == 'True'
6
- end
7
-
8
- failure_message do |service|
9
- command_result = @runner.run_command("$ProgressPreference = 'SilentlyContinue'; (Get-WmiObject Win32_Service | Where-Object {$_.Name -eq '#{service.name}'}).StartName")
10
- "Expected service '#{service.name}' to be running under '#{account_name}' but was running under '#{command_result.stdout.strip}'"
11
- end
12
-
13
- failure_message_when_negated do |service|
14
- command_result = @runner.run_command("$ProgressPreference = 'SilentlyContinue'; (Get-WmiObject Win32_Service | Where-Object {$_.Name -eq '#{service.name}'}).StartName")
15
- "Expected service '#{service.name}' to not be running under '#{account_name}' but was running under '#{command_result.stdout.strip}'"
16
- end
17
- end
1
+ RSpec::Matchers.define :run_under_account do |account_name|
2
+ match do |service|
3
+ @runner = Specinfra::Runner
4
+ command_result = @runner.run_command("$ProgressPreference = 'SilentlyContinue'; (Get-WmiObject Win32_Service | Where-Object {$_.Name -eq '#{service.name}'}).StartName -eq '#{account_name}'")
5
+ command_result.stdout.strip == 'True'
6
+ end
7
+
8
+ failure_message do |service|
9
+ command_result = @runner.run_command("$ProgressPreference = 'SilentlyContinue'; (Get-WmiObject Win32_Service | Where-Object {$_.Name -eq '#{service.name}'}).StartName")
10
+ "Expected service '#{service.name}' to be running under '#{account_name}' but was running under '#{command_result.stdout.strip}'"
11
+ end
12
+
13
+ failure_message_when_negated do |service|
14
+ command_result = @runner.run_command("$ProgressPreference = 'SilentlyContinue'; (Get-WmiObject Win32_Service | Where-Object {$_.Name -eq '#{service.name}'}).StartName")
15
+ "Expected service '#{service.name}' to not be running under '#{account_name}' but was running under '#{command_result.stdout.strip}'"
16
+ end
17
+ end
@@ -1,34 +1,34 @@
1
- require 'serverspec'
2
- require 'serverspec/type/base'
3
-
4
- module Serverspec::Type
5
- class ChocolateyPackage < Base
6
-
7
- def initialize(name)
8
- @name = name
9
- @runner = Specinfra::Runner
10
- end
11
-
12
- def installed?(provider, version)
13
- command_result = @runner.run_command("choco list -l -r #{name}")
14
-
15
- software = command_result.stdout.gsub("\r\n", "\n").split("\n").each_with_object({}) do |s, h|
16
- v, k = s.split('|')
17
- h[String(v).strip.downcase] = String(k).strip.downcase
18
- h
19
- end
20
-
21
- if (version.nil?)
22
- !software[name.downcase].nil?
23
- else
24
- software[name.downcase] == version
25
- end
26
- end
27
- end
28
-
29
- def chocolatey_package(name)
30
- ChocolateyPackage.new(name)
31
- end
32
- end
33
-
1
+ require 'serverspec'
2
+ require 'serverspec/type/base'
3
+
4
+ module Serverspec::Type
5
+ class ChocolateyPackage < Base
6
+
7
+ def initialize(name)
8
+ @name = name
9
+ @runner = Specinfra::Runner
10
+ end
11
+
12
+ def installed?(provider, version)
13
+ command_result = @runner.run_command("choco list -l -r #{name}")
14
+
15
+ software = command_result.stdout.gsub("\r\n", "\n").split("\n").each_with_object({}) do |s, h|
16
+ v, k = s.split('|')
17
+ h[String(v).strip.downcase] = String(k).strip.downcase
18
+ h
19
+ end
20
+
21
+ if (version.nil?)
22
+ !software[name.downcase].nil?
23
+ else
24
+ software[name.downcase] == version
25
+ end
26
+ end
27
+ end
28
+
29
+ def chocolatey_package(name)
30
+ ChocolateyPackage.new(name)
31
+ end
32
+ end
33
+
34
34
  include Serverspec::Type