Skip to content

Commit

Permalink
Rspec updates, puppet 4.x (#6)
Browse files Browse the repository at this point in the history
* improved rspec tests
* fixed - pe requirement is no longer supported by the Forge
* formatting fixes for lint test
* additional rspec expected results for more coverage
* meta updated for next release and added puppet 4.x support
  • Loading branch information
BIAndrews authored May 13, 2017
1 parent fcf94a6 commit b52399c
Show file tree
Hide file tree
Showing 9 changed files with 263 additions and 66 deletions.
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--format documentation
--color
58 changes: 36 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,45 @@
---
sudo: false
language: ruby
bundler_args: --without development system_tests
before_install: rm Gemfile.lock || true
before_install:
- rm Gemfile.lock || true
- gem update bundler
rvm:
- 1.9.3
- 2.0.0
- 2.1.4
script: rake
- 2.1.5
- 2.3.1
script: bundle exec rake test
env:
- PUPPET_VERSION=3.1.1
- PUPPET_VERSION=3.2.4
- PUPPET_VERSION=3.3.2
- PUPPET_VERSION=3.4.3
- PUPPET_VERSION=3.6.2
- PUPPET_VERSION=3.7.3 FUTURE_PARSER="no"
- PUPPET_VERSION=3.8.1 FUTURE_PARSER="no"
- PUPPET_GEM_VERSION="~> 3.3.0"
- PUPPET_GEM_VERSION="~> 3.4.0"
- PUPPET_GEM_VERSION="~> 3.5.0"
- PUPPET_GEM_VERSION="~> 3.6.0"
- PUPPET_GEM_VERSION="~> 3.7.0"
- PUPPET_GEM_VERSION="~> 3.8.0" FUTURE_PARSER=yes
- PUPPET_GEM_VERSION="~> 4.1.0"
- PUPPET_GEM_VERSION="~> 4.2.0"
- PUPPET_GEM_VERSION="~> 4.3.0"
- PUPPET_GEM_VERSION="~> 4.4.0"
- PUPPET_GEM_VERSION="~> 4.5.0"
- PUPPET_GEM_VERSION="~> 4.6.0"
- PUPPET_GEM_VERSION="~> 4.7.0"
- PUPPET_GEM_VERSION="~> 4.8.0" FUTURE_PARSER=yes
matrix:
allow_failures:
- rvm: ruby-head
- env: PUPPET_VERSION=3.7.3
exclude:
- rvm: 2.0.0
env: PUPPET_VERSION=3.1.1
- rvm: 2.1.4
env: PUPPET_VERSION=3.1.1
- rvm: 2.1.4
env: PUPPET_VERSION=3.2.4
- rvm: 2.1.4
env: PUPPET_VERSION=3.3.2
fast_finish: true
exclude:
- rvm: 2.1.5
env: PUPPET_GEM_VERSION="~> 3.3.0"
- rvm: 2.3.1
env: PUPPET_GEM_VERSION="~> 3.3.0"
- rvm: 2.3.1
env: PUPPET_GEM_VERSION="~> 3.4.0"
- rvm: 2.3.1
env: PUPPET_GEM_VERSION="~> 3.5.0"
- rvm: 2.3.1
env: PUPPET_GEM_VERSION="~> 3.6.0"
- rvm: 2.3.1
env: PUPPET_GEM_VERSION="~> 3.7.0"
- rvm: 2.3.1
env: PUPPET_GEM_VERSION="~> 3.8.0" FUTURE_PARSER=yes
44 changes: 34 additions & 10 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,37 @@
source 'https://rubygems.org'
source ENV['GEM_SOURCE'] || "https://rubygems.org"

if ENV.key?('PUPPET_VERSION')
puppetversion = "= #{ENV['PUPPET_VERSION']}"
else
puppetversion = ['>= 2.7']
group :test do
gem 'rake', '< 11.0'
gem "puppet", ENV['PUPPET_GEM_VERSION'] || '~> 4.2.3'
gem "rspec", '< 3.2.0'
gem "rspec-puppet"
gem "puppetlabs_spec_helper"
gem "metadata-json-lint"
gem "rspec-puppet-facts"
gem 'rubocop', '0.33.0'
gem 'simplecov', '>= 0.11.0'
gem 'simplecov-console', '< 0.4.0'

gem "puppet-lint-absolute_classname-check"
gem "puppet-lint-leading_zero-check"
gem "puppet-lint-trailing_comma-check"
gem "puppet-lint-version_comparison-check"
gem "puppet-lint-classes_and_types_beginning_with_digits-check"
gem "puppet-lint-unquoted_string-check"
gem 'puppet-lint-resource_reference_syntax'

gem 'json_pure', '<= 2.0.1' if RUBY_VERSION < '2.0.0'
end

gem 'rake'
gem 'puppet-lint'
gem 'rspec-puppet'
gem 'puppetlabs_spec_helper'
gem 'puppet', puppetversion
group :development do
gem "travis" if RUBY_VERSION >= '2.1.0'
gem "travis-lint" if RUBY_VERSION >= '2.1.0'
gem "puppet-blacksmith"
gem "guard-rake" if RUBY_VERSION >= '2.2.5' # per dependency https://rubygems.org/gems/ruby_dep
end

group :system_tests do
gem "beaker", '< 3.0.0'
gem "beaker-rspec"
gem "beaker-puppet_install_helper"
end
61 changes: 60 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,64 @@
require 'rubygems'
require 'bundler/setup'

require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet/version'
require 'puppet/vendor/semantic/lib/semantic' unless Puppet.version.to_f < 3.6
require 'puppet-lint/tasks/puppet-lint'
require 'puppet-syntax/tasks/puppet-syntax'
require 'metadata-json-lint/rake_task'
require 'rubocop/rake_task'

# These gems aren't always present, for instance
# on Travis with --without development
begin
require 'puppet_blacksmith/rake_tasks'
rescue LoadError # rubocop:disable Lint/HandleExceptions
end

RuboCop::RakeTask.new

exclude_paths = [
"bundle/**/*",
"pkg/**/*",
"vendor/**/*",
"spec/**/*"
]

# Coverage from puppetlabs-spec-helper requires rcov which
# doesn't work in anything since 1.8.7
#Rake::Task[:coverage].clear

Rake::Task[:lint].clear

PuppetLint.configuration.relative = true
PuppetLint.configuration.disable_80chars
PuppetLint.configuration.disable_class_inherits_from_params_class
PuppetLint.configuration.disable_class_parameter_defaults
PuppetLint.configuration.fail_on_warnings = true

PuppetLint::RakeTask.new :lint do |config|
config.ignore_paths = exclude_paths
end

PuppetSyntax.exclude_paths = exclude_paths

desc "Run acceptance tests"
RSpec::Core::RakeTask.new(:acceptance) do |t|
t.pattern = 'spec/acceptance'
end

desc "Populate CONTRIBUTORS file"
task :contributors do
system("git log --format='%aN' | sort -u > CONTRIBUTORS")
end

desc "Run syntax, lint, and spec tests."
task :test => [
:metadata_lint,
:syntax,
:lint,
#:rubocop,
:spec
]

task :default => [:spec, :lint]
4 changes: 2 additions & 2 deletions examples/init.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include osquery

class { 'osquery':
class { '::osquery':
settings => {
'options' => {
'event_pubsub_expiry' => '86000',
Expand All @@ -13,6 +13,6 @@
'interval' => '3600',
},
},
}
},
}

5 changes: 1 addition & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@
validate_hash($settings)
validate_bool($repo_install)

class { '::osquery::install': } ->
class { '::osquery::config': } ~>
class { '::osquery::service': } ->
Class['::osquery']
class { '::osquery::install': } -> class { '::osquery::config': } ~> class { '::osquery::service': } -> Class['::osquery']
}
2 changes: 1 addition & 1 deletion manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
$repo_key_server = 'keyserver.ubuntu.com'
}
default: {
fail("${::operatingsystem} not supported")
fail("Unsupported platform: ${::operatingsystem}")
}
}

Expand Down
8 changes: 4 additions & 4 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bryana-osquery",
"version": "0.1.3",
"version": "0.1.4",
"author": "Bryan Andrews",
"summary": "OSQuery Puppet module",
"license": "Apache-2.0",
Expand All @@ -13,12 +13,12 @@
"tags": ["osquery","security","compliance","pci-dss","audit"],
"requirements": [
{
"name": "pe",
"version_requirement": ">= 3.0.0"
"name": "puppet",
"version_requirement": "3.x"
},
{
"name": "puppet",
"version_requirement": "3.x"
"version_requirement": "4.x"
}
],
"operatingsystem_support": [
Expand Down
Loading

0 comments on commit b52399c

Please sign in to comment.