diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..19a7c04 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,89 @@ +# Python CircleCI 2.0 configuration file +# +# Check https://circleci.com/docs/2.0/language-ruby/ for more details +version: 2 + +references: + machine-defaults: &environment-defaults + machine: true + install-augeas: &install-augeas + run: + name: Install Augeas + command: | + sudo apt-get update && sudo apt-get install -y libaugeas-dev libxml2-dev libgmp3-dev + install-rvm: &install-rvm + run: + name: Install RVM + command: | + gpg --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB + \curl -sSL https://get.rvm.io | bash -s stable + intall-ruby: &intall-ruby + run: + name: Install Ruby + shell: /bin/bash -leo pipefail + command: | + rvm use $RUBY_VERSION --default + gem install bundler --no-rdoc --no-ri + restore-cache-dependencies: &restore-cache-dependencies + # Download and cache dependencies + restore_cache: + keys: + - v1-dependencies-{{ checksum "Gemfile.lock" }} + save-cache-dependencies: &save-cache-dependencies + save_cache: + paths: + - ./vendor/bundle + key: v1-dependencies-{{ checksum "Gemfile.lock" }} + bundle-dependencies: &bundle-dependencies + run: + name: Fetch dependencies via Bundler + shell: /bin/bash -leo pipefail + command: | + rvm use $RUBY_VERSION + bundle install --jobs=4 --retry=3 --path vendor/bundle + beaker: &beaker + run: + name: Run integration tests using Beaker + shell: /bin/bash -leo pipefail + command: | + rvm use $RUBY_VERSION + bundle exec rake beaker + + steps: &steps + steps: + - checkout + - *install-augeas + - *install-rvm + - *intall-ruby + - *restore-cache-dependencies + - *bundle-dependencies + - *save-cache-dependencies + - *beaker + +workflows: + version: 2 + integration-tests: + jobs: + - centos-6 + - debian-8 + - ubuntu-1404 + +jobs: + centos-6: + <<: *environment-defaults + <<: *steps + environment: + RUBY_VERSION: '2.1' + RS_SET: centos-6-docker + debian-8: + <<: *environment-defaults + <<: *steps + environment: + RUBY_VERSION: '2.1' + RS_SET: debian-8-docker + ubuntu-1404: + <<: *environment-defaults + <<: *steps + environment: + RUBY_VERSION: '2.1' + RS_SET: ubuntu-1404-docker diff --git a/.editorconfig b/.editorconfig index eb67838..5f8702c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -3,9 +3,10 @@ # top-most EditorConfig file root = true -# Unix-style newlines with a newline ending every file, indent by 2 spaces +# Unix-style newlines with a newline ending every file [*] end_of_line = lf insert_final_newline = true +charset = utf-8 indent_style = space indent_size = 2 diff --git a/.gitignore b/.gitignore index be75e51..9dbcad3 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,3 @@ Vagrantfile .DS_Store Gemfile.local .idea/ -Gemfile.lock diff --git a/.rspec b/.rspec index 210a1d6..7e703cb 100644 --- a/.rspec +++ b/.rspec @@ -1,2 +1,3 @@ --format documentation ---color \ No newline at end of file +--color +--backtrace diff --git a/.rubocop.ruby-1.8.7.yml b/.rubocop.ruby-1.8.7.yml index 207d68a..d4f992e 100644 --- a/.rubocop.ruby-1.8.7.yml +++ b/.rubocop.ruby-1.8.7.yml @@ -1,5 +1,6 @@ +inherit_from: .rubocop_todo.yml # Ruby 1.8.7 needs the . on chain of method calls at the end of a line -Style/DotPosition: +Layout/DotPosition: EnforcedStyle: trailing # Ruby 1.8.7 doesn't have the -> lambda @@ -10,11 +11,9 @@ Style/Lambda: Style/HashSyntax: EnforcedStyle: hash_rockets -Style/StringLiterals: +Style/BracesAroundHashParameters: Enabled: false -Style/Documentation: - Enabled: false - -Metrics/LineLength: - Max: 140 +Layout/AlignHash: + EnforcedHashRocketStyle: table + EnforcedColonStyle: table diff --git a/.rubocop.yml b/.rubocop.yml index bd54733..b776043 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,28 @@ +inherit_from: .rubocop.ruby-1.8.7.yml AllCops: + TargetRubyVersion: 1.9 + Include: + - gemfiles/Gemfile* Exclude: - - 'vendor/**/*' - + - vendor/**/* + - .vendor/**/* + - pkg/**/* + - spec/fixtures/**/* + - gemfiles/Gemfile*.lock Metrics/LineLength: - Max: 140 + # Max: 140 # Commented out to pass rubocop todo analysis + Max: 400 +Style/FileName: + Exclude: + - 'Gemfile' + - 'Rakefile' +Metrics/BlockLength: + Exclude: + - spec/**/* +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: native, lf, crlf +Layout/EndOfLine: + EnforcedStyle: lf + +Style/ClassAndModuleChildren: + Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 0000000..d4cad16 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,773 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2018-06-25 21:25:04 +0200 using RuboCop version 0.49.1. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 13 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedHashRocketStyle, SupportedHashRocketStyles, EnforcedColonStyle, SupportedColonStyles, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/AlignHash: + Exclude: + - 'lib/puppet/provider/jboss_resourceadapter/jbosscli.rb' + - 'lib/puppet_x/coi/jboss/internal/cli_executor.rb' + - 'lib/puppet_x/coi/jboss/internal/securitydomain_auditor.rb' + - 'lib/puppet_x/coi/jboss/provider/abstract_jboss_cli.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. +# SupportedStyles: with_first_parameter, with_fixed_indentation +Layout/AlignParameters: + Exclude: + - 'lib/puppet/provider/jboss_confignode/jbosscli.rb' + - 'lib/puppet/provider/jboss_datasource/jbosscli.rb' + - 'lib/puppet/provider/jboss_deploy/jbosscli.rb' + - 'lib/puppet/provider/jboss_jdbcdriver/jbosscli.rb' + - 'lib/puppet/provider/jboss_jmsqueue/jbosscli.rb' + - 'lib/puppet/provider/jboss_resourceadapter/jbosscli.rb' + - 'lib/puppet/provider/jboss_securitydomain/jbosscli.rb' + +# Offense count: 14 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, IndentOneStep, IndentationWidth. +# SupportedStyles: case, end +Layout/CaseIndentation: + Exclude: + - 'lib/puppet_x/coi/jboss/functions/jboss_to_bool.rb' + - 'lib/puppet_x/coi/jboss/provider/confignode.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + +# Offense count: 11 +# Cop supports --auto-correct. +# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines. +Layout/EmptyLineBetweenDefs: + Exclude: + - 'lib/puppet/type/jboss_jmsqueue.rb' + - 'lib/puppet_x/coi/jboss/buildins_utils.rb' + - 'lib/puppet_x/coi/jboss/internal/securitydomain_auditor.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +Layout/EmptyLines: + Exclude: + - 'lib/puppet/type/jboss_confignode.rb' + - 'lib/puppet/type/jboss_deploy.rb' + - 'lib/puppet_x/coi/jboss/internal/securitydomain_auditor.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/EmptyLinesAroundAccessModifier: + Exclude: + - 'lib/puppet_x/coi/jboss/factsrefresher.rb' + +# Offense count: 12 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: empty_lines, no_empty_lines +Layout/EmptyLinesAroundBlockBody: + Exclude: + - 'lib/puppet/provider/jboss_datasource/jbosscli.rb' + - 'lib/puppet/provider/jboss_resourceadapter/jbosscli.rb' + - 'lib/puppet/type/jboss_confignode.rb' + - 'lib/puppet/type/jboss_datasource.rb' + - 'lib/puppet/type/jboss_deploy.rb' + - 'lib/puppet/type/jboss_jdbcdriver.rb' + - 'lib/puppet/type/jboss_jmsqueue.rb' + - 'lib/puppet/type/jboss_resourceadapter.rb' + - 'lib/puppet/type/jboss_securitydomain.rb' + +# Offense count: 15 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines +Layout/EmptyLinesAroundClassBody: + Exclude: + - 'lib/puppet_x/coi/jboss/configuration.rb' + - 'lib/puppet_x/coi/jboss/factsrefresher.rb' + - 'lib/puppet_x/coi/jboss/functions/jboss_basename.rb' + - 'lib/puppet_x/coi/jboss/functions/jboss_dirname.rb' + - 'lib/puppet_x/coi/jboss/functions/jboss_short_version.rb' + - 'lib/puppet_x/coi/jboss/functions/jboss_to_bool.rb' + - 'lib/puppet_x/coi/jboss/functions/jboss_to_i.rb' + - 'lib/puppet_x/coi/jboss/functions/jboss_to_s.rb' + - 'lib/puppet_x/coi/jboss/functions/jboss_type_version.rb' + - 'lib/puppet_x/coi/jboss/internal/execution_state_wrapper.rb' + - 'lib/puppet_x/coi/jboss/internal/logic_creator.rb' + - 'lib/puppet_x/coi/jboss/internal/state/securitydomain_state.rb' + - 'lib/puppet_x/coi/jboss/provider/abstract_jboss_cli.rb' + - 'lib/puppet_x/coi/jboss/provider/securitydomain/abstract_provider.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/EmptyLinesAroundExceptionHandlingKeywords: + Exclude: + - 'lib/puppet_x/coi/jboss/internal/cli_executor.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines +Layout/EmptyLinesAroundModuleBody: + Exclude: + - 'lib/puppet_x/coi/jboss/provider/confignode.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource/static.rb' + - 'lib/puppet_x/coi/jboss/provider/deploy.rb' + - 'lib/puppet_x/coi/jboss/provider/jdbcdriver.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +# Configuration parameters: Width, IgnoredPatterns. +Layout/IndentationWidth: + Exclude: + - 'lib/puppet/provider/jboss_resourceadapter/jbosscli.rb' + - 'lib/puppet_x/coi/jboss/configuration.rb' + - 'lib/puppet_x/coi/jboss/provider/abstract_jboss_cli.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + - 'lib/puppet_x/coi/jboss/provider/jdbcdriver.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: symmetrical, new_line, same_line +Layout/MultilineMethodCallBraceLayout: + Exclude: + - 'lib/puppet_x/coi/jboss/internal/securitydomain_auditor.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. +# SupportedStyles: aligned, indented +Layout/MultilineOperationIndentation: + Exclude: + - 'lib/puppet_x/coi/jboss/provider/securitydomain/post_wildfly_provider.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Layout/SpaceAfterComma: + Exclude: + - 'lib/puppet/provider/jboss_resourceadapter/jbosscli.rb' + - 'lib/puppet_x/coi/jboss.rb' + - 'lib/puppet_x/coi/jboss/configuration.rb' + - 'lib/puppet_x/coi/jboss/provider/confignode.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleInsidePipes, SupportedStylesInsidePipes. +# SupportedStylesInsidePipes: space, no_space +Layout/SpaceAroundBlockParameters: + Exclude: + - 'lib/puppet_x/coi/jboss/internal/sanitizer.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: space, no_space +Layout/SpaceAroundEqualsInParameterDefault: + Exclude: + - 'lib/puppet_x/coi/jboss/provider/abstract_jboss_cli.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Layout/SpaceAroundKeyword: + Exclude: + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + - 'lib/puppet_x/coi/jboss/provider/jdbcdriver.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces, SpaceBeforeBlockParameters. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideBlockBraces: + Exclude: + - 'lib/puppet_x/coi/jboss/facts.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Layout/SpaceInsideBrackets: + Exclude: + - 'lib/puppet_x/coi/jboss/provider/confignode.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Layout/SpaceInsideParens: + Exclude: + - 'lib/puppet_x/coi/jboss/configuration.rb' + +# Offense count: 17 +# Cop supports --auto-correct. +Layout/TrailingWhitespace: + Exclude: + - 'lib/puppet/type/jboss_jdbcdriver.rb' + - 'lib/puppet/type/jboss_resourceadapter.rb' + - 'lib/puppet/type/jboss_securitydomain.rb' + - 'lib/puppet_x/coi/jboss/internal/cli_executor.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleAlignWith, SupportedStylesAlignWith, AutoCorrect. +# SupportedStylesAlignWith: keyword, variable, start_of_line +Lint/EndAlignment: + Exclude: + - 'lib/puppet_x/coi/jboss/functions/jboss_to_bool.rb' + +# Offense count: 1 +Lint/Loop: + Exclude: + - 'lib/puppet_x/coi/jboss/internal/cli_executor.rb' + +# Offense count: 1 +Lint/RescueException: + Exclude: + - 'lib/puppet_x/coi/jboss/internal/cli_executor.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +Lint/StringConversionInInterpolation: + Exclude: + - 'lib/puppet_x/coi/jboss/provider/abstract_jboss_cli.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. +Lint/UnusedBlockArgument: + Exclude: + - 'lib/puppet/provider/jboss_resourceadapter/jbosscli.rb' + - 'lib/puppet_x/coi/jboss/provider/confignode.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods. +Lint/UnusedMethodArgument: + Exclude: + - 'lib/puppet/type/jboss_datasource.rb' + - 'lib/puppet_x/coi/jboss/internal/cli_executor.rb' + - 'lib/puppet_x/coi/jboss/provider/securitydomain/abstract_provider.rb' + +# Offense count: 11 +Lint/UselessAssignment: + Exclude: + - 'lib/puppet/provider/jboss_resourceadapter/jbosscli.rb' + - 'lib/puppet_x/coi/jboss.rb' + - 'lib/puppet_x/coi/jboss/factsrefresher.rb' + - 'lib/puppet_x/coi/jboss/internal/cli_executor.rb' + - 'lib/puppet_x/coi/jboss/provider/confignode.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + - 'lib/puppet_x/coi/jboss/provider/deploy.rb' + - 'lib/puppet_x/coi/jboss/provider/securitydomain/abstract_provider.rb' + +# Offense count: 26 +Metrics/AbcSize: + Max: 44 + +# Offense count: 10 +# Configuration parameters: CountComments, ExcludedMethods. +Metrics/BlockLength: + Max: 228 + +# Offense count: 3 +# Configuration parameters: CountComments. +Metrics/ClassLength: + Max: 142 + +# Offense count: 12 +Metrics/CyclomaticComplexity: + Max: 10 + +# Offense count: 7 +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Metrics/LineLength: + Max: 248 + +# Offense count: 44 +# Configuration parameters: CountComments. +Metrics/MethodLength: + Max: 58 + +# Offense count: 2 +# Configuration parameters: CountComments. +Metrics/ModuleLength: + Max: 444 + +# Offense count: 9 +Metrics/PerceivedComplexity: + Max: 13 + +# Offense count: 3 +# Cop supports --auto-correct. +Performance/StringReplacement: + Exclude: + - 'lib/puppet_x/coi/jboss/internal/sanitizer.rb' + +# Offense count: 2 +Security/Eval: + Exclude: + - 'lib/puppet_x/coi/jboss/internal/cli_executor.rb' + - 'spec/unit/facter/jboss_fullconfig_spec.rb' + +# Offense count: 1 +Style/AccessorMethodName: + Exclude: + - 'lib/puppet_x/coi/jboss/provider/jdbcdriver.rb' + +# Offense count: 42 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: always, conditionals +Style/AndOr: + Exclude: + - 'lib/facter/jboss_virtual.rb' + - 'lib/puppet/provider/jboss_resourceadapter/jbosscli.rb' + - 'lib/puppet/type/jboss_confignode.rb' + - 'lib/puppet/type/jboss_datasource.rb' + - 'lib/puppet/type/jboss_deploy.rb' + - 'lib/puppet/type/jboss_jdbcdriver.rb' + - 'lib/puppet/type/jboss_jmsqueue.rb' + - 'lib/puppet/type/jboss_resourceadapter.rb' + - 'lib/puppet/type/jboss_securitydomain.rb' + - 'lib/puppet_x/coi/jboss/buildins_utils.rb' + - 'lib/puppet_x/coi/jboss/configuration.rb' + - 'lib/puppet_x/coi/jboss/internal/cli_executor.rb' + - 'lib/puppet_x/coi/jboss/provider/abstract_jboss_cli.rb' + - 'lib/puppet_x/coi/jboss/provider/confignode.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods. +# SupportedStyles: line_count_based, semantic, braces_for_chaining +# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object +# FunctionalMethods: let, let!, subject, watch +# IgnoredMethods: lambda, proc, it +Style/BlockDelimiters: + Exclude: + - 'lib/puppet_x/coi/jboss/functions/jboss_basename.rb' + - 'lib/puppet_x/coi/jboss/functions/jboss_dirname.rb' + +# Offense count: 36 +Style/ClassAndModuleCamelCase: + Enabled: false + +# Offense count: 2 +Style/ClassVars: + Exclude: + - 'lib/puppet_x/coi/jboss/provider/abstract_jboss_cli.rb' + +# Offense count: 13 +# Cop supports --auto-correct. +Style/ColonMethodCall: + Exclude: + - 'lib/facter/jboss_configfile.rb' + - 'lib/puppet_x/coi/jboss.rb' + - 'lib/puppet_x/coi/jboss/configuration.rb' + - 'lib/puppet_x/coi/jboss/facts.rb' + - 'lib/puppet_x/coi/jboss/factsrefresher.rb' + - 'lib/puppet_x/coi/jboss/provider/abstract_jboss_cli.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + - 'lib/puppet_x/coi/jboss/provider/securitydomain.rb' + +# Offense count: 10 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly, IncludeTernaryExpressions. +# SupportedStyles: assign_to_condition, assign_inside_condition +Style/ConditionalAssignment: + Exclude: + - 'lib/puppet/type/jboss_confignode.rb' + - 'lib/puppet/type/jboss_datasource.rb' + - 'lib/puppet_x/coi/jboss/buildins_utils.rb' + - 'lib/puppet_x/coi/jboss/provider/abstract_jboss_cli.rb' + - 'lib/puppet_x/coi/jboss/provider/confignode.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + - 'lib/puppet_x/coi/jboss/provider/securitydomain.rb' + +# Offense count: 1 +Style/Documentation: + Exclude: + - 'spec/**/*' + - 'test/**/*' + - 'lib/puppet_x/coi/jboss/factsrefresher.rb' + +# Offense count: 2 +Style/DoubleNegation: + Exclude: + - 'lib/puppet_x/coi/jboss/functions/jboss_to_bool.rb' + - 'lib/puppet_x/coi/jboss/provider/confignode.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/EachWithObject: + Exclude: + - 'lib/facter/jboss_running.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: empty, nil, both +Style/EmptyElse: + Exclude: + - 'lib/puppet_x/coi/jboss/functions/jboss_short_version.rb' + - 'lib/puppet_x/coi/jboss/functions/jboss_type_version.rb' + +# Offense count: 1 +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: for, each +Style/For: + Exclude: + - 'lib/puppet_x/coi/jboss/provider/deploy.rb' + +# Offense count: 11 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: format, sprintf, percent +Style/FormatString: + Exclude: + - 'lib/puppet/provider/jboss_resourceadapter/jbosscli.rb' + - 'lib/puppet_x/coi/jboss/internal/cli_executor.rb' + - 'lib/puppet_x/coi/jboss/provider/abstract_jboss_cli.rb' + - 'lib/puppet_x/coi/jboss/provider/confignode.rb' + - 'lib/puppet_x/coi/jboss/provider/securitydomain/abstract_provider.rb' + +# Offense count: 24 +# Configuration parameters: AllowedVariables. +Style/GlobalVars: + Exclude: + - 'lib/puppet/provider/jboss_resourceadapter/jbosscli.rb' + - 'lib/puppet_x/coi/jboss/internal/cli_executor.rb' + - 'lib/puppet_x/coi/jboss/provider/abstract_jboss_cli.rb' + +# Offense count: 8 +# Configuration parameters: MinBodyLength. +Style/GuardClause: + Exclude: + - 'lib/puppet_x/coi/jboss/facts.rb' + - 'lib/puppet_x/coi/jboss/provider/confignode.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + - 'lib/puppet_x/coi/jboss/provider/securitydomain/pre_wildfly_provider.rb' + +# Offense count: 2 +Style/IdenticalConditionalBranches: + Exclude: + - 'lib/puppet_x/coi/jboss/internal/securitydomain_auditor.rb' + +# Offense count: 40 +# Cop supports --auto-correct. +# Configuration parameters: MaxLineLength. +Style/IfUnlessModifier: + Exclude: + - 'lib/puppet/provider/jboss_resourceadapter/jbosscli.rb' + - 'lib/puppet_x/coi/jboss/buildins_utils.rb' + - 'lib/puppet_x/coi/jboss/functions/jboss_to_bool.rb' + - 'lib/puppet_x/coi/jboss/internal/cli_executor.rb' + - 'lib/puppet_x/coi/jboss/provider/abstract_jboss_cli.rb' + - 'lib/puppet_x/coi/jboss/provider/confignode.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + - 'lib/puppet_x/coi/jboss/provider/jdbcdriver.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/LineEndConcatenation: + Exclude: + - 'lib/puppet_x/coi/jboss/provider/securitydomain/post_wildfly_provider.rb' + +# Offense count: 9 +# Cop supports --auto-correct. +Style/MethodCallWithoutArgsParentheses: + Exclude: + - 'lib/puppet/provider/jboss_resourceadapter/jbosscli.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + +# Offense count: 68 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline +Style/MethodDefParentheses: + Enabled: false + +# Offense count: 28 +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: snake_case, camelCase +Style/MethodName: + Exclude: + - 'lib/puppet/provider/jboss_resourceadapter/jbosscli.rb' + - 'lib/puppet_x/coi/jboss/internal/cli_executor.rb' + - 'lib/puppet_x/coi/jboss/provider/abstract_jboss_cli.rb' + - 'lib/puppet_x/coi/jboss/provider/confignode.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + +# Offense count: 1 +Style/MultilineBlockChain: + Exclude: + - 'lib/facter/jboss_running.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/MultilineIfModifier: + Exclude: + - 'lib/puppet_x/coi/jboss/provider/securitydomain.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/MultilineIfThen: + Exclude: + - 'lib/puppet/type/jboss_confignode.rb' + - 'lib/puppet/type/jboss_datasource.rb' + +# Offense count: 1 +Style/MultipleComparison: + Exclude: + - 'lib/puppet_x/coi/jboss/provider/confignode.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Style/MutableConstant: + Exclude: + - 'lib/puppet_x/coi/jboss/provider/securitydomain/abstract_provider.rb' + +# Offense count: 14 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: both, prefix, postfix +Style/NegatedIf: + Exclude: + - 'lib/puppet/provider/jboss_resourceadapter/jbosscli.rb' + - 'lib/puppet_x/coi/jboss/provider/abstract_jboss_cli.rb' + - 'lib/puppet_x/coi/jboss/provider/confignode.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + - 'lib/puppet_x/coi/jboss/provider/jdbcdriver.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Style/NestedParenthesizedCalls: + Exclude: + - 'lib/puppet/provider/jboss_resourceadapter/jbosscli.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, MinBodyLength, SupportedStyles. +# SupportedStyles: skip_modifier_ifs, always +Style/Next: + Exclude: + - 'lib/puppet_x/coi/jboss/configuration.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +Style/NilComparison: + Exclude: + - 'lib/puppet/type/jboss_confignode.rb' + - 'lib/puppet/type/jboss_datasource.rb' + - 'lib/puppet/type/jboss_deploy.rb' + - 'lib/puppet/type/jboss_jdbcdriver.rb' + - 'lib/puppet/type/jboss_jmsqueue.rb' + - 'lib/puppet/type/jboss_resourceadapter.rb' + - 'lib/puppet/type/jboss_securitydomain.rb' + +# Offense count: 29 +# Cop supports --auto-correct. +Style/Not: + Exclude: + - 'lib/puppet/provider/jboss_resourceadapter/jbosscli.rb' + - 'lib/puppet/type/jboss_confignode.rb' + - 'lib/puppet/type/jboss_datasource.rb' + - 'lib/puppet_x/coi/jboss/buildins_utils.rb' + - 'lib/puppet_x/coi/jboss/provider/abstract_jboss_cli.rb' + - 'lib/puppet_x/coi/jboss/provider/confignode.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + - 'lib/puppet_x/coi/jboss/provider/jdbcdriver.rb' + +# Offense count: 11 +# Cop supports --auto-correct. +Style/OneLineConditional: + Exclude: + - 'lib/puppet/type/jboss_confignode.rb' + - 'lib/puppet/type/jboss_datasource.rb' + - 'lib/puppet_x/coi/jboss/configuration.rb' + - 'lib/puppet_x/coi/jboss/functions/jboss_short_version.rb' + - 'lib/puppet_x/coi/jboss/functions/jboss_type_version.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: PreferredDelimiters. +Style/PercentLiteralDelimiters: + Exclude: + - 'lib/puppet/type/jboss_confignode.rb' + - 'lib/puppet/type/jboss_datasource.rb' + +# Offense count: 9 +# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist. +# NamePrefix: is_, has_, have_ +# NamePrefixBlacklist: is_, has_, have_ +# NameWhitelist: is_a? +Style/PredicateName: + Exclude: + - 'spec/**/*' + - 'lib/puppet/type/jboss_jmsqueue.rb' + - 'lib/puppet_x/coi/jboss/configuration.rb' + - 'lib/puppet_x/coi/jboss/internal/state/securitydomain_state.rb' + - 'lib/puppet_x/coi/jboss/provider/abstract_jboss_cli.rb' + - 'lib/puppet_x/coi/jboss/provider/deploy.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/Proc: + Exclude: + - 'lib/puppet_x/coi/jboss/constants.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: compact, exploded +Style/RaiseArgs: + Exclude: + - 'lib/puppet_x/coi/jboss/buildins_utils.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/RedundantBegin: + Exclude: + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/RedundantParentheses: + Exclude: + - 'lib/puppet_x/coi/jboss/buildins_utils.rb' + +# Offense count: 31 +# Cop supports --auto-correct. +# Configuration parameters: AllowMultipleReturnValues. +Style/RedundantReturn: + Exclude: + - 'lib/puppet/provider/jboss_resourceadapter/jbosscli.rb' + - 'lib/puppet/type/jboss_jmsqueue.rb' + - 'lib/puppet_x/coi/jboss/facts.rb' + - 'lib/puppet_x/coi/jboss/functions/jboss_to_bool.rb' + - 'lib/puppet_x/coi/jboss/provider/confignode.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + - 'lib/puppet_x/coi/jboss/provider/jdbcdriver.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +Style/RedundantSelf: + Exclude: + - 'lib/puppet_x/coi/jboss/configuration.rb' + - 'lib/puppet_x/coi/jboss/facts.rb' + - 'lib/puppet_x/coi/jboss/provider/abstract_jboss_cli.rb' + - 'lib/puppet_x/coi/jboss/provider/confignode.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes. +# SupportedStyles: slashes, percent_r, mixed +Style/RegexpLiteral: + Exclude: + - 'lib/puppet/provider/jboss_resourceadapter/jbosscli.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Style/RescueModifier: + Exclude: + - 'lib/puppet/type/jboss_datasource.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/SelfAssignment: + Exclude: + - 'lib/puppet_x/coi/jboss/internal/sanitizer.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: only_raise, only_fail, semantic +Style/SignalException: + Exclude: + - 'lib/puppet/type/jboss_datasource.rb' + - 'lib/puppet/type/jboss_deploy.rb' + +# Offense count: 114 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + Exclude: + - 'lib/puppet/provider/jboss_resourceadapter/jbosscli.rb' + - 'lib/puppet/type/jboss_confignode.rb' + - 'lib/puppet/type/jboss_datasource.rb' + - 'lib/puppet/type/jboss_deploy.rb' + - 'lib/puppet/type/jboss_jdbcdriver.rb' + - 'lib/puppet/type/jboss_jmsqueue.rb' + - 'lib/puppet/type/jboss_resourceadapter.rb' + - 'lib/puppet/type/jboss_securitydomain.rb' + - 'lib/puppet_x/coi/jboss/facts.rb' + - 'lib/puppet_x/coi/jboss/provider/abstract_jboss_cli.rb' + - 'lib/puppet_x/coi/jboss/provider/confignode.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource/static.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: IgnoredMethods. +# IgnoredMethods: respond_to, define_method +Style/SymbolProc: + Exclude: + - 'lib/puppet_x/coi/jboss/constants.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline, SupportedStylesForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInLiteral: + Exclude: + - 'lib/puppet/provider/jboss_resourceadapter/jbosscli.rb' + - 'lib/puppet_x/coi/jboss/provider/abstract_jboss_cli.rb' + - 'lib/puppet_x/coi/jboss/provider/datasource.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, Whitelist. +# Whitelist: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym +Style/TrivialAccessors: + Exclude: + - 'lib/puppet_x/coi/jboss/internal/state/securitydomain_state.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/UnlessElse: + Exclude: + - 'lib/puppet/type/jboss_confignode.rb' + +# Offense count: 6 +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: snake_case, camelCase +Style/VariableName: + Exclude: + - 'lib/puppet/provider/jboss_resourceadapter/jbosscli.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: SupportedStyles, WordRegex. +# SupportedStyles: percent, brackets +Style/WordArray: + EnforcedStyle: percent + MinSize: 3 + +# Offense count: 1 +# Cop supports --auto-correct. +Style/ZeroLengthPredicate: + Exclude: + - 'lib/puppet_x/coi/jboss/provider/confignode.rb' diff --git a/.travis.yml b/.travis.yml index 7161065..c39d813 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,46 +13,27 @@ bundler_args: "--without development --jobs=3 --retry=3 --path=${BUNDLE_PATH:-ve cache: bundler script: bundle exec rake test before_install: - - 'bundler --version || gem install bundler' # TODO:Remove if fixed - travis-ci/travis-ci#5578 - - 'rm -f Gemfile.lock' + - 'bundler --version || gem install bundler' matrix: fast_finish: true include: - rvm: '1.8' - env: PUPPET_VERSION="~> 2.7.0" FACTER_VERSION="~> 1.6.0" + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0" gemfile: gemfiles/Gemfile18.facter16 - bundler_args: "--without development --jobs=3 --retry=3 --path=${BUNDLE_PATH:-../vendor/bundle}" - rvm: '1.8' - env: PUPPET_VERSION="~> 2.7.0" FACTER_VERSION="~> 1.7.0" + env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.7.0" gemfile: gemfiles/Gemfile18.facter17 - bundler_args: "--without development --jobs=3 --retry=3 --path=${BUNDLE_PATH:-../vendor/bundle}" - rvm: '1.9' - env: PUPPET_VERSION="~> 3.0" + env: PUPPET_GEM_VERSION="~> 3.0" gemfile: gemfiles/Gemfile19 - bundler_args: "--without development --jobs=3 --retry=3 --path=${BUNDLE_PATH:-../vendor/bundle}" - rvm: '2.0' - env: PUPPET_VERSION="~> 3.0" + env: PUPPET_GEM_VERSION="~> 3.0" gemfile: gemfiles/Gemfile20 - bundler_args: "--without development --jobs=3 --retry=3 --path=${BUNDLE_PATH:-../vendor/bundle}" - rvm: '2.1' - env: PUPPET_VERSION="~> 3.0" - - rvm: '2.1' - env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES=yes - - rvm: '2.1' - sudo: required - services: docker - env: PUPPET_VERSION="3.8.7" RS_SET="centos-6-x86_64-docker" - script: bundle exec rake acceptance - - rvm: '2.1' - sudo: required - services: docker - env: PUPPET_VERSION="3.8.7" RS_SET="debian-7-x86_64-docker" - script: bundle exec rake acceptance - - rvm: '2.1' - sudo: required - services: docker - env: PUPPET_VERSION="3.8.7" RS_SET="ubuntu-14.04-x86_64-docker" - script: bundle exec rake acceptance + env: PUPPET_GEM_VERSION="~> 3.0" + # TODO: Restore after fixing https://github.com/coi-gov-pl/puppet-jboss/issues/98 + # - rvm: '2.1' + # env: PUPPET_GEM_VERSION="~> 3.0" STRICT_VARIABLES=yes # FIXME: GH Issue #3 - Activate acceptance tests on Travis CI for Puppet Enterprise, at least 2.8.8 and 3.8.2 notifications: email: false diff --git a/Gemfile b/Gemfile index c030d48..363bb9f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,37 +1,67 @@ -source ENV['GEM_SOURCE'] || 'https://rubygems.org' +source ENV['GEM_SOURCE'] || 'https://rubygems.org/' +SUPPORTED_RUBIES = [ + '~> 2.1.8' +].freeze + +# Used for gem conditionals, ugly code here :-P +RVERSION = Gem::Version.new(RUBY_VERSION.dup) +ruby_version_segments = RVERSION.segments +minor_version = "#{ruby_version_segments[0]}.#{ruby_version_segments[1]}" +def ver(spec) + Gem::Version.new(spec) +end + +def location_for(place_or_version) + [place_or_version, { :require => false }] +end + +# Puppet Module version +VER = '~> 0.3.5'.freeze + +# Testing dependencies group group :test do - gem 'rake', :require => false unless dependencies.map {|dep| dep.name}.include?('rake') - # TODO: Remove this explicitly pinned version by the time ticket gh-org/puppet-jboss#84 is closed. - gem 'rspec-puppet', '2.3.2', :require => false - gem 'puppetlabs_spec_helper', :require => false - gem 'puppet-lint', :require => false - gem 'metadata-json-lint', :require => false - gem 'os', :require => false - # TODO: Pinned because beaker is supported only MRI >=2.2, remove this - # explicitly pinned version by the time ticket gh-org/puppet-jboss#96 is closed. - gem 'beaker', '< 3.1.0', :require => false - gem 'beaker-rspec', '~> 5.6.0', :require => false - gem 'docker-api', :require => false - gem 'coveralls', :require => false - gem 'codeclimate-test-reporter', :require => false - gem 'simplecov', :require => false - if facterver = ENV['FACTER_VERSION'] - gem 'facter', facterver, :require => false - else - gem 'facter', :require => false - end - gem 'puppet', '~> 3.0', :require => false - gem 'ruby-augeas', :require => false - gem 'augeas', :require => false + gem "puppet-module-posix-default-r#{minor_version}", VER, :require => false, :platforms => 'ruby' + gem "puppet-module-posix-dev-r#{minor_version}", VER, :require => false, :platforms => 'ruby' + gem "puppet-module-win-default-r#{minor_version}", VER, :require => false, :platforms => %w[mswin mingw x64_mingw] + gem "puppet-module-win-dev-r#{minor_version}", VER, :require => false, :platforms => %w[mswin mingw x64_mingw] + gem 'rspec-puppet-facts-unsupported', '~> 0', :require => false + gem 'ruby-augeas', :require => false + gem 'safe_yaml', :require => false end +# Acceptance Testing dependencies group +group :system_test do + gem "puppet-module-posix-system-r#{minor_version}", VER, :require => false, :platforms => 'ruby' + gem "puppet-module-win-system-r#{minor_version}", VER, :require => false, :platforms => %w[mswin mingw x64_mingw] + beakerver = RVERSION < ver('2.2.0') ? ['>= 3.13.0', '< 4.0.0'] : nil + gem 'beaker', *location_for(ENV['BEAKER_VERSION'] || beakerver) + gem 'beaker-abs', *location_for(ENV['BEAKER_ABS_VERSION']) + gem 'beaker-hostgenerator', *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION']) + gem 'beaker-pe', :require => false + gem 'beaker-puppeter', :require => false + gem 'beaker-rspec', *location_for(ENV['BEAKER_RSPEC_VERSION']) + gem 'puppet-examples-helpers', '~> 0', :require => false + gem 'vagrant-wrapper', :require => false +end + +# Development dependencies group group :development do - gem 'inch', :require => false - gem 'vagrant-wrapper', :require => false - gem 'travis', :require => false - gem 'puppet-blacksmith', :require => false - gem 'pry-byebug', :require => false + gem 'pry', :require => false + gem 'pry-byebug', :require => false end +gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION'] || '~> 3') + +# Only explicitly specify Facter/Hiera if a version has been specified. +# Otherwise it can lead to strange bundler behavior. If you are seeing weird +# gem resolution behavior, try setting `DEBUG_RESOLVER` environment variable +# to `1` and then run bundle install. +gem 'facter', *location_for(ENV['FACTER_GEM_VERSION']) if ENV['FACTER_GEM_VERSION'] +gem 'hiera', *location_for(ENV['HIERA_GEM_VERSION']) if ENV['HIERA_GEM_VERSION'] + +# Check for correct Ruby version, ugly code here :-P +if SUPPORTED_RUBIES.map { |v| Gem::Requirement.new(v) }.find { |req| req.satisfied_by? RVERSION }.nil? + raise "Unsupported Ruby version #{RVERSION}, use one of: #{SUPPORTED_RUBIES}" +end # vim:ft=ruby diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..f0bc0a6 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,419 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (2.3.6) + addressable (2.5.2) + public_suffix (>= 2.0.2, < 4.0) + ansi (1.5.0) + ast (2.4.0) + aws-eventstream (1.0.1) + aws-partitions (1.93.0) + aws-sdk-core (3.21.3) + aws-eventstream (~> 1.0) + aws-partitions (~> 1.0) + aws-sigv4 (~> 1.0) + jmespath (~> 1.0) + aws-sdk-ec2 (1.35.0) + aws-sdk-core (~> 3) + aws-sigv4 (~> 1.0) + aws-sigv4 (1.0.2) + beaker (3.36.0) + beaker-abs (~> 0.4) + beaker-aws (~> 0.1) + beaker-docker (~> 0.1) + beaker-google (~> 0.1) + beaker-hiera (~> 0.0) + beaker-hostgenerator + beaker-openstack (~> 0.1) + beaker-puppet (~> 0.0) + beaker-vagrant (~> 0.1) + beaker-vcloud (~> 0.1) + beaker-vmpooler (~> 1.0) + beaker-vmware (~> 0.1) + hocon (~> 1.0) + in-parallel (~> 0.1) + inifile (~> 3.0) + minitar (~> 0.6) + minitest (~> 5.4) + net-scp (~> 1.2) + net-ssh (~> 4.0) + open_uri_redirections (~> 0.2.1) + pry-byebug (~> 3.4.2) + rb-readline (~> 0.5.3) + rsync (~> 1.0.9) + stringify-hash (~> 0.0) + thor (~> 0.19) + beaker-abs (0.5.0) + beaker-answers (0.23.0) + hocon (~> 1.0) + require_all (~> 1.3.2) + stringify-hash (~> 0.0.0) + beaker-aws (0.5.0) + aws-partitions (~> 1.91) + aws-sdk-ec2 (~> 1.35) + stringify-hash (~> 0.0.0) + beaker-docker (0.3.3) + docker-api + stringify-hash (~> 0.0.0) + beaker-google (0.1.0) + google-api-client (~> 0.9) + stringify-hash (~> 0.0.0) + beaker-hiera (0.1.1) + stringify-hash (~> 0.0.0) + beaker-hostgenerator (1.1.13) + deep_merge (~> 1.0) + stringify-hash (~> 0.0.0) + beaker-i18n_helper (1.1.0) + beaker-module_install_helper (0.1.7) + beaker (>= 2.0) + beaker-openstack (0.2.0) + fog-openstack + stringify-hash (~> 0.0.0) + beaker-pe (1.40.7) + beaker-abs + beaker-answers (~> 0.0) + stringify-hash (~> 0.0.0) + beaker-puppet (0.15.2) + in-parallel (~> 0.1) + oga + stringify-hash (~> 0.0.0) + beaker-puppet_install_helper (0.9.4) + beaker (>= 2.0) + beaker-puppeter (0.1.0) + beaker (< 4) + beaker-rspec (6.2.3) + beaker (~> 3.0) + rspec (~> 3.0) + serverspec (~> 2) + specinfra (~> 2) + beaker-task_helper (1.4.5) + beaker-vagrant (0.5.0) + stringify-hash (~> 0.0.0) + beaker-vcloud (0.2.0) + beaker-vmpooler + beaker-vmware + rbvmomi (~> 1.9) + stringify-hash (~> 0.0.0) + beaker-vmpooler (1.2.0) + stringify-hash (~> 0.0.0) + beaker-vmware (0.2.0) + fission (~> 0.4) + rbvmomi (~> 1.9) + stringify-hash (~> 0.0.0) + builder (3.2.3) + byebug (9.0.6) + codecov (0.1.10) + json + simplecov + url + coderay (1.1.2) + declarative (0.0.10) + declarative-option (0.1.0) + deep_merge (1.2.1) + diff-lcs (1.3) + docile (1.3.1) + docker-api (1.34.2) + excon (>= 0.47.0) + multi_json + domain_name (0.5.20180417) + unf (>= 0.0.5, < 1.0.0) + excon (0.62.0) + facter (2.5.1) + facterdb (0.5.2) + facter + jgrep + faraday (0.15.2) + multipart-post (>= 1.2, < 3) + fast_gettext (1.1.2) + fission (0.5.0) + CFPropertyList (~> 2.2) + fog-core (1.45.0) + builder + excon (~> 0.58) + formatador (~> 0.2) + fog-json (1.2.0) + fog-core + multi_json (~> 1.10) + fog-openstack (0.1.25) + fog-core (~> 1.40) + fog-json (>= 1.0) + ipaddress (>= 0.8) + formatador (0.2.5) + gettext (3.2.9) + locale (>= 2.0.5) + text (>= 1.3.0) + gettext-setup (0.30) + fast_gettext (~> 1.1.0) + gettext (>= 3.0.2) + locale + google-api-client (0.23.0) + addressable (~> 2.5, >= 2.5.1) + googleauth (>= 0.5, < 0.7.0) + httpclient (>= 2.8.1, < 3.0) + mime-types (~> 3.0) + representable (~> 3.0) + retriable (>= 2.0, < 4.0) + googleauth (0.6.2) + faraday (~> 0.12) + jwt (>= 1.4, < 3.0) + logging (~> 2.0) + memoist (~> 0.12) + multi_json (~> 1.11) + os (~> 0.9) + signet (~> 0.7) + hiera (1.3.4) + json_pure + hirb (0.7.3) + hocon (1.2.5) + http-cookie (1.0.3) + domain_name (~> 0.5) + httpclient (2.8.3) + in-parallel (0.1.17) + inifile (3.0.0) + ipaddress (0.8.3) + jgrep (1.5.0) + jmespath (1.4.0) + json (2.1.0) + json-schema (2.8.0) + addressable (>= 2.4) + json_pure (2.1.0) + jwt (2.1.0) + little-plugger (1.1.4) + locale (2.1.2) + logging (2.2.2) + little-plugger (~> 1.1) + multi_json (~> 1.10) + master_manipulator (2.1.1) + beaker (>= 2.7.0) + multi_json + mcollective-client (2.12.1) + json + stomp + systemu + memoist (0.16.0) + metaclass (0.0.4) + metadata-json-lint (2.1.0) + json-schema (~> 2.8) + spdx-licenses (~> 1.0) + method_source (0.8.2) + mime-types (3.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2016.0521) + mini_portile2 (2.3.0) + minitar (0.6.1) + minitest (5.11.3) + mocha (1.1.0) + metaclass (~> 0.0.1) + multi_json (1.13.1) + multipart-post (2.0.0) + net-scp (1.2.1) + net-ssh (>= 2.6.5) + net-ssh (4.2.0) + net-telnet (0.1.1) + netrc (0.11.0) + nokogiri (1.8.3) + mini_portile2 (~> 2.3.0) + oga (2.15) + ast + ruby-ll (~> 2.1) + open_uri_redirections (0.2.1) + os (0.9.6) + parallel (1.12.1) + parallel_tests (2.14.2) + parallel + parser (2.5.1.0) + ast (~> 2.4.0) + powerpack (0.1.2) + pry (0.10.4) + coderay (~> 1.1.0) + method_source (~> 0.8.1) + slop (~> 3.4) + pry-byebug (3.4.3) + byebug (>= 9.0, < 9.1) + pry (~> 0.10) + public_suffix (3.0.2) + puppet (3.8.7) + facter (> 1.6, < 3) + hiera (~> 1.0) + json_pure + puppet-blacksmith (4.1.2) + rest-client (~> 2.0) + puppet-examples-helpers (0.1.0) + puppet-lint (2.3.5) + puppet-module-posix-default-r2.1 (0.3.5) + puppet-module-posix-dev-r2.1 (0.3.5) + codecov (~> 0.1.10) + gettext-setup (~> 0.26) + metadata-json-lint (>= 2.0.2, < 3.0.0) + mocha (>= 1.0.0, < 1.2.0) + parallel_tests (>= 2.14.1, < 2.14.3) + pry (~> 0.10.4) + puppet-blacksmith (>= 3.4.0) + puppet-lint (>= 2.3.0, < 3.0.0) + puppet-strings (~> 2.0) + puppet-syntax (>= 2.4.1, < 3.0.0) + puppet_pot_generator (~> 1.0) + puppetlabs_spec_helper (>= 2.9.0, < 3.0.0) + rainbow (~> 2.0) + rspec-puppet (>= 2.3.2, < 3.0.0) + rspec-puppet-facts (~> 1.8) + rspec_junit_formatter (~> 0.2) + rubocop (~> 0.49.0) + rubocop-i18n (~> 1.2.0) + rubocop-rspec (~> 1.16.0) + simplecov (>= 0.14.1, < 1.0.0) + simplecov-console (~> 0.4.2) + specinfra (= 2.67.3) + puppet-module-posix-system-r2.1 (0.3.5) + beaker-i18n_helper (~> 1.1) + beaker-module_install_helper (>= 0.1.4, < 1.0.0) + beaker-puppet_install_helper (>= 0.7.1, < 1.0.0) + beaker-task_helper (>= 1.1.0, < 2.0.0) + master_manipulator (>= 2.1.1, < 3.0.0) + puppet-strings (2.0.0) + rgen + yard (~> 0.9.5) + puppet-syntax (2.4.1) + rake + puppet_pot_generator (1.0.1) + puppet + puppetlabs_spec_helper (2.9.1) + mocha (~> 1.0) + puppet-lint (~> 2.0) + puppet-syntax (~> 2.0) + rspec-puppet (~> 2.0) + rainbow (2.2.2) + rake + rake (12.3.1) + rb-readline (0.5.5) + rbvmomi (1.13.0) + builder (~> 3.0) + json (>= 1.8) + nokogiri (~> 1.5) + trollop (~> 2.1) + representable (3.0.4) + declarative (< 0.1.0) + declarative-option (< 0.2.0) + uber (< 0.2.0) + require_all (1.3.3) + rest-client (2.0.2) + http-cookie (>= 1.0.2, < 2.0) + mime-types (>= 1.16, < 4.0) + netrc (~> 0.8) + retriable (3.1.2) + rgen (0.8.2) + rspec (3.7.0) + rspec-core (~> 3.7.0) + rspec-expectations (~> 3.7.0) + rspec-mocks (~> 3.7.0) + rspec-core (3.7.1) + rspec-support (~> 3.7.0) + rspec-expectations (3.7.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.7.0) + rspec-its (1.2.0) + rspec-core (>= 3.0.0) + rspec-expectations (>= 3.0.0) + rspec-mocks (3.7.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.7.0) + rspec-puppet (2.6.13) + rspec + rspec-puppet-facts (1.9.0) + facter + facterdb (>= 0.5.0) + json + mcollective-client + puppet + rspec-puppet-facts-unsupported (0.1.1) + rspec-puppet-facts (~> 1) + rspec-support (3.7.1) + rspec_junit_formatter (0.4.1) + rspec-core (>= 2, < 4, != 2.12.0) + rsync (1.0.9) + rubocop (0.49.1) + parallel (~> 1.10) + parser (>= 2.3.3.1, < 3.0) + powerpack (~> 0.1) + rainbow (>= 1.99.1, < 3.0) + ruby-progressbar (~> 1.7) + unicode-display_width (~> 1.0, >= 1.0.1) + rubocop-i18n (1.2.0) + rubocop (~> 0.49.0) + rubocop-rspec (1.16.0) + rubocop (>= 0.49.0) + ruby-augeas (0.5.0) + ruby-ll (2.1.2) + ansi + ast + ruby-progressbar (1.9.0) + safe_yaml (1.0.4) + serverspec (2.39.0) + multi_json + rspec (~> 3.0) + rspec-its + specinfra (~> 2.53) + sfl (2.3) + signet (0.8.1) + addressable (~> 2.3) + faraday (~> 0.9) + jwt (>= 1.5, < 3.0) + multi_json (~> 1.10) + simplecov (0.16.1) + docile (~> 1.1) + json (>= 1.8, < 3) + simplecov-html (~> 0.10.0) + simplecov-console (0.4.2) + ansi + hirb + simplecov + simplecov-html (0.10.2) + slop (3.6.0) + spdx-licenses (1.2.0) + specinfra (2.67.3) + net-scp + net-ssh (>= 2.7, < 5.0) + net-telnet + sfl + stomp (1.4.4) + stringify-hash (0.0.2) + systemu (2.6.5) + text (1.3.1) + thor (0.20.0) + trollop (2.1.2) + uber (0.1.0) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.5) + unicode-display_width (1.4.0) + url (0.3.2) + vagrant-wrapper (2.0.3) + yard (0.9.14) + +PLATFORMS + ruby + +DEPENDENCIES + beaker (>= 3.13.0, < 4.0.0) + beaker-abs + beaker-hostgenerator + beaker-pe + beaker-puppeter + beaker-rspec + pry + pry-byebug + puppet (~> 3) + puppet-examples-helpers (~> 0) + puppet-module-posix-default-r2.1 (~> 0.3.5) + puppet-module-posix-dev-r2.1 (~> 0.3.5) + puppet-module-posix-system-r2.1 (~> 0.3.5) + puppet-module-win-default-r2.1 (~> 0.3.5) + puppet-module-win-dev-r2.1 (~> 0.3.5) + puppet-module-win-system-r2.1 (~> 0.3.5) + rspec-puppet-facts-unsupported (~> 0) + ruby-augeas + safe_yaml + vagrant-wrapper + +BUNDLED WITH + 1.16.2 diff --git a/Guardfile b/Guardfile deleted file mode 100644 index 0d424a8..0000000 --- a/Guardfile +++ /dev/null @@ -1,8 +0,0 @@ -guard 'rake', :task => :spec_ruby do - watch(%r{spec/(unit|functions|hosts|integration|types)/.+_spec\.rb}) - watch(%r{lib/.+\.rb}) -end -guard 'rake', :task => :spec_puppet_prepared do - watch(%r{spec/(classes|defines)/.+_spec\.rb}) - watch(%r{manifests/.+\.pp}) -end diff --git a/LICENSE b/LICENSE index 557bb79..d17f64d 100644 --- a/LICENSE +++ b/LICENSE @@ -187,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2015 Centralny Ośrodek Informatyki + Copyright 2015-2018 Centralny Ośrodek Informatyki Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/Rakefile b/Rakefile index 1418fa5..3072225 100644 --- a/Rakefile +++ b/Rakefile @@ -1,78 +1,24 @@ -require 'rubygems' +require './gemfiles/quirks/file' require 'puppetlabs_spec_helper/rake_tasks' -require 'puppet-lint/tasks/puppet-lint' -# These two gems aren't always present, for instance -# on Travis with --without development -begin - require 'puppet_blacksmith/rake_tasks' -rescue LoadError -end - -PuppetLint.configuration.send('disable_80chars') -PuppetLint.configuration.ignore_paths = [ - "spec/**/*.pp", - "pkg/**/*.pp", - "tests/**/*.pp", - "vendor/**/*.pp" -] -PuppetLint.configuration.fail_on_warnings = true - -desc "Validate manifests, templates, and ruby files" -task :validate do - Dir['manifests/**/*.pp'].each do |manifest| - sh "puppet parser validate --noop #{manifest}" - end - Dir['templates/**/*.erb'].each do |template| - sh "erb -P -x -T '-' #{template} | ruby -c" - end -end - -Rake::Task[:spec_standalone].clear -desc "Run spec tests on an existing fixtures directory (for Puppet code)" -RSpec::Core::RakeTask.new(:spec_puppet) do |t| - t.rspec_opts = ['--color --order rand'] - t.pattern = 'spec/{classes,defines}/**/*_spec.rb' -end -desc "Run spec tests on an existing fixtures directory (for Ruby code)" -RSpec::Core::RakeTask.new(:spec_ruby) do |t| - t.rspec_opts = ['--color --order rand'] - t.verbose = true - t.pattern = 'spec/{unit,functions,hosts,integration,types}/**/*_spec.rb' -end -desc 'Run spec tests on an existing fixtures directory' -task :spec_standalone => [ - :spec_puppet, - :spec_ruby -] - -task :spec_puppet_prepared => [ - :spec_prep, - :spec_puppet -] +tasks = [:spec] -begin - require 'beaker' - desc "Run acceptance tests" - RSpec::Core::RakeTask.new(:acceptance) do |t| - t.pattern = 'spec/acceptance' - end -rescue LoadError - task :acceptance do - $stderr.puts 'Beaker is not avialable, skipping acceptance tests' - end -end - -desc "Clean fixtures" -task :clean_fixtures do - FileUtils.rmtree 'spec/fixtures/modules' +if RUBY_VERSION >= '2.1' + require 'puppet_blacksmith/rake_tasks' + require 'puppet-lint/tasks/puppet-lint' + require 'metadata-json-lint/rake_task' + require 'rubocop/rake_task' + + PuppetLint.configuration.send('disable_80chars') + PuppetLint.configuration.relative = true + PuppetLint.configuration.ignore_paths = ['spec/**/*.pp', 'pkg/**/*.pp'] + RuboCop::RakeTask.new + + tasks.unshift(:syntax) + tasks.unshift(:lint) + tasks.unshift(:metadata_lint) + tasks.unshift(:rubocop) end -desc "Run syntax, lint, and spec tests." -task :test => [ - :metadata_lint, - :lint, - :validate, - :clean_fixtures, - :spec, -] +desc 'Run rubocop, metadata_lint, lint, validate, and spec tests.' +task :test => tasks diff --git a/examples/jboss/as7.pp b/examples/jboss/as7.pp deleted file mode 100644 index b49bdeb..0000000 --- a/examples/jboss/as7.pp +++ /dev/null @@ -1,4 +0,0 @@ -class { 'jboss': - product => 'jboss-as', - version => '7.1.1.Final', -} diff --git a/examples/version/as7.pp b/examples/version/as7.pp new file mode 100644 index 0000000..e3c25b3 --- /dev/null +++ b/examples/version/as7.pp @@ -0,0 +1,14 @@ +# JBoss AS 7 do not work on Java >= 7 +if $::osfamily == 'RedHat' { + $java_package = 'java-1.6.0-openjdk' +} elsif $::osfamily == 'Debian' { + $java_package = 'openjdk-6-jre' +} else { + $java_package = undef +} + +class { 'jboss': + product => 'jboss-as', + version => '7.1.1.Final', + java_package => $java_package, +} diff --git a/examples/version/as7/rmjava_as7.pp b/examples/version/as7/rmjava_as7.pp new file mode 100644 index 0000000..0020c7a --- /dev/null +++ b/examples/version/as7/rmjava_as7.pp @@ -0,0 +1,13 @@ +# JBoss AS 7 do not work on Java >= 7 +if $::osfamily == 'RedHat' { + $java_package = 'java-1.6.0-openjdk' +} elsif $::osfamily == 'Debian' { + $java_package = 'openjdk-6-jre' +} else { + $java_package = undef +} + +class { 'java': + version => 'absent', + package => $java_package, +} diff --git a/examples/version/as7/rmjava_default.pp b/examples/version/as7/rmjava_default.pp new file mode 100644 index 0000000..29672e9 --- /dev/null +++ b/examples/version/as7/rmjava_default.pp @@ -0,0 +1,8 @@ +include java::params + +$jdk = $java::params::java['jdk']['package'] +$jre = $java::params::java['jre']['package'] + +package { [$jdk, $jre]: + ensure => 'purged', +} diff --git a/examples/jboss/wildfly10.pp b/examples/version/wildfly10.pp similarity index 100% rename from examples/jboss/wildfly10.pp rename to examples/version/wildfly10.pp diff --git a/examples/jboss/wildfly8.pp b/examples/version/wildfly8.pp similarity index 100% rename from examples/jboss/wildfly8.pp rename to examples/version/wildfly8.pp diff --git a/examples/jboss/wildfly9.pp b/examples/version/wildfly9.pp similarity index 100% rename from examples/jboss/wildfly9.pp rename to examples/version/wildfly9.pp diff --git a/gemfiles/Gemfile18.facter16 b/gemfiles/Gemfile18.facter16 old mode 100644 new mode 100755 index fa1c622..643bfda --- a/gemfiles/Gemfile18.facter16 +++ b/gemfiles/Gemfile18.facter16 @@ -1,36 +1,31 @@ +#!/usr/bin/env ruby source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :test do - gem 'rake', '~> 10.0.0', :require => false unless dependencies.map {|dep| dep.name}.include?('rake') + gem 'rake', '~> 10.0.0', :require => false unless dependencies.map(&:name).include?('rake') # TODO: Remove this explicitly pinned version by the time ticket gh-org/puppet-jboss#84 is closed. - gem 'rspec-puppet', '2.3.2', :require => false - gem 'puppetlabs_spec_helper', :require => false - gem 'puppet-lint', :require => false - gem 'metadata-json-lint', :require => false + gem 'rspec-puppet', '~> 2.3.2', :require => false + gem 'puppetlabs_spec_helper', '~> 2.7.0', :require => false # This package drops support for 1.8 gem 'json', '1.8.3', :require => false gem 'os', :require => false - gem 'specinfra', '2.59.0', :require => false - gem 'net-ssh', '2.9.4', :require => false # This package drops support for 1.8 gem 'json_pure', '1.8.3', :require => false + gem 'rspec-mocks', :require => false gem 'rspec-its', :require => false - gem 'rspec', '~> 3.1.0', :require => false + gem 'rspec', '~> 2', :require => false + # gem 'rspec', '~> 3.2.0', :require => false - gem 'tins', '~> 1.6.0', :require => false - - gem 'facter', '~> 1.6.18', :require => false - gem 'puppet', '~> 2.7.0', :require => false + gem 'facter', ENV['FACTER_GEM_VERSION'] || '~> 1.6.0', :require => false + gem 'puppet', ENV['PUPPET_GEM_VERSION'] || '~> 2.7.0', :require => false gem 'hiera-puppet', :require => false gem 'ruby-augeas', :require => false gem 'augeas', :require => false - gem 'nokogiri', '~> 1.5.11', :require => false + gem 'rspec-puppet-facts', :require => false end group :development do - gem 'inch', :require => false - gem 'vagrant-wrapper', :require => false gem 'pry', '~> 0.9.12.0', :require => false end diff --git a/gemfiles/Gemfile18.facter16.lock b/gemfiles/Gemfile18.facter16.lock index f461452..4c00124 100644 --- a/gemfiles/Gemfile18.facter16.lock +++ b/gemfiles/Gemfile18.facter16.lock @@ -2,105 +2,87 @@ GEM remote: https://rubygems.org/ specs: augeas (0.6.4) - coderay (1.1.1) - diff-lcs (1.2.5) + coderay (1.1.2) + diff-lcs (1.3) facter (1.6.18) + facterdb (0.5.2) + facter + jgrep hiera (1.3.4) json_pure hiera-puppet (1.0.0) hiera (~> 1.0) - inch (0.7.1) - pry - sparkr (>= 0.2.0) - term-ansicolor - yard (~> 0.8.7.5) + jgrep (1.5.0) json (1.8.3) json_pure (1.8.3) - metaclass (0.0.4) - metadata-json-lint (0.0.11) + mcollective-client (2.12.1) json - spdx-licenses (~> 1.0) - method_source (0.8.2) - mocha (1.1.0) + stomp + systemu + metaclass (0.0.4) + method_source (0.9.0) + mocha (1.5.0) metaclass (~> 0.0.1) - net-scp (1.2.1) - net-ssh (>= 2.6.5) - net-ssh (2.9.4) - net-telnet (0.1.1) - nokogiri (1.5.11) - os (0.9.6) + os (1.0.0) pry (0.9.12.6) coderay (~> 1.0) method_source (~> 0.8) slop (~> 3.4) puppet (2.7.26) facter (~> 1.5) - puppet-lint (2.0.0) - puppet-syntax (2.1.0) - rake - puppetlabs_spec_helper (1.1.1) - mocha - puppet-lint - puppet-syntax + puppet-lint (2.3.5) + puppet-syntax (2.4.1) rake - rspec-puppet + puppetlabs_spec_helper (2.7.0) + mocha (~> 1.0) + puppet-lint (~> 2.0) + puppet-syntax (~> 2.0) + rspec-puppet (~> 2.0) rake (10.0.4) - rspec (3.1.0) - rspec-core (~> 3.1.0) - rspec-expectations (~> 3.1.0) - rspec-mocks (~> 3.1.0) - rspec-core (3.1.7) - rspec-support (~> 3.1.0) - rspec-expectations (3.1.2) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.1.0) - rspec-its (1.2.0) - rspec-core (>= 3.0.0) - rspec-expectations (>= 3.0.0) - rspec-mocks (3.1.3) - rspec-support (~> 3.1.0) + rspec (2.99.0) + rspec-core (~> 2.99.0) + rspec-expectations (~> 2.99.0) + rspec-mocks (~> 2.99.0) + rspec-core (2.99.2) + rspec-expectations (2.99.2) + diff-lcs (>= 1.1.3, < 2.0) + rspec-its (1.0.1) + rspec-core (>= 2.99.0.beta1) + rspec-expectations (>= 2.99.0.beta1) + rspec-mocks (2.99.4) rspec-puppet (2.3.2) rspec - rspec-support (3.1.2) + rspec-puppet-facts (1.9.0) + facter + facterdb (>= 0.5.0) + json + mcollective-client + puppet ruby-augeas (0.5.0) - sfl (2.2) slop (3.6.0) - sparkr (0.4.1) - spdx-licenses (1.1.0) - specinfra (2.59.0) - net-scp - net-ssh (>= 2.7, < 4.0) - net-telnet - sfl - term-ansicolor (1.3.2) - tins (~> 1.0) - tins (1.6.0) - vagrant-wrapper (2.0.3) - yard (0.8.7.6) + stomp (1.4.4) + systemu (2.6.5) PLATFORMS ruby DEPENDENCIES augeas - facter (~> 1.6.18) + facter (~> 1.6.0) hiera-puppet - inch json (= 1.8.3) json_pure (= 1.8.3) - metadata-json-lint - net-ssh (= 2.9.4) - nokogiri (~> 1.5.11) os pry (~> 0.9.12.0) puppet (~> 2.7.0) - puppet-lint - puppetlabs_spec_helper + puppetlabs_spec_helper (~> 2.7.0) rake (~> 10.0.0) - rspec (~> 3.1.0) + rspec (~> 2) rspec-its - rspec-puppet (= 2.3.2) + rspec-mocks + rspec-puppet (~> 2.3.2) + rspec-puppet-facts ruby-augeas - specinfra (= 2.59.0) - tins (~> 1.6.0) - vagrant-wrapper + +BUNDLED WITH + 1.16.2 diff --git a/gemfiles/Gemfile18.facter17 b/gemfiles/Gemfile18.facter17 old mode 100644 new mode 100755 index 49b8f6e..b9fe293 --- a/gemfiles/Gemfile18.facter17 +++ b/gemfiles/Gemfile18.facter17 @@ -1,36 +1,31 @@ +#!/usr/bin/env ruby source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :test do - gem 'rake', '~> 10.0.0', :require => false unless dependencies.map {|dep| dep.name}.include?('rake') + gem 'rake', '~> 10.0.0', :require => false unless dependencies.map(&:name).include?('rake') # TODO: Remove this explicitly pinned version by the time ticket gh-org/puppet-jboss#84 is closed. - gem 'rspec-puppet', '2.3.2', :require => false - gem 'puppetlabs_spec_helper', :require => false - gem 'puppet-lint', :require => false - gem 'metadata-json-lint', :require => false + gem 'rspec-puppet', '~> 2.3.2', :require => false + gem 'puppetlabs_spec_helper', '~> 2.7.0', :require => false # This package drops support for 1.8 gem 'json', '1.8.3', :require => false gem 'os', :require => false - gem 'specinfra', '2.59.0', :require => false - gem 'net-ssh', '2.9.4', :require => false # This package drops support for 1.8 gem 'json_pure', '1.8.3', :require => false + gem 'rspec-mocks', :require => false gem 'rspec-its', :require => false - gem 'rspec', '~> 3.1.0', :require => false + gem 'rspec', '~> 2', :require => false + # gem 'rspec', '~> 3.2.0', :require => false - gem 'tins', '~> 1.6.0', :require => false - - gem 'facter', '1.7.0', :require => false - gem 'puppet', '~> 2.7.0', :require => false + gem 'facter', ENV['FACTER_GEM_VERSION'] || '~> 1.7.0', :require => false + gem 'puppet', ENV['PUPPET_GEM_VERSION'] || '~> 2.7.0', :require => false gem 'hiera-puppet', :require => false gem 'ruby-augeas', :require => false gem 'augeas', :require => false - gem 'nokogiri', '~> 1.5.11', :require => false + gem 'rspec-puppet-facts', :require => false end group :development do - gem 'inch', :require => false - gem 'vagrant-wrapper', :require => false gem 'pry', '~> 0.9.12.0', :require => false end diff --git a/gemfiles/Gemfile18.facter17.lock b/gemfiles/Gemfile18.facter17.lock index 01d9b63..ef8ebe2 100644 --- a/gemfiles/Gemfile18.facter17.lock +++ b/gemfiles/Gemfile18.facter17.lock @@ -2,105 +2,87 @@ GEM remote: https://rubygems.org/ specs: augeas (0.6.4) - coderay (1.1.1) - diff-lcs (1.2.5) - facter (1.7.0) + coderay (1.1.2) + diff-lcs (1.3) + facter (1.7.6) + facterdb (0.5.2) + facter + jgrep hiera (1.3.4) json_pure hiera-puppet (1.0.0) hiera (~> 1.0) - inch (0.7.1) - pry - sparkr (>= 0.2.0) - term-ansicolor - yard (~> 0.8.7.5) + jgrep (1.5.0) json (1.8.3) json_pure (1.8.3) - metaclass (0.0.4) - metadata-json-lint (0.0.11) + mcollective-client (2.12.1) json - spdx-licenses (~> 1.0) - method_source (0.8.2) - mocha (1.1.0) + stomp + systemu + metaclass (0.0.4) + method_source (0.9.0) + mocha (1.5.0) metaclass (~> 0.0.1) - net-scp (1.2.1) - net-ssh (>= 2.6.5) - net-ssh (2.9.4) - net-telnet (0.1.1) - nokogiri (1.5.11) - os (0.9.6) + os (1.0.0) pry (0.9.12.6) coderay (~> 1.0) method_source (~> 0.8) slop (~> 3.4) puppet (2.7.26) facter (~> 1.5) - puppet-lint (2.0.0) - puppet-syntax (2.1.0) - rake - puppetlabs_spec_helper (1.1.1) - mocha - puppet-lint - puppet-syntax + puppet-lint (2.3.5) + puppet-syntax (2.4.1) rake - rspec-puppet + puppetlabs_spec_helper (2.7.0) + mocha (~> 1.0) + puppet-lint (~> 2.0) + puppet-syntax (~> 2.0) + rspec-puppet (~> 2.0) rake (10.0.4) - rspec (3.1.0) - rspec-core (~> 3.1.0) - rspec-expectations (~> 3.1.0) - rspec-mocks (~> 3.1.0) - rspec-core (3.1.7) - rspec-support (~> 3.1.0) - rspec-expectations (3.1.2) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.1.0) - rspec-its (1.2.0) - rspec-core (>= 3.0.0) - rspec-expectations (>= 3.0.0) - rspec-mocks (3.1.3) - rspec-support (~> 3.1.0) + rspec (2.99.0) + rspec-core (~> 2.99.0) + rspec-expectations (~> 2.99.0) + rspec-mocks (~> 2.99.0) + rspec-core (2.99.2) + rspec-expectations (2.99.2) + diff-lcs (>= 1.1.3, < 2.0) + rspec-its (1.0.1) + rspec-core (>= 2.99.0.beta1) + rspec-expectations (>= 2.99.0.beta1) + rspec-mocks (2.99.4) rspec-puppet (2.3.2) rspec - rspec-support (3.1.2) + rspec-puppet-facts (1.9.0) + facter + facterdb (>= 0.5.0) + json + mcollective-client + puppet ruby-augeas (0.5.0) - sfl (2.2) slop (3.6.0) - sparkr (0.4.1) - spdx-licenses (1.1.0) - specinfra (2.59.0) - net-scp - net-ssh (>= 2.7, < 4.0) - net-telnet - sfl - term-ansicolor (1.3.2) - tins (~> 1.0) - tins (1.6.0) - vagrant-wrapper (2.0.3) - yard (0.8.7.6) + stomp (1.4.4) + systemu (2.6.5) PLATFORMS ruby DEPENDENCIES augeas - facter (= 1.7.0) + facter (~> 1.7.0) hiera-puppet - inch json (= 1.8.3) json_pure (= 1.8.3) - metadata-json-lint - net-ssh (= 2.9.4) - nokogiri (~> 1.5.11) os pry (~> 0.9.12.0) puppet (~> 2.7.0) - puppet-lint - puppetlabs_spec_helper + puppetlabs_spec_helper (~> 2.7.0) rake (~> 10.0.0) - rspec (~> 3.1.0) + rspec (~> 2) rspec-its - rspec-puppet (= 2.3.2) + rspec-mocks + rspec-puppet (~> 2.3.2) + rspec-puppet-facts ruby-augeas - specinfra (= 2.59.0) - tins (~> 1.6.0) - vagrant-wrapper + +BUNDLED WITH + 1.16.2 diff --git a/gemfiles/Gemfile19 b/gemfiles/Gemfile19 old mode 100644 new mode 100755 index 75e9b01..c5d60f9 --- a/gemfiles/Gemfile19 +++ b/gemfiles/Gemfile19 @@ -1,45 +1,23 @@ +#!/usr/bin/env ruby source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :test do - gem 'rake', :require => false unless dependencies.map {|dep| dep.name}.include?('rake') - # TODO: Remove this explicitly pinned version by the time ticket gh-org/puppet-jboss#84 is closed. - gem 'rspec-puppet', '2.3.2', :require => false + gem 'rake', :require => false unless dependencies.map(&:name).include?('rake') + gem 'rspec-puppet', :require => false + gem 'rspec-its', :require => false gem 'puppetlabs_spec_helper', :require => false gem 'puppet-lint', :require => false - gem 'metadata-json-lint', :require => false - gem 'json', '1.8.3', :require => false + gem 'metadata-json-lint', '< 1.2.2', :require => false gem 'os', :require => false - gem 'specinfra', '2.59.0', :require => false - gem 'net-ssh', '2.9.4', :require => false - gem 'mime-types', '2.99.2', :require => false - gem 'tins', '~> 1.6.0', :require => false - gem 'rspec-core', '3.4.4', :require => false - - gem 'beaker', :require => false - gem 'beaker-rspec', :require => false - gem 'docker-api', :require => false - gem 'coveralls', :require => false - gem 'codeclimate-test-reporter', :require => false - gem 'simplecov', :require => false - - if facterver = ENV['FACTER_VERSION'] - gem 'facter', facterver, :require => false - else - gem 'facter', :require => false - end - - gem 'puppet', '~> 3.0', :require => false - + gem 'simplecov', :require => false + gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false + gem 'puppet', ENV['PUPPET_GEM_VERSION'] || '~> 3.0', :require => false gem 'ruby-augeas', :require => false - gem 'augeas', :require => false gem 'nokogiri', '~> 1.6.8', :require => false + gem 'rspec-puppet-facts', :require => false end group :development do - gem 'inch', :require => false - gem 'vagrant-wrapper', :require => false - gem 'travis', :require => false - gem 'puppet-blacksmith', :require => false gem 'pry-debugger', :require => false end diff --git a/gemfiles/Gemfile19.lock b/gemfiles/Gemfile19.lock index 83da4e3..53ae9f1 100644 --- a/gemfiles/Gemfile19.lock +++ b/gemfiles/Gemfile19.lock @@ -1,259 +1,41 @@ GEM remote: https://rubygems.org/ specs: - CFPropertyList (2.2.8) - addressable (2.4.0) - augeas (0.6.4) - aws-sdk (1.66.0) - aws-sdk-v1 (= 1.66.0) - aws-sdk-v1 (1.66.0) - json (~> 1.4) - nokogiri (>= 1.4.4) - backports (3.6.8) - beaker (2.46.0) - aws-sdk (~> 1.57) - beaker-answers (~> 0.0) - beaker-hiera (~> 0.0) - beaker-pe (~> 0.0) - docker-api - fission (~> 0.4) - fog (~> 1.25, < 1.35.0) - fog-google (~> 0.0.9) - google-api-client (~> 0.8, < 0.9.5) - hocon (~> 1.0) - inifile (~> 2.0) - json (~> 1.8) - mime-types (~> 2.99) - minitest (~> 5.4) - net-scp (~> 1.2) - net-ssh (~> 2.9) - open_uri_redirections (~> 0.2.1) - rbvmomi (~> 1.8) - rsync (~> 1.0.9) - stringify-hash (~> 0.0) - unf (~> 0.1) - beaker-answers (0.8.0) - hocon (~> 1.0) - require_all (~> 1.3.2) - stringify-hash (~> 0.0.0) - beaker-hiera (0.1.1) - stringify-hash (~> 0.0.0) - beaker-pe (0.6.0) - stringify-hash (~> 0.0.0) - beaker-rspec (5.6.0) - beaker (~> 2.0) - rspec - serverspec (~> 2) - specinfra (~> 2) - builder (3.2.2) - codeclimate-test-reporter (0.6.0) - simplecov (>= 0.7.1, < 1.0.0) - coderay (1.1.1) + coderay (1.1.2) columnize (0.9.0) - coveralls (0.8.14) - json (>= 1.8, < 3) - simplecov (~> 0.12.0) - term-ansicolor (~> 1.3) - thor (~> 0.19.1) - tins (~> 1.6.0) debugger (1.6.8) columnize (>= 0.3.1) debugger-linecache (~> 1.2.0) debugger-ruby_core_source (~> 1.3.5) debugger-linecache (1.2.0) debugger-ruby_core_source (1.3.8) - diff-lcs (1.2.5) - docile (1.1.5) - docker-api (1.29.0) - excon (>= 0.38.0) - json - domain_name (0.5.20160615) - unf (>= 0.0.5, < 1.0.0) - ethon (0.9.0) - ffi (>= 1.3.0) - excon (0.51.0) - facter (2.4.6) - CFPropertyList (~> 2.2.6) - faraday (0.9.2) - multipart-post (>= 1.2, < 3) - faraday_middleware (0.10.0) - faraday (>= 0.7.4, < 0.10) - ffi (1.9.14) - fission (0.5.0) - CFPropertyList (~> 2.2) - fog (1.34.0) - fog-atmos - fog-aws (>= 0.6.0) - fog-brightbox (~> 0.4) - fog-core (~> 1.32) - fog-dynect (~> 0.0.2) - fog-ecloud (~> 0.1) - fog-google (>= 0.0.2) - fog-json - fog-local - fog-powerdns (>= 0.1.1) - fog-profitbricks - fog-radosgw (>= 0.0.2) - fog-riakcs - fog-sakuracloud (>= 0.0.4) - fog-serverlove - fog-softlayer - fog-storm_on_demand - fog-terremark - fog-vmfusion - fog-voxel - fog-xml (~> 0.1.1) - ipaddress (~> 0.5) - nokogiri (~> 1.5, >= 1.5.11) - fog-atmos (0.1.0) - fog-core - fog-xml - fog-aws (0.9.4) - fog-core (~> 1.38) - fog-json (~> 1.0) - fog-xml (~> 0.1) - ipaddress (~> 0.8) - fog-brightbox (0.11.0) - fog-core (~> 1.22) - fog-json - inflecto (~> 0.0.2) - fog-core (1.42.0) - builder - excon (~> 0.49) - formatador (~> 0.2) - fog-dynect (0.0.3) - fog-core - fog-json - fog-xml - fog-ecloud (0.3.0) - fog-core - fog-xml - fog-google (0.0.9) - fog-core - fog-json - fog-xml - fog-json (1.0.2) - fog-core (~> 1.0) - multi_json (~> 1.10) - fog-local (0.3.0) - fog-core (~> 1.27) - fog-powerdns (0.1.1) - fog-core (~> 1.27) - fog-json (~> 1.0) - fog-xml (~> 0.1) - fog-profitbricks (0.0.5) - fog-core - fog-xml - nokogiri - fog-radosgw (0.0.5) - fog-core (>= 1.21.0) - fog-json - fog-xml (>= 0.0.1) - fog-riakcs (0.1.0) - fog-core - fog-json - fog-xml - fog-sakuracloud (1.7.5) - fog-core - fog-json - fog-serverlove (0.1.2) - fog-core - fog-json - fog-softlayer (1.1.2) - fog-core - fog-json - fog-storm_on_demand (0.1.1) - fog-core - fog-json - fog-terremark (0.1.0) - fog-core - fog-xml - fog-vmfusion (0.1.0) - fission - fog-core - fog-voxel (0.1.0) - fog-core - fog-xml - fog-xml (0.1.2) - fog-core - nokogiri (~> 1.5, >= 1.5.11) - formatador (0.2.5) - gh (0.14.0) - addressable - backports - faraday (~> 0.8) - multi_json (~> 1.0) - net-http-persistent (>= 2.7) - net-http-pipeline - google-api-client (0.9.4) - addressable (~> 2.3) - googleauth (~> 0.5) - httpclient (~> 2.7) - hurley (~> 0.1) - memoist (~> 0.11) - mime-types (>= 1.6) - representable (~> 2.3.0) - retriable (~> 2.0) - thor (~> 0.19) - googleauth (0.5.1) - faraday (~> 0.9) - jwt (~> 1.4) - logging (~> 2.0) - memoist (~> 0.12) - multi_json (~> 1.11) - os (~> 0.9) - signet (~> 0.7) + diff-lcs (1.3) + docile (1.3.1) + facter (2.5.1) + facterdb (0.5.2) + facter + jgrep hiera (1.3.4) json_pure - highline (1.7.8) - hocon (1.1.1) - http-cookie (1.0.2) - domain_name (~> 0.5) - httpclient (2.8.0) - hurley (0.2) - inch (0.7.1) - pry - sparkr (>= 0.2.0) - term-ansicolor - yard (~> 0.8.7.5) - inflecto (0.0.2) - inifile (2.0.2) - ipaddress (0.8.3) - json (1.8.3) - json_pure (2.0.1) - jwt (1.5.4) - launchy (2.4.3) - addressable (~> 2.3) - little-plugger (1.1.4) - logging (2.1.0) - little-plugger (~> 1.1) - multi_json (~> 1.10) - memoist (0.14.0) + jgrep (1.5.0) + json (2.1.0) + json_pure (2.1.0) + mcollective-client (2.12.1) + json + stomp + systemu metaclass (0.0.4) - metadata-json-lint (0.0.11) + metadata-json-lint (1.1.0) json + semantic_puppet (>= 0.1.2, < 2.0.0) spdx-licenses (~> 1.0) method_source (0.8.2) - mime-types (2.99.2) mini_portile2 (2.1.0) - minitest (5.9.0) - mocha (1.1.0) + mocha (1.5.0) metaclass (~> 0.0.1) - multi_json (1.12.1) - multipart-post (2.0.0) - net-http-persistent (2.9.4) - net-http-pipeline (1.0.1) - net-scp (1.2.1) - net-ssh (>= 2.6.5) - net-ssh (2.9.4) - net-telnet (0.1.1) - netrc (0.11.0) - nokogiri (1.6.8) + nokogiri (1.6.8.1) mini_portile2 (~> 2.1.0) - pkg-config (~> 1.1.7) - open_uri_redirections (0.2.1) - os (0.9.6) - pkg-config (1.1.7) + os (1.0.0) pry (0.10.4) coderay (~> 1.1.0) method_source (~> 0.8.1) @@ -265,132 +47,69 @@ GEM facter (> 1.6, < 3) hiera (~> 1.0) json_pure - puppet-blacksmith (3.4.0) - puppet (>= 2.7.16) - rest-client (~> 1.8.0) - puppet-lint (2.0.0) - puppet-syntax (2.1.0) + puppet-lint (2.3.5) + puppet-syntax (2.4.1) rake - puppetlabs_spec_helper (1.1.1) - mocha - puppet-lint - puppet-syntax - rake - rspec-puppet - pusher-client (0.6.2) - json - websocket (~> 1.0) - rake (11.2.2) - rbvmomi (1.8.2) - builder - nokogiri (>= 1.4.1) - trollop - representable (2.3.0) - uber (~> 0.0.7) - require_all (1.3.3) - rest-client (1.8.0) - http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 3.0) - netrc (~> 0.7) - retriable (2.1.0) - rspec (3.4.0) - rspec-core (~> 3.4.0) - rspec-expectations (~> 3.4.0) - rspec-mocks (~> 3.4.0) - rspec-core (3.4.4) - rspec-support (~> 3.4.0) - rspec-expectations (3.4.0) + puppetlabs_spec_helper (2.9.1) + mocha (~> 1.0) + puppet-lint (~> 2.0) + puppet-syntax (~> 2.0) + rspec-puppet (~> 2.0) + rake (12.2.1) + rspec (3.7.0) + rspec-core (~> 3.7.0) + rspec-expectations (~> 3.7.0) + rspec-mocks (~> 3.7.0) + rspec-core (3.7.1) + rspec-support (~> 3.7.0) + rspec-expectations (3.7.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.4.0) + rspec-support (~> 3.7.0) rspec-its (1.2.0) rspec-core (>= 3.0.0) rspec-expectations (>= 3.0.0) - rspec-mocks (3.4.1) + rspec-mocks (3.7.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.4.0) - rspec-puppet (2.3.2) + rspec-support (~> 3.7.0) + rspec-puppet (2.6.13) rspec - rspec-support (3.4.1) - rsync (1.0.9) + rspec-puppet-facts (1.9.0) + facter + facterdb (>= 0.5.0) + json + mcollective-client + puppet + rspec-support (3.7.1) ruby-augeas (0.5.0) - serverspec (2.36.0) - multi_json - rspec (~> 3.0) - rspec-its - specinfra (~> 2.53) - sfl (2.2) - signet (0.7.3) - addressable (~> 2.3) - faraday (~> 0.9) - jwt (~> 1.5) - multi_json (~> 1.10) - simplecov (0.12.0) - docile (~> 1.1.0) + semantic_puppet (1.0.2) + simplecov (0.16.1) + docile (~> 1.1) json (>= 1.8, < 3) simplecov-html (~> 0.10.0) - simplecov-html (0.10.0) + simplecov-html (0.10.2) slop (3.6.0) - sparkr (0.4.1) - spdx-licenses (1.1.0) - specinfra (2.59.0) - net-scp - net-ssh (>= 2.7, < 4.0) - net-telnet - sfl - stringify-hash (0.0.2) - term-ansicolor (1.3.2) - tins (~> 1.0) - thor (0.19.1) - tins (1.6.0) - travis (1.8.2) - backports - faraday (~> 0.9) - faraday_middleware (~> 0.9, >= 0.9.1) - gh (~> 0.13) - highline (~> 1.6) - launchy (~> 2.1) - pusher-client (~> 0.4) - typhoeus (~> 0.6, >= 0.6.8) - trollop (2.1.2) - typhoeus (0.8.0) - ethon (>= 0.8.0) - uber (0.0.15) - unf (0.1.4) - unf_ext - unf_ext (0.0.7.2) - vagrant-wrapper (2.0.3) - websocket (1.2.3) - yard (0.8.7.6) + spdx-licenses (1.2.0) + stomp (1.4.4) + systemu (2.6.5) PLATFORMS ruby DEPENDENCIES - augeas - beaker - beaker-rspec - codeclimate-test-reporter - coveralls - docker-api facter - inch - json (= 1.8.3) - metadata-json-lint - mime-types (= 2.99.2) - net-ssh (= 2.9.4) + metadata-json-lint (< 1.2.2) nokogiri (~> 1.6.8) os pry-debugger puppet (~> 3.0) - puppet-blacksmith puppet-lint puppetlabs_spec_helper rake - rspec-core (= 3.4.4) - rspec-puppet (= 2.3.2) + rspec-its + rspec-puppet + rspec-puppet-facts ruby-augeas simplecov - specinfra (= 2.59.0) - tins (~> 1.6.0) - travis - vagrant-wrapper + +BUNDLED WITH + 1.16.2 diff --git a/gemfiles/Gemfile20 b/gemfiles/Gemfile20 old mode 100644 new mode 100755 index 1e36678..f3ace72 --- a/gemfiles/Gemfile20 +++ b/gemfiles/Gemfile20 @@ -1,37 +1,23 @@ +#!/usr/bin/env ruby source ENV['GEM_SOURCE'] || 'https://rubygems.org' group :test do - gem 'rake', :require => false unless dependencies.map {|dep| dep.name}.include?('rake') - # TODO: Remove this explicitly pinned version by the time ticket gh-org/puppet-jboss#84 is closed. - gem 'rspec-puppet', '2.3.2', :require => false + gem 'rake', :require => false unless dependencies.map(&:name).include?('rake') + gem 'rspec-puppet', :require => false + gem 'rspec-its', :require => false gem 'puppetlabs_spec_helper', :require => false gem 'puppet-lint', :require => false gem 'metadata-json-lint', :require => false gem 'os', :require => false - # TODO: Pinned because beaker is supported only MRI >=2.2, remove this - # explicitly pinned version by the time ticket gh-org/puppet-jboss#96 is closed. - gem 'beaker', '< 3.1.0', :require => false - gem 'beaker-rspec', '< 6.0.0', :require => false - gem 'docker-api', :require => false - gem 'coveralls', :require => false - gem 'codeclimate-test-reporter', :require => false gem 'simplecov', :require => false - if facterver = ENV['FACTER_VERSION'] - gem 'facter', facterver, :require => false - else - gem 'facter', :require => false - end - gem 'puppet', '~> 3.0', :require => false + gem 'facter', ENV['FACTER_GEM_VERSION'], :require => false + gem 'puppet', ENV['PUPPET_GEM_VERSION'] || '~> 3.0', :require => false gem 'ruby-augeas', :require => false - gem 'augeas', :require => false gem 'nokogiri', '~> 1.6.8', :require => false + gem 'rspec-puppet-facts', :require => false end group :development do - gem 'inch', :require => false - gem 'vagrant-wrapper', :require => false - gem 'travis', :require => false - gem 'puppet-blacksmith', :require => false gem 'pry-byebug', :require => false end diff --git a/gemfiles/Gemfile20.lock b/gemfiles/Gemfile20.lock index 0d9a03b..74fad35 100644 --- a/gemfiles/Gemfile20.lock +++ b/gemfiles/Gemfile20.lock @@ -1,402 +1,110 @@ GEM remote: https://rubygems.org/ specs: - CFPropertyList (2.3.4) - addressable (2.4.0) - augeas (0.6.4) - aws-sdk-v1 (1.66.0) - json (~> 1.4) - nokogiri (>= 1.4.4) - backports (3.6.8) - beaker (2.52.0) - aws-sdk-v1 (~> 1.57) - beaker-answers (~> 0.0) - beaker-hiera (~> 0.0) - beaker-hostgenerator - beaker-pe (~> 0.0) - docker-api - fission (~> 0.4) - fog (~> 1.25, < 1.35.0) - fog-google (~> 0.0.9) - google-api-client (~> 0.8, < 0.9.5) - hocon (~> 1.0) - in-parallel (~> 0.1) - inifile (~> 2.0) - json (~> 1.8) - mime-types (~> 2.99) - minitest (~> 5.4) - net-scp (~> 1.2) - net-ssh (~> 2.9) - open_uri_redirections (~> 0.2.1) - public_suffix (< 1.5.0) - rbvmomi (~> 1.8, < 1.9.0) - rsync (~> 1.0.9) - stringify-hash (~> 0.0) - unf (~> 0.1) - beaker-answers (0.14.0) - hocon (~> 1.0) - require_all (~> 1.3.2) - stringify-hash (~> 0.0.0) - beaker-hiera (0.1.1) - stringify-hash (~> 0.0.0) - beaker-hostgenerator (0.8.2) - deep_merge (~> 1.0) - stringify-hash (~> 0.0.0) - beaker-pe (0.12.1) - stringify-hash (~> 0.0.0) - beaker-rspec (5.6.0) - beaker (~> 2.0) - rspec - serverspec (~> 2) - specinfra (~> 2) - builder (3.2.3) + addressable (2.5.2) + public_suffix (>= 2.0.2, < 4.0) byebug (9.0.6) - codeclimate-test-reporter (1.0.5) - simplecov - coderay (1.1.1) - coveralls (0.8.19) - json (>= 1.8, < 3) - simplecov (~> 0.12.0) - term-ansicolor (~> 1.3) - thor (~> 0.19.1) - tins (~> 1.6) - deep_merge (1.1.1) + coderay (1.1.2) diff-lcs (1.3) - docile (1.1.5) - docker-api (1.33.1) - excon (>= 0.38.0) - json - domain_name (0.5.20161129) - unf (>= 0.0.5, < 1.0.0) - ethon (0.10.1) - ffi (>= 1.3.0) - excon (0.54.0) - facter (2.4.6) - faraday (0.11.0) - multipart-post (>= 1.2, < 3) - faraday_middleware (0.11.0.1) - faraday (>= 0.7.4, < 1.0) - fast_gettext (1.1.0) - ffi (1.9.17) - fission (0.5.0) - CFPropertyList (~> 2.2) - fog (1.34.0) - fog-atmos - fog-aws (>= 0.6.0) - fog-brightbox (~> 0.4) - fog-core (~> 1.32) - fog-dynect (~> 0.0.2) - fog-ecloud (~> 0.1) - fog-google (>= 0.0.2) - fog-json - fog-local - fog-powerdns (>= 0.1.1) - fog-profitbricks - fog-radosgw (>= 0.0.2) - fog-riakcs - fog-sakuracloud (>= 0.0.4) - fog-serverlove - fog-softlayer - fog-storm_on_demand - fog-terremark - fog-vmfusion - fog-voxel - fog-xml (~> 0.1.1) - ipaddress (~> 0.5) - nokogiri (~> 1.5, >= 1.5.11) - fog-atmos (0.1.0) - fog-core - fog-xml - fog-aws (1.2.0) - fog-core (~> 1.38) - fog-json (~> 1.0) - fog-xml (~> 0.1) - ipaddress (~> 0.8) - fog-brightbox (0.11.0) - fog-core (~> 1.22) - fog-json - inflecto (~> 0.0.2) - fog-core (1.43.0) - builder - excon (~> 0.49) - formatador (~> 0.2) - fog-dynect (0.0.3) - fog-core - fog-json - fog-xml - fog-ecloud (0.3.0) - fog-core - fog-xml - fog-google (0.0.9) - fog-core - fog-json - fog-xml - fog-json (1.0.2) - fog-core (~> 1.0) - multi_json (~> 1.10) - fog-local (0.3.1) - fog-core (~> 1.27) - fog-powerdns (0.1.1) - fog-core (~> 1.27) - fog-json (~> 1.0) - fog-xml (~> 0.1) - fog-profitbricks (3.0.0) - fog-core (~> 1.42) - fog-json (~> 1.0) - fog-radosgw (0.0.5) - fog-core (>= 1.21.0) - fog-json - fog-xml (>= 0.0.1) - fog-riakcs (0.1.0) - fog-core - fog-json - fog-xml - fog-sakuracloud (1.7.5) - fog-core - fog-json - fog-serverlove (0.1.2) - fog-core - fog-json - fog-softlayer (1.1.4) - fog-core - fog-json - fog-storm_on_demand (0.1.1) - fog-core - fog-json - fog-terremark (0.1.0) - fog-core - fog-xml - fog-vmfusion (0.1.0) - fission - fog-core - fog-voxel (0.1.0) - fog-core - fog-xml - fog-xml (0.1.2) - fog-core - nokogiri (~> 1.5, >= 1.5.11) - formatador (0.2.5) - gettext (3.2.2) - locale (>= 2.0.5) - text (>= 1.3.0) - gettext-setup (0.13) - fast_gettext (~> 1.1.0) - gettext (>= 3.0.2) - locale - gh (0.15.0) - addressable (~> 2.4.0) - backports - faraday (~> 0.8) - multi_json (~> 1.0) - net-http-persistent (~> 2.9) - net-http-pipeline - google-api-client (0.9.4) - addressable (~> 2.3) - googleauth (~> 0.5) - httpclient (~> 2.7) - hurley (~> 0.1) - memoist (~> 0.11) - mime-types (>= 1.6) - representable (~> 2.3.0) - retriable (~> 2.0) - thor (~> 0.19) - googleauth (0.5.1) - faraday (~> 0.9) - jwt (~> 1.4) - logging (~> 2.0) - memoist (~> 0.12) - multi_json (~> 1.11) - os (~> 0.9) - signet (~> 0.7) + docile (1.3.1) + facter (2.5.1) + facterdb (0.5.2) + facter + jgrep hiera (1.3.4) json_pure - highline (1.7.8) - hocon (1.2.4) - http-cookie (1.0.3) - domain_name (~> 0.5) - httpclient (2.8.3) - hurley (0.2) - in-parallel (0.1.15) - inch (0.7.1) - pry - sparkr (>= 0.2.0) - term-ansicolor - yard (~> 0.8.7.5) - inflecto (0.0.2) - inifile (2.0.2) - ipaddress (0.8.3) - json (1.8.6) - json_pure (2.0.3) - jwt (1.5.6) - launchy (2.4.3) - addressable (~> 2.3) - little-plugger (1.1.4) - locale (2.1.2) - logging (2.1.0) - little-plugger (~> 1.1) - multi_json (~> 1.10) - memoist (0.15.0) - metaclass (0.0.4) - metadata-json-lint (1.0.0) + jgrep (1.5.0) + json (2.1.0) + json-schema (2.8.0) + addressable (>= 2.4) + json_pure (2.1.0) + mcollective-client (2.12.1) json - semantic_puppet (>= 0.1.2, < 2.0.0) + stomp + systemu + metaclass (0.0.4) + metadata-json-lint (2.1.0) + json-schema (~> 2.8) spdx-licenses (~> 1.0) - method_source (0.8.2) - mime-types (2.99.3) + method_source (0.9.0) mini_portile2 (2.1.0) - minitest (5.10.1) - mocha (1.2.1) + mocha (1.5.0) metaclass (~> 0.0.1) - multi_json (1.12.1) - multipart-post (2.0.0) - net-http-persistent (2.9.4) - net-http-pipeline (1.0.1) - net-scp (1.2.1) - net-ssh (>= 2.6.5) - net-ssh (2.9.4) - net-telnet (0.1.1) - netrc (0.11.0) nokogiri (1.6.8.1) mini_portile2 (~> 2.1.0) - open_uri_redirections (0.2.1) - os (0.9.6) - pry (0.10.4) + os (1.0.0) + pry (0.11.3) coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) - pry-byebug (3.4.2) - byebug (~> 9.0) + method_source (~> 0.9.0) + pry-byebug (3.4.3) + byebug (>= 9.0, < 9.1) pry (~> 0.10) - public_suffix (1.4.6) + public_suffix (2.0.5) puppet (3.8.7) facter (> 1.6, < 3) hiera (~> 1.0) json_pure - puppet-blacksmith (3.4.0) - puppet (>= 2.7.16) - rest-client (~> 1.8.0) - puppet-lint (2.1.0) - puppet-syntax (2.2.0) + puppet-lint (2.3.5) + puppet-syntax (2.4.1) rake - puppetlabs_spec_helper (1.2.2) + puppetlabs_spec_helper (2.9.1) mocha (~> 1.0) puppet-lint (~> 2.0) puppet-syntax (~> 2.0) rspec-puppet (~> 2.0) - pusher-client (0.6.2) - json - websocket (~> 1.0) - rake (12.0.0) - rbvmomi (1.8.2) - builder - nokogiri (>= 1.4.1) - trollop - representable (2.3.0) - uber (~> 0.0.7) - require_all (1.3.3) - rest-client (1.8.0) - http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 3.0) - netrc (~> 0.7) - retriable (2.1.0) - rspec (3.5.0) - rspec-core (~> 3.5.0) - rspec-expectations (~> 3.5.0) - rspec-mocks (~> 3.5.0) - rspec-core (3.5.4) - rspec-support (~> 3.5.0) - rspec-expectations (3.5.0) + rake (12.3.1) + rspec (3.7.0) + rspec-core (~> 3.7.0) + rspec-expectations (~> 3.7.0) + rspec-mocks (~> 3.7.0) + rspec-core (3.7.1) + rspec-support (~> 3.7.0) + rspec-expectations (3.7.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.5.0) + rspec-support (~> 3.7.0) rspec-its (1.2.0) rspec-core (>= 3.0.0) rspec-expectations (>= 3.0.0) - rspec-mocks (3.5.0) + rspec-mocks (3.7.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.5.0) - rspec-puppet (2.3.2) + rspec-support (~> 3.7.0) + rspec-puppet (2.6.13) rspec - rspec-support (3.5.0) - rsync (1.0.9) + rspec-puppet-facts (1.9.0) + facter + facterdb (>= 0.5.0) + json + mcollective-client + puppet + rspec-support (3.7.1) ruby-augeas (0.5.0) - semantic_puppet (0.1.4) - gettext-setup (>= 0.3) - serverspec (2.38.0) - multi_json - rspec (~> 3.0) - rspec-its - specinfra (~> 2.53) - sfl (2.3) - signet (0.7.3) - addressable (~> 2.3) - faraday (~> 0.9) - jwt (~> 1.5) - multi_json (~> 1.10) - simplecov (0.12.0) - docile (~> 1.1.0) + simplecov (0.16.1) + docile (~> 1.1) json (>= 1.8, < 3) simplecov-html (~> 0.10.0) - simplecov-html (0.10.0) - slop (3.6.0) - sparkr (0.4.1) - spdx-licenses (1.1.0) - specinfra (2.66.5) - net-scp - net-ssh (>= 2.7, < 5.0) - net-telnet - sfl - stringify-hash (0.0.2) - term-ansicolor (1.4.0) - tins (~> 1.0) - text (1.3.1) - thor (0.19.4) - tins (1.13.0) - travis (1.8.5) - backports - faraday (~> 0.9) - faraday_middleware (~> 0.9, >= 0.9.1) - gh (~> 0.13) - highline (~> 1.6) - launchy (~> 2.1) - pusher-client (~> 0.4) - typhoeus (~> 0.6, >= 0.6.8) - trollop (2.1.2) - typhoeus (0.8.0) - ethon (>= 0.8.0) - uber (0.0.15) - unf (0.1.4) - unf_ext - unf_ext (0.0.7.2) - vagrant-wrapper (2.0.3) - websocket (1.2.3) - yard (0.8.7.6) + simplecov-html (0.10.2) + spdx-licenses (1.2.0) + stomp (1.4.4) + systemu (2.6.5) PLATFORMS ruby DEPENDENCIES - augeas - beaker (< 3.1.0) - beaker-rspec (< 6.0.0) - codeclimate-test-reporter - coveralls - docker-api facter - inch metadata-json-lint nokogiri (~> 1.6.8) os pry-byebug puppet (~> 3.0) - puppet-blacksmith puppet-lint puppetlabs_spec_helper rake - rspec-puppet (= 2.3.2) + rspec-its + rspec-puppet + rspec-puppet-facts ruby-augeas simplecov - travis - vagrant-wrapper BUNDLED WITH - 1.14.3 + 1.15.1 diff --git a/gemfiles/quirks/file.rb b/gemfiles/quirks/file.rb new file mode 100644 index 0000000..07a17c0 --- /dev/null +++ b/gemfiles/quirks/file.rb @@ -0,0 +1,10 @@ +unless File.respond_to? :absolute_path + # Overriden Ruby class (for Ruby 1.8) + class File + class << self + def absolute_path(path, directory = Dir.pwd) + File.expand_path(path, directory) + end + end + end +end diff --git a/lib/puppet_x/coi/jboss.rb b/lib/puppet_x/coi/jboss.rb index 7ddf552..adb1703 100644 --- a/lib/puppet_x/coi/jboss.rb +++ b/lib/puppet_x/coi/jboss.rb @@ -9,6 +9,7 @@ def self.require_relative(relative_path, lvl = 0) file = './' if ['(eval)', '(pry)', ''].include?(file) file = File.dirname(file) path = File.expand_path(File.join(file, relative_path)) + path = Pathname.new(path + '.rb').realpath.to_s Kernel.require(path) end diff --git a/lib/puppet_x/coi/jboss/internal/logic_creator.rb b/lib/puppet_x/coi/jboss/internal/logic_creator.rb index cda3967..0599492 100644 --- a/lib/puppet_x/coi/jboss/internal/logic_creator.rb +++ b/lib/puppet_x/coi/jboss/internal/logic_creator.rb @@ -12,15 +12,19 @@ def initialize(auditor, resource, provider, compilator) end # Method that will return list of commands based on current state - # @param {Puppet_X::Coi::Jboss::Provider::SecurityDomain::PreWildFlyProvider| Puppet_X::Coi::Jboss::Provider::SecurityDomain::PostWildFlyProvider} + # @param {Puppet_X::Coi::Jboss::Provider::SecurityDomain::PreWildFlyProvider| + # Puppet_X::Coi::Jboss::Provider::SecurityDomain::PostWildFlyProvider} # @return [Hash] commands Hash with commands that will be executed, key is message that will # be displayed and value is command def decide state = @auditor.fetch_securtydomain_state commands = [] unless state.cache_default? - command = @compilator.compile(@resource[:runasdomain], - @resource[:profile], "/subsystem=security/security-domain=#{@resource[:name]}:add(cache-type=default)") + command = @compilator.compile( + @resource[:runasdomain], + @resource[:profile], + "/subsystem=security/security-domain=#{@resource[:name]}:add(cache-type=default)" + ) commands.push(['Security Domain Cache Type', command]) end diff --git a/lib/puppet_x/coi/jboss/provider/jmsqueue.rb b/lib/puppet_x/coi/jboss/provider/jmsqueue.rb index 215d0cf..32166c3 100644 --- a/lib/puppet_x/coi/jboss/provider/jmsqueue.rb +++ b/lib/puppet_x/coi/jboss/provider/jmsqueue.rb @@ -4,57 +4,32 @@ module Puppet_X::Coi::Jboss::Provider::Jmsqueue # Method that creates jms-queue in JBoss instance. def create - if is_runasdomain - profile = "--profile=#{@resource[:profile]}" - else - profile = '' - end + profile = calc_profile entries = @resource[:entries].join '", "' - if not entries.empty? - entries = '["%s"]' % entries - else - raise "Array of entries can not be empty" - end + raise 'Array of entries can not be empty' if entries.empty? + entries = format('["%s"]', entries) durable = ToBooleanConverter.new(@resource[:durable]).to_bool - extcmd = "/extension=org.jboss.as.messaging" - if not execute("#{extcmd}:read-resource()")[:result] - bringUp "Extension - messaging", "#{extcmd}:add()" - end - syscmd = compilecmd "/subsystem=messaging" - if not execute("#{syscmd}:read-resource()")[:result] - bringUp "Subsystem - messaging", "#{syscmd}:add()" - end - hornetcmd = compilecmd "/subsystem=messaging/hornetq-server=default" - if not execute("#{hornetcmd}:read-resource()")[:result] - bringUp "Default HornetQ", "#{hornetcmd}:add()" - end - cmd = "jms-queue #{profile} add --queue-address=#{@resource[:name]} --entries=#{entries} --durable=#{durable.to_s}" - bringUp "JMS Queue", cmd + ensure_default_hornetq + cmd = "jms-queue #{profile} add --queue-address=#{@resource[:name]} " \ + "--entries=#{entries} --durable=#{durable}" + bringUp 'JMS Queue', cmd end # Method to remove jms-queue from Jboss instance. def destroy - if is_runasdomain - profile = "--profile=#{@resource[:profile]}" - else - profile = '' - end + profile = calc_profile cmd = "jms-queue #{profile} remove --queue-address=#{@resource[:name]}" - bringDown "JMS Queue", cmd + bringDown 'JMS Queue', cmd end # Method to check if there is jms-queue. Methods calls read-resource to validate if jms-queue is present. def exists? - $data = nil - cmd = compilecmd "/subsystem=messaging/hornetq-server=default/jms-queue=#{@resource[:name]}:read-resource()" - res = executeAndGet cmd - - if not res[:result] - Puppet.debug "JMS Queue do not exists" + result = loaddata + unless result[:result] + Puppet.debug 'JMS Queue do not exists' return false end - $data = res[:data] - return true + true end # Standard getter for durable value. @@ -62,43 +37,68 @@ def durable trace 'durable' Puppet.debug "Durable given: #{@resource[:durable].inspect}" # normalization - ToBooleanConverter.new($data['durable']).to_bool.to_s + ToBooleanConverter.new(@data['durable']).to_bool.to_s end # Standard setter for durable value. # # @param {Boolean} value a value of durable, can be true or false - def durable= value - trace 'durable= %s' % value.to_s - setattr 'durable', ('"%s"' % ToBooleanConverter.new(value).to_bool) + def durable=(value) + trace format('durable= %s', value.to_s) + setattr 'durable', format('"%s"', ToBooleanConverter.new(value).to_bool) end # Standard getter for entries value. def entries trace 'entries' - $data['entries'] + @data['entries'] end # Standard setter for entries value. # # @param {Array} value a value of entries - def entries= value - trace 'entries= %s' % value.inspect + def entries=(value) + trace format('entries= %s', value.inspect) entries = value.join '", "' - if not entries.empty? - entries = '["%s"]' % entries - else - raise "Array of entries can not be empty" - end + raise 'Array of entries can not be empty' if entries.empty? + + entries = format('["%s"]', entries) setattr 'entries', entries end private + def calc_profile + if is_runasdomain + "--profile=#{@resource[:profile]}" + else + '' + end + end + + def ensure_default_hornetq + bring_up_if_needed 'Extension - messaging', '/extension=org.jboss.as.messaging' + bring_up_if_needed 'Subsystem - messaging', compilecmd('/subsystem=messaging') + bring_up_if_needed 'Default HornetQ', compilecmd('/subsystem=messaging/hornetq-server=default') + end + + def bring_up_if_needed(label, clipath) + bringUp label, "#{clipath}:add()" unless execute("#{clipath}:read-resource()")[:result] + end + + def loaddata + return unless @data.nil? + @data = nil + cmd = compilecmd "/subsystem=messaging/hornetq-server=default/jms-queue=#{@resource[:name]}:read-resource()" + res = executeAndGet cmd + @data = res[:data] + res + end + # Methods set attributes for messaging to default hornetq-server # @param {String} name a key for representing name. # @param {Object} value a value of attribute - def setattr name, value + def setattr(name, value) setattribute_raw "/subsystem=messaging/hornetq-server=default/jms-queue=#{@resource[:name]}", name, value end end diff --git a/manifests/domain/server.pp b/manifests/domain/server.pp index 7052123..8bd31be 100644 --- a/manifests/domain/server.pp +++ b/manifests/domain/server.pp @@ -10,10 +10,10 @@ # [*name*] # **This is a namevar**. Standard Puppet namevar indicates name of this virtual server (instance). # [*group*] -# This parameter indicates a server group that this virtual server should be member of. If you are setting +# This parameter indicates a server group that this virtual server should be member of. If you are setting # `ensure` parameter to `running` this is required to be set. # [*ensure*] -# This is standard ensure puppet parameter. It is extended to support also `running` and `stopped` values +# This is standard ensure puppet parameter. It is extended to support also `running` and `stopped` values # as an addition to standard `present` and `absent`. # [*host*] # This parameter indicates a server that should be host (controller) to this virtual server (instance). By @@ -22,7 +22,7 @@ # This parameter indicates whether this virtual server (instance), should be automatically started when # host (controller) starts. Be default it is set to `true`. # [*socket_binding_group*] -# This parameter indicates that this virtual server should use value of it as socket binding group, By +# This parameter indicates that this virtual server should use value of it as socket binding group, By # default it is set to `undef` and not being used. # [*socket_binding_port_offset*] # This parameter indicates offset on JBoss ports, defined by socket binding group. It will shift ports up @@ -103,8 +103,8 @@ controller => $controller, } } - Jboss::Domain::Servergroup[$group] -> - Jboss::Clientry["jboss::domain::server(${name})"] + Jboss::Domain::Servergroup[$group] + -> Jboss::Clientry["jboss::domain::server(${name})"] } } diff --git a/manifests/domain/servergroup.pp b/manifests/domain/servergroup.pp index f863f22..3a2fea2 100644 --- a/manifests/domain/servergroup.pp +++ b/manifests/domain/servergroup.pp @@ -1,7 +1,7 @@ # == Define: jboss::domain::servergroup # # This defined type simplifies creation and removal and updating JBoss domain server group that can enforce -# same configuration (profile, deployments and JVM settings) across multiple servers on multiple host +# same configuration (profile, deployments and JVM settings) across multiple servers on multiple host # controllers. This is only possible in domain mode. # # === Parameters @@ -19,17 +19,17 @@ # [*maxheapsize*] # This parameters configures JVM Heap maximal size, By default it is equal to `1303m` # [*profile*] -# This parameter configure profile to be active on all servers within this group. By default +# This parameter configure profile to be active on all servers within this group. By default # it is equal to value of `$::jboss::profile`. # [*socket_binding_group*] -# This parameter indicates that server instances within this group should use value of it as socket +# This parameter indicates that server instances within this group should use value of it as socket # binding group, By default it is set to `full-sockets`. # [*socket_binding_port_offset*] # This parameter indicates offset on JBoss ports, defined by socket binding group. It will shift ports up # or down by amount described. The format is simply `n` or `-n`, for example: `120` will shift all ports by # 120 up making standard http port being now `8080 + 120 = 8200`. By default it is equal to `0`. # [*system_properties*] -# This parameter can be used to set system properties that will be passed to server instance java +# This parameter can be used to set system properties that will be passed to server instance java # process as `-D` parameters. It's empty by default. # [*jvmopts*] # This property can be set to configure additional JVM options to be passed to server instances in @@ -102,12 +102,10 @@ } if $ensure == 'present' { - JBoss::Clientry["jboss::domain::servergroup(${name})"] -> - JBoss::Clientry["jboss::domain::servergroup::jvm(${name})"] - } else { - JBoss::Clientry["jboss::domain::servergroup::jvm(${name})"] -> JBoss::Clientry["jboss::domain::servergroup(${name})"] + -> JBoss::Clientry["jboss::domain::servergroup::jvm(${name})"] + } else { + JBoss::Clientry["jboss::domain::servergroup::jvm(${name})"] + -> JBoss::Clientry["jboss::domain::servergroup(${name})"] } } - - diff --git a/manifests/interface.pp b/manifests/interface.pp index 0f753e8..920f4d1 100644 --- a/manifests/interface.pp +++ b/manifests/interface.pp @@ -157,18 +157,16 @@ } if jboss_to_bool($::jboss_running) { - Jboss::Clientry { - ensure => $ensure, - controller => $controller, - runasdomain => $runasdomain, - profile => $profile, - } $entrypath = $runasdomain ? { true => "/host=${jboss::hostname}/interface=${interface_name}", default => "/interface=${interface_name}", } jboss::clientry { $entrypath: - properties => $bind_variables, + ensure => $ensure, + controller => $controller, + runasdomain => $runasdomain, + profile => $profile, + properties => $bind_variables, } } else { $supported_bind_types = keys($bind_variables) diff --git a/manifests/internal/configure/interfaces.pp b/manifests/internal/configure/interfaces.pp index 1f484b9..3adf09b 100644 --- a/manifests/internal/configure/interfaces.pp +++ b/manifests/internal/configure/interfaces.pp @@ -11,19 +11,17 @@ $bind_public = $jboss::params::bind_public $bind_mgmt = $jboss::params::bind_mgmt - Jboss::Interface { - ensure => 'present', - } - $__console_is_sensible = $jboss::internal::runtime::dc::runs_as_controller or $jboss::runasdomain == false if $__console_is_sensible and ($enableconsole or $bind_mgmt != undef){ if $bind_mgmt != undef { jboss::interface { 'management': + ensure => 'present', inet_address => $bind_mgmt, any_address => undef, } } else { jboss::interface { 'management': + ensure => 'present', any_address => true, inet_address => undef, } @@ -32,11 +30,13 @@ if $bind_public != undef { jboss::interface { 'public': + ensure => 'present', any_address => undef, inet_address => $bind_public, } } else { jboss::interface { 'public': + ensure => 'present', any_address => true, inet_address => undef, } diff --git a/manifests/internal/domain/servergroup/foreach.pp b/manifests/internal/domain/servergroup/foreach.pp index 73e3669..2f253e0 100644 --- a/manifests/internal/domain/servergroup/foreach.pp +++ b/manifests/internal/domain/servergroup/foreach.pp @@ -26,10 +26,10 @@ } if $ensure == 'present' { - JBoss::Clientry["jboss::domain::servergroup(${group})"] -> - JBoss::Clientry["jboss::domain::servergroup::sysproperty(${key} => ${value})"] - } else { - JBoss::Clientry["jboss::domain::servergroup::sysproperty(${key} => ${value})"] -> JBoss::Clientry["jboss::domain::servergroup(${group})"] + -> JBoss::Clientry["jboss::domain::servergroup::sysproperty(${key} => ${value})"] + } else { + JBoss::Clientry["jboss::domain::servergroup::sysproperty(${key} => ${value})"] + -> JBoss::Clientry["jboss::domain::servergroup(${group})"] } } diff --git a/manifests/internal/interface/foreach.pp b/manifests/internal/interface/foreach.pp index 25b46fb..db18d38 100644 --- a/manifests/internal/interface/foreach.pp +++ b/manifests/internal/interface/foreach.pp @@ -11,10 +11,6 @@ validate_hash($augeas_defaults) - Augeas { - require => Augeas["ensure present interface ${interface_name}"], - } - $interface_bind_pair = split($name, ':') $bind_type = $interface_bind_pair[1] $bind_value = $bind_variables[$bind_type] @@ -23,13 +19,17 @@ $augeas_params = merge($augeas_defaults, { changes => "rm ${path}/interface[#attribute/name='${interface_name}']/${bind_type}", onlyif => "match ${path}/interface[#attribute/name='${interface_name}']/${bind_type} size != 0", + require => Augeas["ensure present interface ${interface_name}"], }) - ensure_resource('augeas', "interface ${interface_name} rm ${bind_type}", $augeas_params) + $resource_title = "interface ${interface_name} rm ${bind_type}" + } else { $augeas_params = merge($augeas_defaults, { changes => "set ${path}/interface[#attribute/name='${interface_name}']/${bind_type}/#attribute/value '${bind_value}'", onlyif => "get ${path}/interface[#attribute/name='${interface_name}']/${bind_type}/#attribute/value != '${bind_value}'", + require => Augeas["ensure present interface ${interface_name}"], }) - ensure_resource('augeas', "interface ${interface_name} set ${bind_type}", $augeas_params) + $resource_title = "interface ${interface_name} set ${bind_type}" } + ensure_resource('augeas', $resource_title, $augeas_params) } diff --git a/metadata.json b/metadata.json index 248bedd..504076c 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { - "name": "coi/jboss", - "version": "1.2.0", + "name": "coi-jboss", + "version": "1.2.1", "author": "Center of Information Technology COI.gov.pl", "summary": "Installs JBoss EAP and WildFly application servers and manage their resources and applications in either a domain or a stand-alone mode", "license": "Apache-2.0", @@ -13,16 +13,14 @@ { "name": "puppetlabs/concat", "version_requirement": ">= 1.0.0 <2.0.0" } ], "operatingsystem_support": [ - { "operatingsystem": "RedHat", "operatingsystemrelease": [ "5", "6" ] }, - { "operatingsystem": "CentOS", "operatingsystemrelease": [ "5", "6" ] }, - { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "5", "6" ] }, - { "operatingsystem": "Scientific", "operatingsystemrelease": [ "5", "6" ] }, - { "operatingsystem": "Debian", "operatingsystemrelease": [ "6", "7" ] }, - { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "10.04", "12.04", "14.04" ] } + { "operatingsystem": "RedHat", "operatingsystemrelease": [ "6" ] }, + { "operatingsystem": "CentOS", "operatingsystemrelease": [ "6" ] }, + { "operatingsystem": "OracleLinux", "operatingsystemrelease": [ "6" ] }, + { "operatingsystem": "Scientific", "operatingsystemrelease": [ "6" ] }, + { "operatingsystem": "Debian", "operatingsystemrelease": [ "8" ] }, + { "operatingsystem": "Ubuntu", "operatingsystemrelease": [ "14.04" ] } ], "requirements": [ - { "name": "pe", "version_requirement": ">=2.8.0 <4.0.0" }, { "name": "puppet", "version_requirement": ">=2.7.0 <4.0.0" } ] } - diff --git a/spec/acceptance/answers/default.yml b/spec/acceptance/answers/default.yml new file mode 100644 index 0000000..3b4737a --- /dev/null +++ b/spec/acceptance/answers/default.yml @@ -0,0 +1,3 @@ +installer: + mode: Agent + type: pc3x diff --git a/spec/acceptance/answers/pc4x.yml b/spec/acceptance/answers/pc4x.yml new file mode 100644 index 0000000..c040b73 --- /dev/null +++ b/spec/acceptance/answers/pc4x.yml @@ -0,0 +1,3 @@ +installer: + mode: Agent + type: pc4x diff --git a/spec/acceptance/answers/pc5x.yml b/spec/acceptance/answers/pc5x.yml new file mode 100644 index 0000000..a0839cc --- /dev/null +++ b/spec/acceptance/answers/pc5x.yml @@ -0,0 +1,3 @@ +installer: + mode: Agent + type: pc5x diff --git a/spec/acceptance/answers/system.yml b/spec/acceptance/answers/system.yml new file mode 100644 index 0000000..54d29c1 --- /dev/null +++ b/spec/acceptance/answers/system.yml @@ -0,0 +1,3 @@ +installer: + mode: Agent + type: system diff --git a/spec/acceptance/clientry_spec.rb b/spec/acceptance/clientry_spec.rb index d361cd9..c95304d 100644 --- a/spec/acceptance/clientry_spec.rb +++ b/spec/acceptance/clientry_spec.rb @@ -1,17 +1,19 @@ require 'spec_helper_acceptance' -describe 'clientry smoke test', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - let(:baseserver) { Testing::Acceptance::SmokeTestReader.smoke_pp :init } - let(:pp) { Testing::Acceptance::SmokeTestReader.smoke_pp :clientry } +describe 'clientry smoke test' do + let(:baseserver) { example 'jboss' } + let(:pp) { example 'jboss::clientry' } it 'should install base server with no errors' do - apply_manifest(baseserver, :catch_failures => true) + result = apply_manifest(baseserver, :catch_failures => true) + expect(result.exit_code).to be(2) end it 'should add CLI entry with no errors' do - apply_manifest(pp, :catch_failures => true) + result = apply_manifest(pp, :catch_failures => true) + expect(result.exit_code).to be(2) end it 'should work idempotently' do - apply_manifest(pp, :catch_changes => true) + apply_manifest(pp, :catch_changes => true) end describe service('wildfly') do it { is_expected.to be_running } diff --git a/spec/acceptance/datasource_spec.rb b/spec/acceptance/datasource_spec.rb index 4b84ead..e5c2ef6 100644 --- a/spec/acceptance/datasource_spec.rb +++ b/spec/acceptance/datasource_spec.rb @@ -1,17 +1,19 @@ require 'spec_helper_acceptance' -describe 'datasource smoke test', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - let(:baseserver) { Testing::Acceptance::SmokeTestReader.smoke_pp :init } - let(:pp) { Testing::Acceptance::SmokeTestReader.smoke_pp :datasource } +describe 'datasource smoke test' do + let(:baseserver) { example 'jboss' } + let(:pp) { example 'jboss::datasource' } it 'should install base server with no errors' do - apply_manifest(baseserver, :catch_failures => true) + result = apply_manifest(baseserver, :catch_failures => true) + expect(result.exit_code).to be(2) end it 'should add datasource with no errors' do - apply_manifest(pp, :catch_failures => true) + result = apply_manifest(pp, :catch_failures => true) + expect(result.exit_code).to be(2) end it 'should work idempotently' do - apply_manifest(pp, :catch_changes => true) + apply_manifest(pp, :catch_changes => true) end describe service('wildfly') do it { is_expected.to be_running } diff --git a/spec/acceptance/deploy_spec.rb b/spec/acceptance/deploy_spec.rb index 9e79da7..0969015 100644 --- a/spec/acceptance/deploy_spec.rb +++ b/spec/acceptance/deploy_spec.rb @@ -1,19 +1,21 @@ require 'spec_helper_acceptance' -describe 'deploy smoke test', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - let(:baseserver) { Testing::Acceptance::SmokeTestReader.smoke_pp :init } - let(:pp) { Testing::Acceptance::SmokeTestReader.smoke_pp :deploy } +describe 'deploy smoke test' do + let(:baseserver) { example 'jboss' } + let(:pp) { example 'jboss::deploy' } it 'should install base server with no errors' do - apply_manifest(baseserver, :catch_failures => true) + result = apply_manifest(baseserver, :catch_failures => true) + expect(result.exit_code).to be(2) end it 'should deploy artifact with no errors' do - apply_manifest(pp, :catch_failures => true) + result = apply_manifest(pp, :catch_failures => true) + expect(result.exit_code).to be(2) end - context 'verifing idempotency' do + describe 'verifing idempotency' do before(:each) { skip('This not work, GH issue: coi-gov-pl/puppet-jboss#71') } it 'should work idempotently' do - apply_manifest(pp, :catch_changes => true) + apply_manifest(pp, :catch_changes => true) end end describe service('wildfly') do diff --git a/spec/acceptance/init_spec.rb b/spec/acceptance/init_spec.rb index 5c2161b..3b068f5 100644 --- a/spec/acceptance/init_spec.rb +++ b/spec/acceptance/init_spec.rb @@ -1,13 +1,14 @@ require 'spec_helper_acceptance' -describe 'init smoke test', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - let(:pp) { Testing::Acceptance::SmokeTestReader.smoke_pp :init } +describe 'init smoke test' do + let(:pp) { example 'jboss' } it 'should install WildFly 9.x with no errors' do - apply_manifest(pp, :catch_failures => true) + result = apply_manifest(pp, :catch_failures => true) + expect(result.exit_code).to be(2) end it 'should work idempotently' do - apply_manifest(pp, :catch_changes => true) + apply_manifest(pp, :catch_changes => true) end describe service('wildfly') do it { is_expected.to be_running } diff --git a/spec/acceptance/interface_spec.rb b/spec/acceptance/interface_spec.rb index e11b894..37812ae 100644 --- a/spec/acceptance/interface_spec.rb +++ b/spec/acceptance/interface_spec.rb @@ -1,17 +1,19 @@ require 'spec_helper_acceptance' -describe 'interface smoke test', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - let(:baseserver) { Testing::Acceptance::SmokeTestReader.smoke_pp :init } - let(:pp) { Testing::Acceptance::SmokeTestReader.smoke_pp :interface } +describe 'interface smoke test' do + let(:baseserver) { example 'jboss' } + let(:pp) { example 'jboss::interface' } it 'should install base server with no errors' do - apply_manifest(baseserver, :catch_failures => true) + result = apply_manifest(baseserver, :catch_failures => true) + expect(result.exit_code).to be(2) end it 'should add insterface with no errors' do - apply_manifest(pp, :catch_failures => true) + result = apply_manifest(pp, :catch_failures => true) + expect(result.exit_code).to be(2) end it 'should work idempotently' do - apply_manifest(pp, :catch_changes => true) + apply_manifest(pp, :catch_changes => true) end describe service('wildfly') do it { is_expected.to be_running } diff --git a/spec/acceptance/jboss/as7_spec.rb b/spec/acceptance/jboss/as7_spec.rb deleted file mode 100644 index fa27588..0000000 --- a/spec/acceptance/jboss/as7_spec.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'spec_helper_acceptance' - -describe 'jboss::as7 smoke test', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - let(:pp) { Testing::Acceptance::SmokeTestReader.smoke_pp :'jboss::as7' } - - it 'should add install JBoss AS 7 with no errors' do - apply_manifest(pp, :expect_changes => true, :trace => true) - end - it 'should work idempotently' do - apply_manifest(pp, :catch_changes => true, :trace => true) - end - describe service('jboss-as') do - it { is_expected.to be_running } - end - after(:all) do - extend Testing::Acceptance::Cleaner - remove_jboss_installation('jboss-as') - end -end diff --git a/spec/acceptance/jmsqueue_spec.rb b/spec/acceptance/jmsqueue_spec.rb index aa9ac47..1a88a07 100644 --- a/spec/acceptance/jmsqueue_spec.rb +++ b/spec/acceptance/jmsqueue_spec.rb @@ -1,17 +1,19 @@ require 'spec_helper_acceptance' -describe 'jmsqueue smoke test', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - let(:baseserver) { Testing::Acceptance::SmokeTestReader.smoke_pp :init } - let(:pp) { Testing::Acceptance::SmokeTestReader.smoke_pp :jmsqueue } +describe 'jmsqueue smoke test' do + let(:baseserver) { example 'jboss' } + let(:pp) { example 'jboss::jmsqueue' } it 'should install base server with no errors' do - apply_manifest(baseserver, :catch_failures => true) + result = apply_manifest(baseserver, :catch_failures => true) + expect(result.exit_code).to be(2) end it 'should add jmsqueue with no errors' do - apply_manifest(pp, :catch_failures => true) + result = apply_manifest(pp, :catch_failures => true) + expect(result.exit_code).to be(2) end it 'should work idempotently' do - apply_manifest(pp, :catch_changes => true) + apply_manifest(pp, :catch_changes => true) end describe service('wildfly') do it { is_expected.to be_running } diff --git a/spec/acceptance/module_spec.rb b/spec/acceptance/module_spec.rb index dd6068f..66226cf 100644 --- a/spec/acceptance/module_spec.rb +++ b/spec/acceptance/module_spec.rb @@ -1,17 +1,19 @@ require 'spec_helper_acceptance' -describe 'module smoke test', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - let(:baseserver) { Testing::Acceptance::SmokeTestReader.smoke_pp :init } - let(:pp) { Testing::Acceptance::SmokeTestReader.smoke_pp :module } +describe 'module smoke test' do + let(:baseserver) { example 'jboss' } + let(:pp) { example 'jboss::module' } it 'should install base server with no errors' do - apply_manifest(baseserver, :catch_failures => true, :trace => true) + result = apply_manifest(baseserver, :catch_failures => true) + expect(result.exit_code).to be(2) end it 'should add module with no errors' do - apply_manifest(pp, :catch_failures => true, :trace => true) + result = apply_manifest(pp, :catch_failures => true) + expect(result.exit_code).to be(2) end it 'should work idempotently' do - apply_manifest(pp, :catch_changes => true, :trace => true) + apply_manifest(pp, :catch_changes => true) end describe service('wildfly') do it { is_expected.to be_running } diff --git a/spec/acceptance/nodesets/centos-6-docker.yml b/spec/acceptance/nodesets/centos-6-docker.yml new file mode 100644 index 0000000..fe30407 --- /dev/null +++ b/spec/acceptance/nodesets/centos-6-docker.yml @@ -0,0 +1,24 @@ +HOSTS: + centos-6-docker: + platform: el-6-x86_64 + hypervisor: docker + image: centos:6 + docker_cmd: '["/sbin/init"]' + docker_preserve_image: true + docker_image_commands: + - 'cp /bin/true /sbin/mingetty' # Fix for getty 100% cpu -> https://github.com/moby/moby/issues/4040 + - "sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf" + - 'yum install -y crontabs wget tar centos-release-scl' + - 'yum install -y python27-python-pip' + - 'scl enable python27 "pip install puppeter"' + mount_folders: + wget_cache: + host_path: /tmp/docker-cache/wget + container_path: /var/cache/wget + yum_cache: + host_path: /tmp/docker-cache/yum/centos-6-docker + container_path: /var/cache/yum +CONFIG: + trace_limit: 200 + type: foss + log_level: debug diff --git a/spec/acceptance/nodesets/centos-6-pe288-docker.yml b/spec/acceptance/nodesets/centos-6-pe288-docker.yml new file mode 100644 index 0000000..1e05595 --- /dev/null +++ b/spec/acceptance/nodesets/centos-6-pe288-docker.yml @@ -0,0 +1,31 @@ +HOSTS: + centos-6-pe288-docker: + platform: el-6-x86_64 + hypervisor: docker + image: centos:6 + docker_cmd: '["/sbin/init"]' + docker_preserve_image: true + docker_image_commands: + - 'cp /bin/true /sbin/mingetty' + - "sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf" + - 'yum install -y crontabs wget tar' + roles: + - agent + - master + - database + - dashboard + mount_folders: + wget_cache: + host_path: /tmp/docker-cache/wget + container_path: /var/cache/wget + yum_cache: + host_path: /tmp/docker-cache/yum/centos-6-docker + container_path: /var/cache/yum +CONFIG: + type: pe + pe_ver: 2.8.8 + pe_dir: https://s3.amazonaws.com/pe-builds/released/2.8.8 + log_level: verbose +ssh: + password: root + auth_methods: ["password"] diff --git a/spec/acceptance/nodesets/centos-6-vagrant.yml b/spec/acceptance/nodesets/centos-6-vagrant.yml new file mode 100644 index 0000000..b20b6e7 --- /dev/null +++ b/spec/acceptance/nodesets/centos-6-vagrant.yml @@ -0,0 +1,16 @@ +HOSTS: + centos-6-vagrant: + platform: el-6-x86_64 + hypervisor: vagrant + box: bento/centos-6 + mount_folders: + wget_cache: + from: /tmp/vagrant-cache/wget + to: /var/cache/wget + yum_cache: + from: /tmp/vagrant-cache/yum/centos-6-vagrant + to: /var/cache/yum +CONFIG: + trace_limit: 200 + type: foss + log_level: debug diff --git a/spec/acceptance/nodesets/centos-6-x86_64-docker.yml b/spec/acceptance/nodesets/centos-6-x86_64-docker.yml deleted file mode 100644 index 453ce2a..0000000 --- a/spec/acceptance/nodesets/centos-6-x86_64-docker.yml +++ /dev/null @@ -1,19 +0,0 @@ -HOSTS: - centos-6-x64: - platform: el-6-x86_64 - hypervisor : docker - image: centos:6 - docker_preserve_image: true - docker_image_commands: - - "sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf" - - 'yum install -y crontabs wget' - mount_folders: - wget_cache: - host_path: /tmp/wget_cache - container_path: /var/cache/wget - yum_cache: - host_path: /tmp/yum_cache/centos-6-x64 - container_path: /var/cache/yum -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/centos-6-x86_64-openstack.yml b/spec/acceptance/nodesets/centos-6-x86_64-openstack.yml deleted file mode 100644 index 2ce40e2..0000000 --- a/spec/acceptance/nodesets/centos-6-x86_64-openstack.yml +++ /dev/null @@ -1,11 +0,0 @@ -HOSTS: - centos-6-x64: - platform: el-6-x86_64 - hypervisor : openstack - flavor: m1.small - image: centos-6-latest - user: root -CONFIG: - type: foss - log_level: debug - openstack_network: default diff --git a/spec/acceptance/nodesets/centos-6-x86_64-pe288-docker.yml b/spec/acceptance/nodesets/centos-6-x86_64-pe288-docker.yml deleted file mode 100644 index a6fe6b7..0000000 --- a/spec/acceptance/nodesets/centos-6-x86_64-pe288-docker.yml +++ /dev/null @@ -1,21 +0,0 @@ -HOSTS: - centos-6-x64-pe288: - roles: - - master - - agent - - database - - dashboard - platform: el-6-x86_64 - image: centos:centos6 - hypervisor: docker - docker_preserve_image: true - docker_image_commands: - - 'yum install -y crontabs wget' -CONFIG: - type: pe - pe_ver: 2.8.8 - pe_dir: https://s3.amazonaws.com/pe-builds/released/2.8.8 - log_level: verbose -ssh: - password: root - auth_methods: ["password"] diff --git a/spec/acceptance/nodesets/centos-6-x86_64-pe382-docker.yml b/spec/acceptance/nodesets/centos-6-x86_64-pe382-docker.yml deleted file mode 100644 index a4e6ecb..0000000 --- a/spec/acceptance/nodesets/centos-6-x86_64-pe382-docker.yml +++ /dev/null @@ -1,21 +0,0 @@ -HOSTS: - centos-6-x64-pe382: - roles: - - master - - agent - - database - - dashboard - platform: el-6-x86_64 - image: centos:centos6 - hypervisor: docker - docker_preserve_image: true - docker_image_commands: - - 'yum install -y crontabs wget' -CONFIG: - type: pe - pe_ver: 3.8.2 - pe_dir: https://s3.amazonaws.com/pe-builds/released/3.8.2 - log_level: verbose -ssh: - password: root - auth_methods: ["password"] diff --git a/spec/acceptance/nodesets/centos-6-x86_64-vagrant.yml b/spec/acceptance/nodesets/centos-6-x86_64-vagrant.yml deleted file mode 100644 index 0574815..0000000 --- a/spec/acceptance/nodesets/centos-6-x86_64-vagrant.yml +++ /dev/null @@ -1,8 +0,0 @@ -HOSTS: - centos-6-x64: - platform: el-6-x86_64 - hypervisor : vagrant - box : camptocamp/centos-6-x86_64 -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/centos-7-x86_64-docker.yml b/spec/acceptance/nodesets/centos-7-docker.yml similarity index 62% rename from spec/acceptance/nodesets/centos-7-x86_64-docker.yml rename to spec/acceptance/nodesets/centos-7-docker.yml index 4551cf5..33c4d23 100644 --- a/spec/acceptance/nodesets/centos-7-x86_64-docker.yml +++ b/spec/acceptance/nodesets/centos-7-docker.yml @@ -1,20 +1,20 @@ HOSTS: - centos-7-x64: + centos-7-docker: platform: el-7-x86_64 hypervisor : docker image: centos:7 docker_preserve_image: true - docker_cmd: '["/usr/sbin/init"]' + docker_cmd: ["/sbin/init"] docker_image_commands: - - "sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf" - - 'yum install -y crontabs tar wget openssl sysvinit-tools iproute which initscripts' + - 'yum install -y crontabs tar wget openssl sysvinit-tools iproute which initscripts python-pip' mount_folders: wget_cache: - host_path: /tmp/wget_cache + host_path: /tmp/docker-cache/wget container_path: /var/cache/wget yum_cache: - host_path: /tmp/yum_cache/centos-7-x64 + host_path: /tmp/docker-cache/yum/centos-7-docker container_path: /var/cache/yum CONFIG: + trace_limit: 200 type: foss log_level: debug diff --git a/spec/acceptance/nodesets/centos-7-vagrant.yml b/spec/acceptance/nodesets/centos-7-vagrant.yml new file mode 100644 index 0000000..9073250 --- /dev/null +++ b/spec/acceptance/nodesets/centos-7-vagrant.yml @@ -0,0 +1,16 @@ +HOSTS: + centos-7-vagrant: + platform: el-7-x86_64 + hypervisor: vagrant + box: bento/centos-7 + mount_folders: + wget_cache: + from: /tmp/vagrant-cache/wget + to: /var/cache/wget + yum_cache: + from: /tmp/vagrant-cache/yum/centos-7-vagrant + to: /var/cache/yum +CONFIG: + trace_limit: 200 + type: foss + log_level: debug diff --git a/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml b/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml deleted file mode 100644 index b9bb99c..0000000 --- a/spec/acceptance/nodesets/centos-7-x86_64-openstack.yml +++ /dev/null @@ -1,11 +0,0 @@ -HOSTS: - centos-7-x64: - platform: el-7-x86_64 - hypervisor : openstack - flavor: m1.small - image: centos-7-latest - user: centos -CONFIG: - type: foss - log_level: debug - openstack_network: default diff --git a/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml b/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml deleted file mode 100644 index b7e6a04..0000000 --- a/spec/acceptance/nodesets/centos-7-x86_64-vagrant.yml +++ /dev/null @@ -1,8 +0,0 @@ -HOSTS: - centos-7-x64: - platform: el-7-x86_64 - hypervisor : vagrant - box : camptocamp/centos-7-x86_64 -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/debian-6-x86_64-docker.yml b/spec/acceptance/nodesets/debian-6-x86_64-docker.yml deleted file mode 100644 index 6aa1808..0000000 --- a/spec/acceptance/nodesets/debian-6-x86_64-docker.yml +++ /dev/null @@ -1,19 +0,0 @@ -HOSTS: - debian-6-x64: - platform: debian-6-amd64 - hypervisor : docker - image: debian:6 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'apt-get update && apt-get install -y cron locales-all net-tools wget' - mount_folders: - wget_cache: - host_path: /tmp/wget_cache - container_path: /var/cache/wget - apt_cache: - host_path: /tmp/apt_cache/debian-6-amd64 - container_path: /var/cache/apt -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/debian-6-x86_64-openstack.yml b/spec/acceptance/nodesets/debian-6-x86_64-openstack.yml deleted file mode 100644 index 423f4e7..0000000 --- a/spec/acceptance/nodesets/debian-6-x86_64-openstack.yml +++ /dev/null @@ -1,11 +0,0 @@ -HOSTS: - debian-6-x64: - platform: debian-6-amd64 - hypervisor : openstack - flavor: m1.small - image: debian-6-latest - user: debian -CONFIG: - type: foss - log_level: debug - openstack_network: default diff --git a/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml b/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml deleted file mode 100644 index 38a196b..0000000 --- a/spec/acceptance/nodesets/debian-6-x86_64-vagrant.yml +++ /dev/null @@ -1,8 +0,0 @@ -HOSTS: - debian-6-x64: - platform: debian-6-amd64 - hypervisor : vagrant - box : puppetlabs/debian-6.0.10-64-nocm -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/debian-7-x86_64-docker.yml b/spec/acceptance/nodesets/debian-7-x86_64-docker.yml deleted file mode 100644 index 63d3d1a..0000000 --- a/spec/acceptance/nodesets/debian-7-x86_64-docker.yml +++ /dev/null @@ -1,19 +0,0 @@ -HOSTS: - debian-7-x64: - platform: debian-7-amd64 - hypervisor : docker - image: debian:7 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' - docker_image_commands: - - 'apt-get update && apt-get install -y cron locales-all net-tools wget' - mount_folders: - wget_cache: - host_path: /tmp/wget_cache - container_path: /var/cache/wget - apt_cache: - host_path: /tmp/apt_cache/debian-7-amd64 - container_path: /var/cache/apt -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml b/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml deleted file mode 100644 index c16afa4..0000000 --- a/spec/acceptance/nodesets/debian-7-x86_64-openstack.yml +++ /dev/null @@ -1,11 +0,0 @@ -HOSTS: - debian-7-x64: - platform: debian-7-amd64 - hypervisor : openstack - flavor: m1.small - image: debian-7-latest - user: debian -CONFIG: - type: foss - log_level: debug - openstack_network: default diff --git a/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml b/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml deleted file mode 100644 index 572c137..0000000 --- a/spec/acceptance/nodesets/debian-7-x86_64-vagrant.yml +++ /dev/null @@ -1,8 +0,0 @@ -HOSTS: - debian-7-x64: - platform: debian-7-amd64 - hypervisor : vagrant - box : camptocamp/debian-7-amd64 -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/debian-8-x86_64-docker.yml b/spec/acceptance/nodesets/debian-8-docker.yml similarity index 78% rename from spec/acceptance/nodesets/debian-8-x86_64-docker.yml rename to spec/acceptance/nodesets/debian-8-docker.yml index 934fce3..8fd883b 100644 --- a/spec/acceptance/nodesets/debian-8-x86_64-docker.yml +++ b/spec/acceptance/nodesets/debian-8-docker.yml @@ -1,13 +1,12 @@ HOSTS: - debian-8-x64: + debian-8-docker: platform: debian-8-amd64 - hypervisor : docker + hypervisor: docker image: debian:8 docker_preserve_image: true docker_cmd: ["/bin/systemd"] - docker_preserve_image: true docker_image_commands: - - apt-get install -y wget net-tools + - apt-get install -y wget net-tools python-pip python-dev - rm /lib/systemd/system/getty.target mount_folders: wget_cache: @@ -17,5 +16,6 @@ HOSTS: host_path: /tmp/apt_cache/debian-8-amd64 container_path: /var/cache/apt CONFIG: + trace_limit: 200 type: foss log_level: debug diff --git a/spec/acceptance/nodesets/debian-8-vagrant.yml b/spec/acceptance/nodesets/debian-8-vagrant.yml new file mode 100644 index 0000000..3b7950d --- /dev/null +++ b/spec/acceptance/nodesets/debian-8-vagrant.yml @@ -0,0 +1,16 @@ +HOSTS: + debian-8-vagrant: + platform: debian-8-amd64 + hypervisor : vagrant + box : bento/debian-8 + mount_folders: + wget_cache: + from: /tmp/vagrant-cache/wget + to: /var/cache/wget + yum_cache: + from: /tmp/vagrant-cache/yum/debian-8-vagrant + to: /var/cache/yum +CONFIG: + trace_limit: 200 + type: foss + log_level: debug diff --git a/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml b/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml deleted file mode 100644 index 39c20a5..0000000 --- a/spec/acceptance/nodesets/debian-8-x86_64-openstack.yml +++ /dev/null @@ -1,11 +0,0 @@ -HOSTS: - debian-8-x64: - platform: debian-8-amd64 - hypervisor : openstack - flavor: m1.small - image: debian-8-latest - user: debian -CONFIG: - type: foss - log_level: debug - openstack_network: default diff --git a/spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml b/spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml deleted file mode 100644 index 055150a..0000000 --- a/spec/acceptance/nodesets/debian-8-x86_64-vagrant.yml +++ /dev/null @@ -1,8 +0,0 @@ -HOSTS: - debian-8-x64: - platform: debian-8-amd64 - hypervisor : vagrant - box : camptocamp/debian-8-amd64 -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-16.04-x86_64-docker.yml b/spec/acceptance/nodesets/debian-9-docker.yml similarity index 63% rename from spec/acceptance/nodesets/ubuntu-16.04-x86_64-docker.yml rename to spec/acceptance/nodesets/debian-9-docker.yml index 6cc3545..ec3678e 100644 --- a/spec/acceptance/nodesets/ubuntu-16.04-x86_64-docker.yml +++ b/spec/acceptance/nodesets/debian-9-docker.yml @@ -1,23 +1,21 @@ HOSTS: - ubuntu-1604-x64: - roles: - - agent - - default - platform: ubuntu-16.04-amd64 - image: ubuntu:16.04 + debian-9-docker: + platform: debian-9-amd64 hypervisor: docker - docker_cmd: ["/bin/systemd"] + image: debian:9 docker_preserve_image: true + docker_cmd: ["/bin/systemd"] docker_image_commands: - - apt-get install -y wget net-tools + - apt-get install -y wget net-tools python-pip python-dev - rm /lib/systemd/system/getty.target mount_folders: wget_cache: host_path: /tmp/wget_cache container_path: /var/cache/wget apt_cache: - host_path: /tmp/apt_cache/ubuntu-16.04-amd64 + host_path: /tmp/apt_cache/debian-9-amd64 container_path: /var/cache/apt CONFIG: + trace_limit: 200 type: foss log_level: debug diff --git a/spec/acceptance/nodesets/debian-9-vagrant.yml b/spec/acceptance/nodesets/debian-9-vagrant.yml new file mode 100644 index 0000000..1a076d1 --- /dev/null +++ b/spec/acceptance/nodesets/debian-9-vagrant.yml @@ -0,0 +1,16 @@ +HOSTS: + debian-9-vagrant: + platform: debian-9-amd64 + hypervisor : vagrant + box : bento/debian-9 + mount_folders: + wget_cache: + from: /tmp/vagrant-cache/wget + to: /var/cache/wget + yum_cache: + from: /tmp/vagrant-cache/yum/debian-9-vagrant + to: /var/cache/yum +CONFIG: + trace_limit: 200 + type: foss + log_level: debug diff --git a/spec/acceptance/nodesets/default.yml b/spec/acceptance/nodesets/default.yml index 453ce2a..f9f9289 100644 --- a/spec/acceptance/nodesets/default.yml +++ b/spec/acceptance/nodesets/default.yml @@ -1,19 +1,15 @@ HOSTS: - centos-6-x64: + default-centos-6-vagrant: platform: el-6-x86_64 - hypervisor : docker - image: centos:6 - docker_preserve_image: true - docker_image_commands: - - "sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf" - - 'yum install -y crontabs wget' + hypervisor: vagrant + box: bento/centos-6 mount_folders: wget_cache: - host_path: /tmp/wget_cache - container_path: /var/cache/wget + from: /tmp/vagrant-cache/wget + to: /var/cache/wget yum_cache: - host_path: /tmp/yum_cache/centos-6-x64 - container_path: /var/cache/yum + from: /tmp/vagrant-cache/yum/centos-6-vagrant + to: /var/cache/yum CONFIG: + trace_limit: 200 type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-12.04-x86_64-docker.yml b/spec/acceptance/nodesets/ubuntu-12.04-x86_64-docker.yml deleted file mode 100644 index aeddc9d..0000000 --- a/spec/acceptance/nodesets/ubuntu-12.04-x86_64-docker.yml +++ /dev/null @@ -1,19 +0,0 @@ -HOSTS: - ubuntu-1204-x64: - platform: ubuntu-12.04-amd64 - hypervisor : docker - image: ubuntu:12.04 - docker_preserve_image: true - docker_image_commands: - - 'apt-get update && apt-get install -y net-tools ca-certificates wget' - - 'locale-gen en_US.UTF-8' - mount_folders: - wget_cache: - host_path: /tmp/wget_cache - container_path: /var/cache/wget - apt_cache: - host_path: /tmp/apt_cache/ubuntu-12.04-amd64 - container_path: /var/cache/apt -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-12.04-x86_64-openstack.yml b/spec/acceptance/nodesets/ubuntu-12.04-x86_64-openstack.yml deleted file mode 100644 index 9db344e..0000000 --- a/spec/acceptance/nodesets/ubuntu-12.04-x86_64-openstack.yml +++ /dev/null @@ -1,11 +0,0 @@ -HOSTS: - ubuntu-1204-x64: - platform: ubuntu-12.04-amd64 - hypervisor : openstack - flavor: m1.small - image: ubuntu-1204-latest - user: ubuntu -CONFIG: - type: foss - log_level: debug - openstack_network: default diff --git a/spec/acceptance/nodesets/ubuntu-14.04-x86_64-openstack.yml b/spec/acceptance/nodesets/ubuntu-14.04-x86_64-openstack.yml deleted file mode 100644 index 28f8401..0000000 --- a/spec/acceptance/nodesets/ubuntu-14.04-x86_64-openstack.yml +++ /dev/null @@ -1,11 +0,0 @@ -HOSTS: - ubuntu-1404-x64: - platform: ubuntu-14.04-amd64 - hypervisor : openstack - flavor: m1.small - image: ubuntu-1404-latest - user: ubuntu -CONFIG: - type: foss - log_level: debug - openstack_network: default diff --git a/spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml b/spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml deleted file mode 100644 index 8584692..0000000 --- a/spec/acceptance/nodesets/ubuntu-14.04-x86_64-vagrant.yml +++ /dev/null @@ -1,8 +0,0 @@ -HOSTS: - ubuntu-1404-x64: - platform: ubuntu-14.04-amd64 - hypervisor : vagrant - box : puppetlabs/ubuntu-14.04-64-nocm -CONFIG: - type: foss - log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-14.04-x86_64-docker.yml b/spec/acceptance/nodesets/ubuntu-1404-docker.yml similarity index 55% rename from spec/acceptance/nodesets/ubuntu-14.04-x86_64-docker.yml rename to spec/acceptance/nodesets/ubuntu-1404-docker.yml index 8a0f274..e1a9397 100644 --- a/spec/acceptance/nodesets/ubuntu-14.04-x86_64-docker.yml +++ b/spec/acceptance/nodesets/ubuntu-1404-docker.yml @@ -1,21 +1,23 @@ HOSTS: - ubuntu-1404-x64: + ubuntu-1404-docker: platform: ubuntu-14.04-amd64 - hypervisor : docker + hypervisor: docker image: ubuntu:14.04 docker_preserve_image: true + docker_cmd: '["/sbin/init"]' docker_image_commands: - 'rm /usr/sbin/policy-rc.d' - 'rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl' - - 'apt-get update && apt-get install -y net-tools ca-certificates wget' + - 'apt-get install -y net-tools wget python-pip python-dev' - 'locale-gen en_US.UTF-8' mount_folders: wget_cache: - host_path: /tmp/wget_cache + host_path: /tmp/docker-cache/wget container_path: /var/cache/wget apt_cache: - host_path: /tmp/apt_cache/ubuntu-14.04-amd64 - container_path: /var/cache/apt + host_path: /tmp/docker-cache/apt/ubuntu-1404-docker + container_path: /var/cache/apt/archives CONFIG: + trace_limit: 200 type: foss log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-1404-vagrant.yml b/spec/acceptance/nodesets/ubuntu-1404-vagrant.yml new file mode 100644 index 0000000..ad71fde --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-1404-vagrant.yml @@ -0,0 +1,16 @@ +HOSTS: + ubuntu-1404-vagrant: + platform: ubuntu-14.04-amd64 + hypervisor: vagrant + box: bento/ubuntu-14.04 + mount_folders: + wget_cache: + from: /tmp/vagrant-cache/wget + to: /var/cache/wget + apt_cache: + from: /tmp/vagrant-cache/apt/ubuntu-1404-vagrant + to: /var/cache/apt/archives +CONFIG: + trace_limit: 200 + type: foss + log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-1604-docker.yml b/spec/acceptance/nodesets/ubuntu-1604-docker.yml new file mode 100644 index 0000000..c855cd3 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-1604-docker.yml @@ -0,0 +1,22 @@ +HOSTS: + ubuntu-1604-docker: + platform: ubuntu-16.04-amd64 + hypervisor: docker + image: ubuntu:16.04 + docker_preserve_image: true + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'apt-get install -y net-tools wget locales python-pip python-dev' + - 'locale-gen en_US.UTF-8' + mount_folders: + wget_cache: + host_path: /tmp/docker-cache/wget + container_path: /var/cache/wget + apt_cache: + host_path: /tmp/docker-cache/apt/ubuntu-1604-docker + container_path: /var/cache/apt/archives +CONFIG: + trace_limit: 200 + puppeter_answers: system + type: foss + log_level: debug diff --git a/spec/acceptance/nodesets/ubuntu-1604-vagrant.yml b/spec/acceptance/nodesets/ubuntu-1604-vagrant.yml new file mode 100644 index 0000000..a2070c7 --- /dev/null +++ b/spec/acceptance/nodesets/ubuntu-1604-vagrant.yml @@ -0,0 +1,17 @@ +HOSTS: + ubuntu-1604-vagrant: + platform: ubuntu-16.04-amd64 + hypervisor: vagrant + box: bento/ubuntu-16.04 + mount_folders: + wget_cache: + from: /tmp/vagrant-cache/wget + to: /var/cache/wget + apt_cache: + from: /tmp/vagrant-cache/apt/ubuntu-1604-vagrant + to: /var/cache/apt/archives +CONFIG: + trace_limit: 200 + puppeter_answers: system + type: foss + log_level: debug diff --git a/spec/acceptance/resourceadapter_spec.rb b/spec/acceptance/resourceadapter_spec.rb index 027d426..3c8440a 100644 --- a/spec/acceptance/resourceadapter_spec.rb +++ b/spec/acceptance/resourceadapter_spec.rb @@ -1,19 +1,21 @@ require 'spec_helper_acceptance' -describe 'resourceadapter smoke test', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - let(:baseserver) { Testing::Acceptance::SmokeTestReader.smoke_pp :init } - let(:pp) { Testing::Acceptance::SmokeTestReader.smoke_pp :resourceadapter } +describe 'resourceadapter smoke test' do + let(:baseserver) { example 'jboss' } + let(:pp) { example 'jboss::resourceadapter' } it 'should install base server with no errors' do - apply_manifest(baseserver, :catch_failures => true) + result = apply_manifest(baseserver, :catch_failures => true) + expect(result.exit_code).to be(2) end it 'should add resource adapter with no errors' do - apply_manifest(pp, :catch_failures => true) + result = apply_manifest(pp, :catch_failures => true) + expect(result.exit_code).to be(2) end - context 'verifing idempotency' do + describe 'verifing idempotency' do before(:each) { skip('This not work, GH issue: coi-gov-pl/puppet-jboss#70') } it 'should work idempotently' do - apply_manifest(pp, :catch_changes => true) + apply_manifest(pp, :catch_changes => true) end end describe service('wildfly') do diff --git a/spec/acceptance/securitydomain_spec.rb b/spec/acceptance/securitydomain_spec.rb index 3e09e6a..a9b1455 100644 --- a/spec/acceptance/securitydomain_spec.rb +++ b/spec/acceptance/securitydomain_spec.rb @@ -1,17 +1,19 @@ require 'spec_helper_acceptance' -describe 'securitydomain smoke test', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - let(:baseserver) { Testing::Acceptance::SmokeTestReader.smoke_pp :init } - let(:pp) { Testing::Acceptance::SmokeTestReader.smoke_pp :securitydomain } +describe 'securitydomain smoke test' do + let(:baseserver) { example 'jboss' } + let(:pp) { example 'jboss::securitydomain' } it 'should install base server with no errors' do - apply_manifest(baseserver, :catch_failures => true, :trace => true) + result = apply_manifest(baseserver, :catch_failures => true) + expect(result.exit_code).to be(2) end it 'should add securitydomain with no errors' do - apply_manifest(pp, :catch_failures => true, :trace => true) + result = apply_manifest(pp, :catch_failures => true) + expect(result.exit_code).to be(2) end it 'should work idempotently' do - apply_manifest(pp, :catch_changes => true, :trace => true) + apply_manifest(pp, :catch_changes => true) end describe service('wildfly') do it { is_expected.to be_running } diff --git a/spec/acceptance/user_spec.rb b/spec/acceptance/user_spec.rb index 05f1332..20901cb 100644 --- a/spec/acceptance/user_spec.rb +++ b/spec/acceptance/user_spec.rb @@ -1,17 +1,19 @@ require 'spec_helper_acceptance' -describe 'user smoke test', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - let(:baseserver) { Testing::Acceptance::SmokeTestReader.smoke_pp :init } - let(:pp) { Testing::Acceptance::SmokeTestReader.smoke_pp :user } +describe 'user smoke test' do + let(:baseserver) { example 'jboss' } + let(:pp) { example 'jboss::user' } it 'should install base server with no errors' do - apply_manifest(baseserver, :catch_failures => true) + result = apply_manifest(baseserver, :catch_failures => true) + expect(result.exit_code).to be(2) end it 'should add user with no errors' do - apply_manifest(pp, :catch_failures => true) + result = apply_manifest(pp, :catch_failures => true) + expect(result.exit_code).to be(2) end it 'should work idempotently' do - apply_manifest(pp, :catch_changes => true) + apply_manifest(pp, :catch_changes => true) end describe service('wildfly') do it { is_expected.to be_running } diff --git a/spec/acceptance/version/as7_spec.rb b/spec/acceptance/version/as7_spec.rb new file mode 100644 index 0000000..c99feb3 --- /dev/null +++ b/spec/acceptance/version/as7_spec.rb @@ -0,0 +1,28 @@ +require 'spec_helper_acceptance' + +describe 'jboss::version::as7 smoke test', :if => Testing::Acceptance::JavaPlatform.java6compatibile? do + let(:pp) { example 'jboss::version::as7' } + + before(:all) do + cleanup_pp = example 'jboss::version::as7::rmjava_default' + apply_manifest(cleanup_pp, :catch_failures => true) + end + + it 'should add install JBoss AS 7 with no errors' do + result = apply_manifest(pp, :catch_failures => true) + expect(result.exit_code).to be(2) + end + it 'should work idempotently' do + apply_manifest(pp, :catch_changes => true) + end + describe service('jboss-as') do + it { is_expected.to be_running } + end + + after(:all) do + extend Testing::Acceptance::Cleaner + remove_jboss_installation('jboss-as') + cleanup_pp = example 'jboss::version::as7::rmjava_as7' + apply_manifest(cleanup_pp, :catch_failures => true) + end +end diff --git a/spec/acceptance/jboss/wildfly10_spec.rb b/spec/acceptance/version/wildfly10_spec.rb similarity index 57% rename from spec/acceptance/jboss/wildfly10_spec.rb rename to spec/acceptance/version/wildfly10_spec.rb index 6c7f6c9..32dd31a 100644 --- a/spec/acceptance/jboss/wildfly10_spec.rb +++ b/spec/acceptance/version/wildfly10_spec.rb @@ -1,31 +1,30 @@ require 'spec_helper_acceptance' -describe 'jboss::wildfly10 smoke test', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - let(:pp) { Testing::Acceptance::SmokeTestReader.smoke_pp :'jboss::wildfly10' } +describe 'jboss::version::wildfly10 smoke test' do + let(:pp) { example 'jboss::version::wildfly10' } shared_examples 'a properly working class on a platform with supported Java version' do - it 'should install WildFly 10 with no errors' do - apply_manifest(pp, :expect_changes => true, :trace => true) + result = apply_manifest(pp, :catch_failures => true) + expect(result.exit_code).to be(2) end it 'should work idempotently' do - apply_manifest(pp, :catch_changes => true, :trace => true) + apply_manifest(pp, :catch_changes => true) end describe service('wildfly') do it { is_expected.to be_running } end - end - if (fact('osfamily') == 'RedHat' && fact('operatingsystemmajrelease') >= '7') + if fact('osfamily') == 'RedHat' && fact('operatingsystemmajrelease') >= '7' it_behaves_like 'a properly working class on a platform with supported Java version' - elsif (fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') >= '8' ) + elsif fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') >= '9' it_behaves_like 'a properly working class on a platform with supported Java version' - elsif (fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') >= '15.10' ) + elsif fact('operatingsystem') == 'Ubuntu' && fact('operatingsystemmajrelease') >= '15.10' it_behaves_like 'a properly working class on a platform with supported Java version' else it 'should install WildFly, but it should not start due to lack of Java 8' do - apply_manifest(pp, :expect_changes => true, :trace => true) + apply_manifest(pp, :acceptable_exit_codes => [2, 4]) end describe service('wildfly') do it { is_expected.not_to be_running } diff --git a/spec/acceptance/jboss/wildfly8_spec.rb b/spec/acceptance/version/wildfly8_spec.rb similarity index 50% rename from spec/acceptance/jboss/wildfly8_spec.rb rename to spec/acceptance/version/wildfly8_spec.rb index a22c834..643ebcf 100644 --- a/spec/acceptance/jboss/wildfly8_spec.rb +++ b/spec/acceptance/version/wildfly8_spec.rb @@ -1,13 +1,14 @@ require 'spec_helper_acceptance' -describe 'jboss::wildfly8 smoke test', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - let(:pp) { Testing::Acceptance::SmokeTestReader.smoke_pp :'jboss::wildfly8' } +describe 'jboss::version::wildfly8 smoke test' do + let(:pp) { example 'jboss::version::wildfly8' } it 'should add install WildFly 8 with no errors' do - apply_manifest(pp, :expect_changes => true, :trace => true) + result = apply_manifest(pp, :catch_failures => true) + expect(result.exit_code).to be(2) end it 'should work idempotently' do - apply_manifest(pp, :catch_changes => true, :trace => true) + apply_manifest(pp, :catch_changes => true) end describe service('wildfly') do it { is_expected.to be_running } diff --git a/spec/acceptance/jboss/wildfly9_spec.rb b/spec/acceptance/version/wildfly9_spec.rb similarity index 50% rename from spec/acceptance/jboss/wildfly9_spec.rb rename to spec/acceptance/version/wildfly9_spec.rb index c64899d..0290c94 100644 --- a/spec/acceptance/jboss/wildfly9_spec.rb +++ b/spec/acceptance/version/wildfly9_spec.rb @@ -1,13 +1,14 @@ require 'spec_helper_acceptance' -describe 'jboss::wildfly9 smoke test', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do - let(:pp) { Testing::Acceptance::SmokeTestReader.smoke_pp :'jboss::wildfly9' } +describe 'jboss::version::wildfly9 smoke test' do + let(:pp) { example 'jboss::version::wildfly9' } it 'should add install WildFly 9 with no errors' do - apply_manifest(pp, :expect_changes => true, :trace => true) + result = apply_manifest(pp, :catch_failures => true) + expect(result.exit_code).to be(2) end it 'should work idempotently' do - apply_manifest(pp, :catch_changes => true, :trace => true) + apply_manifest(pp, :catch_changes => true) end describe service('wildfly') do it { is_expected.to be_running } diff --git a/spec/classes/init_spec.rb b/spec/classes/init_spec.rb index 171ec93..aa9adac 100644 --- a/spec/classes/init_spec.rb +++ b/spec/classes/init_spec.rb @@ -1,16 +1,15 @@ require 'spec_helper_puppet' describe 'jboss', :type => :class do - let(:facts) { Testing::RspecPuppet::SharedFacts.oraclelinux_facts } extend Testing::RspecPuppet::SharedExamples - context 'with defaults for all parameters' do + describe 'with defaults for all parameters' do it { is_expected.to compile } it do - is_expected.to contain_class('jboss').with({ - :product => 'wildfly', - :version => '9.0.2.Final', - }) + is_expected.to contain_class('jboss').with( + :product => 'wildfly', + :version => '9.0.2.Final' + ) end it { is_expected.to contain_anchor 'jboss::begin' } it { is_expected.to contain_anchor 'jboss::end' } @@ -24,15 +23,17 @@ it { is_expected.to contain_anchor 'jboss::service::started' } it { is_expected.to contain_user 'jboss' } it { is_expected.to contain_group 'jboss' } - it { is_expected.to contain_class('jboss::internal::package').with({ - :version => '9.0.2.Final', - :product => 'wildfly', - :jboss_user => 'jboss', - :jboss_group => 'jboss', - :java_version => 'latest' - })} + it do + is_expected.to contain_class('jboss::internal::package').with( + :version => '9.0.2.Final', + :product => 'wildfly', + :jboss_user => 'jboss', + :jboss_group => 'jboss', + :java_version => 'latest' + ) + end end - context 'with product => jboss-eap and version => 6.4.0.GA parameters set' do + describe 'with product => jboss-eap and version => 6.4.0.GA parameters set' do let(:params) do { :product => 'jboss-eap', :version => '6.4.0.GA' } end @@ -42,7 +43,7 @@ it { is_expected.to contain_user 'jboss' } it { is_expected.to contain_group 'jboss' } end - context 'with jboss_user => appserver parameter set' do + describe 'with jboss_user => appserver parameter set' do let(:params) do { :jboss_user => 'appserver' } end @@ -52,15 +53,15 @@ it { is_expected.to contain_user 'appserver' } it { is_expected.to contain_group 'jboss' } end - context 'with download_url => file:///tmp/wildfly-8.2.0.Final.zip set' do + describe 'with download_url => file:///tmp/wildfly-8.2.0.Final.zip set' do let(:params) do { :download_url => 'file:///tmp/wildfly-8.2.0.Final.zip' } end it do - is_expected.to contain_class('jboss').with({ + is_expected.to contain_class('jboss').with( :download_url => 'file:///tmp/wildfly-8.2.0.Final.zip' - }) + ) end it { is_expected.to contain_class 'jboss::params' } it { is_expected.to contain_class 'jboss::internal::compatibility' } @@ -69,6 +70,5 @@ it_behaves_like common_interfaces it_behaves_like common_anchors - end end diff --git a/spec/classes/internal/augeas_spec.rb b/spec/classes/internal/augeas_spec.rb index 4323f83..c65d807 100644 --- a/spec/classes/internal/augeas_spec.rb +++ b/spec/classes/internal/augeas_spec.rb @@ -1,17 +1,19 @@ require 'spec_helper_puppet' describe 'jboss::internal::augeas', :type => :class do - DEFAULT_VERSION = '9.0.2.Final' - DEFAULT_PRODUCT = 'wildfly' + defs = { + :version => '9.0.2.Final', + :product => 'wildfly' + } shared_examples 'contains self' do it { is_expected.to contain_class('jboss') } it { is_expected.to contain_class 'jboss::internal::lenses' } it { is_expected.to contain_class 'jboss::internal::augeas' } - it { is_expected.to contain_file("/usr/lib/#{DEFAULT_PRODUCT}-#{DEFAULT_VERSION}/lenses/jbxml.aug") } + it { is_expected.to contain_file("/usr/lib/#{defs[:product]}-#{defs[:version]}/lenses/jbxml.aug") } end - context 'On RedHat os family' do + describe 'On RedHat os family' do extend Testing::RspecPuppet::SharedExamples let(:title) { 'test-augeas' } let(:facts) { Testing::RspecPuppet::SharedFacts.oraclelinux_facts } @@ -19,7 +21,7 @@ it_behaves_like 'contains self' end - context 'On Debian os family' do + describe 'On Debian os family' do extend Testing::RspecPuppet::SharedExamples let(:title) { 'test-augeas' } let(:facts) { Testing::RspecPuppet::SharedFacts.ubuntu_facts } diff --git a/spec/classes/internal/configuration_spec.rb b/spec/classes/internal/configuration_spec.rb index f623eb1..2cb13ae 100644 --- a/spec/classes/internal/configuration_spec.rb +++ b/spec/classes/internal/configuration_spec.rb @@ -1,7 +1,6 @@ require 'spec_helper_puppet' describe 'jboss::internal::configuration', :type => :class do - shared_examples 'contains basic class structure' do it { is_expected.to contain_class('jboss') } it { is_expected.to contain_class('jboss::params') } @@ -19,48 +18,62 @@ end shared_examples 'contains file structure' do - it { is_expected.to contain_file('/etc/profile.d/jboss.sh').with({ - :ensure => 'file', - :mode => '0644' - }) } - - it { is_expected.to contain_file('/var/log/wildfly/console.log').with({ - :ensure => 'file', - :alias => 'jboss::logfile', - :owner => 'root', - :group => 'jboss', - :mode => '0660' - }) } - - it { is_expected.to contain_file('/etc/jboss-as').with({ - :ensure => 'directory', - :mode => '2770', - :owner => 'jboss', - :group => 'jboss' - }) } - - it { is_expected.to contain_file('/etc/jboss-as/jboss-as.conf'). - with_ensure('link'). - that_comes_before('Anchor[jboss::configuration::end]') } + it do + is_expected.to contain_file('/etc/profile.d/jboss.sh').with( + :ensure => 'file', + :mode => '0644' + ) + end + + it do + is_expected.to contain_file('/var/log/wildfly/console.log').with( + :ensure => 'file', + :alias => 'jboss::logfile', + :owner => 'root', + :group => 'jboss', + :mode => '0660' + ) + end + + it do + is_expected.to contain_file('/etc/jboss-as').with( + :ensure => 'directory', + :mode => '2770', + :owner => 'jboss', + :group => 'jboss' + ) + end + + it { + is_expected.to contain_file('/etc/jboss-as/jboss-as.conf'). + with_ensure('link'). + that_comes_before('Anchor[jboss::configuration::end]') + } it { is_expected.to contain_file('/etc/default').with_ensure('directory') } - it { is_expected.to contain_file('/etc/default/wildfly.conf'). - with_ensure('link'). - that_comes_before('Anchor[jboss::configuration::end]') } + it { + is_expected.to contain_file('/etc/default/wildfly.conf'). + with_ensure('link'). + that_comes_before('Anchor[jboss::configuration::end]') + } end shared_examples 'contains self' do - it { is_expected.to contain_concat('/etc/wildfly/wildfly.conf').with({ - :alias => 'jboss::jboss-as.conf', - :mode => '0644' - }) } - it { is_expected.to contain_concat__fragment('jboss::jboss-as.conf::defaults').with({ - :order => '000' - }) } + it { + is_expected.to contain_concat('/etc/wildfly/wildfly.conf').with( + :alias => 'jboss::jboss-as.conf', + :mode => '0644' + ) + } + it { + is_expected.to contain_concat__fragment('jboss::jboss-as.conf::defaults').with( + :order => '000' + ) + } end - context 'On RedHat os family' do + describe 'On RedHat os family' do extend Testing::RspecPuppet::SharedExamples let(:title) { 'test-configuration' } let(:facts) { Testing::RspecPuppet::SharedFacts.oraclelinux_facts } @@ -73,7 +86,7 @@ it { is_expected.to contain_file('/etc/sysconfig/wildfly.conf') } end - context 'On Debian os family' do + describe 'On Debian os family' do extend Testing::RspecPuppet::SharedExamples let(:title) { 'test-configuration' } let(:facts) { Testing::RspecPuppet::SharedFacts.ubuntu_facts } diff --git a/spec/classes/internal/configure/interfaces_spec.rb b/spec/classes/internal/configure/interfaces_spec.rb index f05de7b..9277115 100644 --- a/spec/classes/internal/configure/interfaces_spec.rb +++ b/spec/classes/internal/configure/interfaces_spec.rb @@ -1,26 +1,26 @@ require 'spec_helper_puppet' -describe 'jboss::internal::configure::interfaces', :type => :define do - shared_examples 'contains self' do +describe 'jboss::internal::configure::interfaces', :type => :class do + shared_examples 'contains jboss::internal::configure::interfaces classes' do it { is_expected.to contain_class 'jboss::internal::configure::interfaces' } it { is_expected.to contain_class('jboss') } it { is_expected.to contain_class('jboss::params') } it { is_expected.to contain_class('jboss::internal::runtime::dc') } end - context 'On RedHat os family' do + describe 'On RedHat os family' do extend Testing::RspecPuppet::SharedExamples let(:title) { 'test-conf-interfaces' } let(:facts) { Testing::RspecPuppet::SharedFacts.oraclelinux_facts } - it_behaves_like 'contains self' + it_behaves_like 'contains jboss::internal::configure::interfaces classes' end - context 'On Debian os family' do + describe 'On Debian os family' do extend Testing::RspecPuppet::SharedExamples let(:title) { 'test-conf-interfaces' } let(:facts) { Testing::RspecPuppet::SharedFacts.ubuntu_facts } - it_behaves_like 'contains self' + it_behaves_like 'contains jboss::internal::configure::interfaces classes' end end diff --git a/spec/classes/internal/lenses_spec.rb b/spec/classes/internal/lenses_spec.rb index e7b495a..026290a 100644 --- a/spec/classes/internal/lenses_spec.rb +++ b/spec/classes/internal/lenses_spec.rb @@ -1,37 +1,51 @@ require 'spec_helper_puppet' describe 'jboss::internal::lenses', :type => :class do - DEFAULT_VERSION = '9.0.2.Final' - DEFAULT_PRODUCT = 'wildfly' + defaults = { + :version => '9.0.2.Final', + :product => 'wildfly' + } - shared_examples 'completly working define' do + shared_examples 'completly working define jboss::internal::lenses' do it { is_expected.to contain_class 'jboss::internal::lenses' } it { is_expected.to contain_class 'jboss' } - it { is_expected.to contain_file("/usr/lib/#{DEFAULT_PRODUCT}-#{DEFAULT_VERSION}/lenses/jbxml.aug").with({ - :ensure => 'file', - :source => 'puppet:///modules/jboss/jbxml.aug', - })} - it { is_expected.to contain_file("/usr/lib/#{DEFAULT_PRODUCT}-#{DEFAULT_VERSION}/lenses/jbxml.aug").that_requires( - "File[/usr/lib/#{DEFAULT_PRODUCT}-#{DEFAULT_VERSION}/lenses/]" - )} - it { is_expected.to contain_file("/usr/lib/#{DEFAULT_PRODUCT}-#{DEFAULT_VERSION}/lenses").with({ - :ensure => 'directory', - :owner => 'jboss', - }) } - it { is_expected.to contain_file("/usr/lib/#{DEFAULT_PRODUCT}-#{DEFAULT_VERSION}/lenses").that_requires( - 'Anchor[jboss::configuration::begin]' - )} + it do + is_expected.to contain_file( + "/usr/lib/#{defaults[:product]}-#{defaults[:version]}/lenses/jbxml.aug" + ).with( + :ensure => 'file', + :source => 'puppet:///modules/jboss/jbxml.aug' + ) + end + it do + is_expected.to contain_file( + "/usr/lib/#{defaults[:product]}-#{defaults[:version]}/lenses/jbxml.aug" + ).that_requires( + "File[/usr/lib/#{defaults[:product]}-#{defaults[:version]}/lenses/]" + ) + end + it do + is_expected.to contain_file( + "/usr/lib/#{defaults[:product]}-#{defaults[:version]}/lenses" + ).with( + :ensure => 'directory', + :owner => 'jboss' + ) + end + it do + is_expected.to contain_file( + "/usr/lib/#{defaults[:product]}-#{defaults[:version]}/lenses" + ).that_requires( + 'Anchor[jboss::configuration::begin]' + ) + end end - context 'On RedHat os family' do - let(:title) { 'test-lenses' } - let(:facts) { Testing::RspecPuppet::SharedFacts.oraclelinux_facts } - it_behaves_like 'completly working define' - end - - context 'On Debian os family' do - let(:title) { 'test-lenses' } - let(:facts) { Testing::RspecPuppet::SharedFacts.ubuntu_facts } - it_behaves_like 'completly working define' + on_supported_os.each do |os, facts| + describe "On #{os}" do + let(:title) { 'test-lenses' } + let(:facts) { facts.merge(:concat_basedir => '/root') } + it_behaves_like 'completly working define jboss::internal::lenses' + end end end diff --git a/spec/classes/internal/prerequisites_spec.rb b/spec/classes/internal/prerequisites_spec.rb index c4e432c..003edfe 100644 --- a/spec/classes/internal/prerequisites_spec.rb +++ b/spec/classes/internal/prerequisites_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper_puppet' -describe 'jboss::internal::prerequisites', :type => :define do +describe 'jboss::internal::prerequisites', :type => :class do shared_examples 'completly working define' do it { is_expected.to compile } it { is_expected.to contain_class 'jboss::internal::prerequisites' } @@ -9,12 +9,12 @@ it { is_expected.to contain_package('coreutils') } end - context 'On RedHat os family' do + describe 'On RedHat os family' do let(:title) { 'test-prerequisites' } let(:facts) { Testing::RspecPuppet::SharedFacts.oraclelinux_facts } it_behaves_like 'completly working define' end - context 'On Debian os family' do + describe 'On Debian os family' do let(:title) { 'test-module' } let(:facts) { Testing::RspecPuppet::SharedFacts.ubuntu_facts } it_behaves_like 'completly working define' diff --git a/spec/classes/internal/quirks/etc_initd_functions_spec.rb b/spec/classes/internal/quirks/etc_initd_functions_spec.rb index 3fdebcc..ec76473 100644 --- a/spec/classes/internal/quirks/etc_initd_functions_spec.rb +++ b/spec/classes/internal/quirks/etc_initd_functions_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper_puppet' -describe 'jboss::internal::quirks::etc_initd_functions', :type => :define do +describe 'jboss::internal::quirks::etc_initd_functions', :type => :class do shared_examples 'contains class structure' do it { is_expected.to contain_class 'jboss::internal::quirks::etc_initd_functions' } it { is_expected.to contain_class('jboss') } @@ -8,21 +8,19 @@ it { is_expected.to contain_class('jboss::internal::compatibility') } end - context 'On RedHat os family' do + describe 'On RedHat os family' do extend Testing::RspecPuppet::SharedExamples let(:title) { 'test-etc_initd_functions' } let(:facts) { Testing::RspecPuppet::SharedFacts.oraclelinux_facts } it_behaves_like 'contains class structure' - end - context 'On Debian os family' do + describe 'On Debian os family' do extend Testing::RspecPuppet::SharedExamples let(:title) { 'test-etc_initd_functions' } let(:facts) { Testing::RspecPuppet::SharedFacts.ubuntu_facts } it_behaves_like 'contains class structure' - end end diff --git a/spec/classes/internal/service_spec.rb b/spec/classes/internal/service_spec.rb index cdb24cd..0d5792a 100644 --- a/spec/classes/internal/service_spec.rb +++ b/spec/classes/internal/service_spec.rb @@ -15,41 +15,41 @@ shared_examples 'containg service restart exec' do it do is_expected.to contain_exec('jboss::service::restart'). - with( - :command => "service wildfly stop ; sleep 5 ; pkill -9 -f '^java.*wildfly' ; service wildfly start", - :refreshonly => true - ) + with( + :command => "service wildfly stop ; sleep 5 ; pkill -9 -f '^java.*wildfly' ; service wildfly start", + :refreshonly => true + ) end end shared_examples 'containg SystemD execs' do it do is_expected.to contain_exec('jboss::service::test-running'). - with( - :loglevel => 'emerg', - :command => 'tail -n 80 /var/log/wildfly/console.log && exit 1', - :unless => "pgrep -f '^java.*wildfly' > /dev/null", - :logoutput => true - ) + with( + :loglevel => 'emerg', + :command => 'tail -n 80 /var/log/wildfly/console.log && exit 1', + :unless => "pgrep -f '^java.*wildfly' > /dev/null", + :logoutput => true + ) end it do is_expected.to contain_exec('systemctl-daemon-reload-for-wildfly'). - with_command("/bin/systemctl daemon-reload") + with_command('/bin/systemctl daemon-reload') end end shared_examples 'containg SystemV execs' do it do is_expected.to contain_exec('jboss::service::test-running'). - with( - :loglevel => 'warning', - :command => 'tail -n 80 /var/log/wildfly/console.log && exit 0', - :unless => "pgrep -f '^java.*wildfly' > /dev/null", - :logoutput => true - ) + with( + :loglevel => 'warning', + :command => 'tail -n 80 /var/log/wildfly/console.log && exit 0', + :unless => "pgrep -f '^java.*wildfly' > /dev/null", + :logoutput => true + ) end end - context 'on RedHat os family' do - context 'on Docker container' do + describe 'on RedHat os family' do + describe 'on Docker container' do let(:facts) do Testing::RspecPuppet::SharedFacts.oraclelinux_facts( :jboss_virtual => 'docker' @@ -61,14 +61,14 @@ it_behaves_like 'containg class structure' it do is_expected.to contain_service('wildfly'). - with( - :ensure => 'running', - :enable => nil, - :hasstatus => true, - :hasrestart => true - ) + with( + :ensure => 'running', + :enable => nil, + :hasstatus => true, + :hasrestart => true + ) end - context 'on SystemD system' do + describe 'on SystemD system' do let(:facts) do Testing::RspecPuppet::SharedFacts.oraclelinux_facts( :jboss_virtual => 'docker', @@ -78,7 +78,7 @@ it_behaves_like 'containg SystemD execs' end end - context 'on non-Docker machine' do + describe 'on non-Docker machine' do let(:facts) do Testing::RspecPuppet::SharedFacts.oraclelinux_facts( :jboss_virtual => 'phisycal' @@ -90,14 +90,14 @@ it_behaves_like 'containg class structure' it do is_expected.to contain_service('wildfly'). - with( - :ensure => 'running', - :enable => true, - :hasstatus => true, - :hasrestart => true - ) + with( + :ensure => 'running', + :enable => true, + :hasstatus => true, + :hasrestart => true + ) end - context 'on SystemD system' do + describe 'on SystemD system' do let(:facts) do Testing::RspecPuppet::SharedFacts.oraclelinux_facts( :jboss_virtual => 'phisycal', @@ -109,8 +109,8 @@ end end - context 'on Debian os family' do - context 'on Docker container' do + describe 'on Debian os family' do + describe 'on Docker container' do let(:facts) do Testing::RspecPuppet::SharedFacts.ubuntu_facts( :jboss_virtual => 'docker' @@ -122,14 +122,14 @@ it_behaves_like 'containg class structure' it do is_expected.to contain_service('wildfly'). - with( - :ensure => 'running', - :enable => nil, - :hasstatus => true, - :hasrestart => true - ) + with( + :ensure => 'running', + :enable => nil, + :hasstatus => true, + :hasrestart => true + ) end - context 'on SystemD system' do + describe 'on SystemD system' do let(:facts) do Testing::RspecPuppet::SharedFacts.ubuntu_facts( :jboss_virtual => 'docker', @@ -140,7 +140,7 @@ it_behaves_like 'containg SystemD execs' end end - context 'on non-Docker machine' do + describe 'on non-Docker machine' do let(:facts) do Testing::RspecPuppet::SharedFacts.ubuntu_facts( :jboss_virtual => 'vmware' @@ -152,14 +152,14 @@ it_behaves_like 'containg class structure' it do is_expected.to contain_service('wildfly'). - with( - :ensure => 'running', - :enable => true, - :hasstatus => true, - :hasrestart => true - ) + with( + :ensure => 'running', + :enable => true, + :hasstatus => true, + :hasrestart => true + ) end - context 'on SystemD system' do + describe 'on SystemD system' do let(:facts) do Testing::RspecPuppet::SharedFacts.ubuntu_facts( :jboss_virtual => 'vmware', diff --git a/spec/classes/params_spec.rb b/spec/classes/params_spec.rb index edd93dd..ad2a59f 100644 --- a/spec/classes/params_spec.rb +++ b/spec/classes/params_spec.rb @@ -1,12 +1,10 @@ require 'spec_helper_puppet' describe 'jboss::params', :type => :class do - it { is_expected.to compile } it { is_expected.to contain_class 'jboss::params' } it { is_expected.to contain_class 'jboss::internal::params' } it { is_expected.to contain_class 'jboss::internal::quirks::autoinstall' } it { is_expected.to contain_class 'jboss::internal::params::socketbinding' } it { is_expected.to contain_class 'jboss::internal::params::memorydefaults' } - end diff --git a/spec/defines/clientry_spec.rb b/spec/defines/clientry_spec.rb index 3de6d24..5e06ac3 100644 --- a/spec/defines/clientry_spec.rb +++ b/spec/defines/clientry_spec.rb @@ -1,28 +1,27 @@ require 'spec_helper_puppet' describe 'jboss::clientry', :type => :define do - shared_examples 'contain self' do it do - is_expected.to contain_jboss_confignode(title).with({ + is_expected.to contain_jboss_confignode(title).with( :ensure => 'present', :path => 'profile/test' - }) + ) end it { is_expected.to contain_jboss_confignode(title).that_requires('Anchor[jboss::package::end]') } it do - is_expected.to contain_jboss__clientry(title).with({ + is_expected.to contain_jboss__clientry(title).with( :ensure => 'present', - :path => 'profile/test', - }) + :path => 'profile/test' + ) end end - context 'on RedHat os family' do + describe 'on RedHat os family' do extend Testing::RspecPuppet::SharedExamples let(:title) { 'test-clientry' } - let(:params) { { :path => 'profile/test', } } + let(:params) { { :path => 'profile/test' } } let(:facts) { Testing::RspecPuppet::SharedFacts.oraclelinux_facts } it_behaves_like containing_basic_class_structure @@ -30,11 +29,11 @@ it_behaves_like 'contain self' end - context 'on Debian os family' do + describe 'on Debian os family' do extend Testing::RspecPuppet::SharedExamples let(:title) { 'test-clientry' } - let(:params) { { :path => 'profile/test', } } + let(:params) { { :path => 'profile/test' } } let(:facts) { Testing::RspecPuppet::SharedFacts.ubuntu_facts } it_behaves_like containing_basic_class_structure diff --git a/spec/defines/datasource_spec.rb b/spec/defines/datasource_spec.rb index 50340a0..3941921 100644 --- a/spec/defines/datasource_spec.rb +++ b/spec/defines/datasource_spec.rb @@ -1,23 +1,31 @@ require 'spec_helper_puppet' describe 'jboss::datasource', :type => :define do + def default_driver_params + { + 'name' => 'test-driver', + 'classname' => 'com.example.TestDriver', + 'modulename' => 'test-driver' + } + end + + def default_params + { + :username => 'test-username', + :password => 'test-password', + :jdbcscheme => 'test-scheme', + :host => 'example.com', + :port => '1234', + :driver => default_driver_params + } + end - context 'on RedHat os family' do + def merge_params(hash = {}) + hash.merge(default_params) + end + + describe 'on RedHat os family' do extend Testing::RspecPuppet::SharedExamples - def merge_params(hash = {}) - hash.merge({ - :username => 'test-username', - :password => 'test-password', - :jdbcscheme => 'test-scheme', - :host => 'example.com', - :port => '1234', - :driver => { - 'name' => 'test-driver', - 'classname' => 'com.example.TestDriver', - 'modulename' => 'test-driver', - }, - }) - end let(:title) { 'test-datasource' } let(:params) { merge_params } @@ -43,60 +51,49 @@ def merge_params(hash = {}) with_xa(false) end - context 'with option prepared-statements-cache-size set to 46' do - let(:options) do { + describe 'with option prepared-statements-cache-size set to 46' do + let(:options) do + { 'prepared-statements-cache-size' => 46 } end - context 'in XA mode' do + describe 'in XA mode' do let(:params) do - merge_params({ :options => options, :xa => true }) + merge_params(:options => options, :xa => true) end it { is_expected.to contain_jboss_datasource('test-datasource').with_xa(true) } - it do is_expected.to contain_jboss_datasource('test-datasource').with_options({ - "validate-on-match"=>false, - "background-validation"=>false, - "share-prepared-statements"=>false, - "prepared-statements-cache-size"=>46, - "same-rm-override"=>true, - "wrap-xa-resource"=>true - }) + it do + is_expected.to contain_jboss_datasource('test-datasource').with_options( + 'validate-on-match' => false, + 'background-validation' => false, + 'share-prepared-statements' => false, + 'prepared-statements-cache-size' => 46, + 'same-rm-override' => true, + 'wrap-xa-resource' => true + ) end end - context 'in non-XA mode' do + describe 'in non-XA mode' do let(:params) do - merge_params({ :options => options, :xa => false }) + merge_params(:options => options, :xa => false) end it { is_expected.to contain_jboss_datasource('test-datasource').with_xa(false) } - it do is_expected.to contain_jboss_datasource('test-datasource').with_options({ - "validate-on-match"=>false, - "background-validation"=>false, - "share-prepared-statements"=>false, - "prepared-statements-cache-size"=>46 - }) + it do + is_expected.to contain_jboss_datasource('test-datasource').with_options( + 'validate-on-match' => false, + 'background-validation' => false, + 'share-prepared-statements' => false, + 'prepared-statements-cache-size' => 46 + ) end end end end - context 'on Ubuntu os family' do + describe 'on Ubuntu os family' do extend Testing::RspecPuppet::SharedExamples - def merge_params(hash = {}) - hash.merge({ - :username => 'test-username', - :password => 'test-password', - :jdbcscheme => 'test-scheme', - :host => 'example.com', - :port => '1234', - :driver => { - 'name' => 'test-driver', - 'classname' => 'com.example.TestDriver', - 'modulename' => 'test-driver', - }, - }) - end let(:title) { 'test-datasource' } let(:params) { merge_params } @@ -122,39 +119,42 @@ def merge_params(hash = {}) with_xa(false) end - context 'with option prepared-statements-cache-size set to 46' do - let(:options) do { + describe 'with option prepared-statements-cache-size set to 46' do + let(:options) do + { 'prepared-statements-cache-size' => 46 } end - context 'in XA mode' do + describe 'in XA mode' do let(:params) do - merge_params({ :options => options, :xa => true }) + merge_params(:options => options, :xa => true) end it { is_expected.to contain_jboss_datasource('test-datasource').with_xa(true) } - it do is_expected.to contain_jboss_datasource('test-datasource').with_options({ - "validate-on-match"=>false, - "background-validation"=>false, - "share-prepared-statements"=>false, - "prepared-statements-cache-size"=>46, - "same-rm-override"=>true, - "wrap-xa-resource"=>true - }) + it do + is_expected.to contain_jboss_datasource('test-datasource').with_options( + 'validate-on-match' => false, + 'background-validation' => false, + 'share-prepared-statements' => false, + 'prepared-statements-cache-size' => 46, + 'same-rm-override' => true, + 'wrap-xa-resource' => true + ) end end - context 'in non-XA mode' do + describe 'in non-XA mode' do let(:params) do - merge_params({ :options => options, :xa => false }) + merge_params(:options => options, :xa => false) end it { is_expected.to contain_jboss_datasource('test-datasource').with_xa(false) } - it do is_expected.to contain_jboss_datasource('test-datasource').with_options({ - "validate-on-match"=>false, - "background-validation"=>false, - "share-prepared-statements"=>false, - "prepared-statements-cache-size"=>46 - }) + it do + is_expected.to contain_jboss_datasource('test-datasource').with_options( + 'validate-on-match' => false, + 'background-validation' => false, + 'share-prepared-statements' => false, + 'prepared-statements-cache-size' => 46 + ) end end end diff --git a/spec/defines/deploy_spec.rb b/spec/defines/deploy_spec.rb index 59902a9..8fe5736 100644 --- a/spec/defines/deploy_spec.rb +++ b/spec/defines/deploy_spec.rb @@ -1,72 +1,84 @@ require 'spec_helper_puppet' describe 'jboss::deploy', :type => :define do - shared_examples 'containing class structure' do it { is_expected.to contain_class('jboss') } it { is_expected.to contain_class('jboss::internal::runtime::node') } - it { is_expected.to contain_jboss_deploy(title).with({ - :ensure => 'present', - :source => '/tmp/jboss.war' - }) } + it { + is_expected.to contain_jboss_deploy(title).with( + :ensure => 'present', + :source => '/tmp/jboss.war' + ) + } end shared_examples 'containing self' do - it { is_expected.to contain_jboss__deploy(title).with({ + it { + is_expected.to contain_jboss__deploy(title).with( :ensure => 'present', :jndi => title - }) } + ) + } end shared_examples 'raise error' do - it { is_expected.to raise_error(Puppet::Error, /Invalid file extension, module only supports: .jar, .war, .ear, .rar/) } + it { + is_expected.to raise_error( + Puppet::Error, + /Invalid file extension, module only supports: .jar, .war, .ear, .rar/ + ) + } end - context 'On RedHat os family' do + describe 'On RedHat os family' do extend Testing::RspecPuppet::SharedExamples let(:facts) { Testing::RspecPuppet::SharedFacts.oraclelinux_facts } - context 'valid runtime_name' do + describe 'valid runtime_name' do let(:title) { 'test-deploy' } - let(:params) { { - :path => '/tmp/jboss.war', - :runtime_name => 'foobar-app.war'} - } + let(:params) do + { + :path => '/tmp/jboss.war', + :runtime_name => 'foobar-app.war' + } + end it_behaves_like 'containing class structure' it_behaves_like 'containing self' end - context 'invalid runtime name' do + describe 'invalid runtime name' do let(:title) { 'test-deploy' } - let(:params) { { - :path => '/tmp/jboss.war', - :runtime_name => 'foobar-app'} - } + let(:params) do + { + :path => '/tmp/jboss.war', + :runtime_name => 'foobar-app' + } + end it_behaves_like 'raise error' end - end - context 'On Debian os family' do + describe 'On Debian os family' do extend Testing::RspecPuppet::SharedExamples let(:facts) { Testing::RspecPuppet::SharedFacts.ubuntu_facts } - context 'valid runtime_name' do + describe 'valid runtime_name' do let(:title) { 'test-deploy' } - let(:params) { { :path => '/tmp/jboss.war', } } - + let(:params) { { :path => '/tmp/jboss.war' } } it_behaves_like 'containing class structure' it_behaves_like 'containing self' end - context 'invalid runtime_name' do + describe 'invalid runtime_name' do let(:title) { 'test-deploy' } - let(:params) { { - :path => '/tmp/jboss.war', - :runtime_name => 'foobar-app'} - } + let(:params) do + { + :path => '/tmp/jboss.war', + :runtime_name => 'foobar-app' + } + end it_behaves_like 'raise error' end diff --git a/spec/defines/interface_spec.rb b/spec/defines/interface_spec.rb index 572ff6f..7e2dc99 100644 --- a/spec/defines/interface_spec.rb +++ b/spec/defines/interface_spec.rb @@ -1,7 +1,6 @@ require 'spec_helper_puppet' describe 'jboss::interface', :type => :define do - shared_examples 'basic class structure' do it { is_expected.to contain_class('jboss') } it { is_expected.to contain_class('jboss::internal::augeas') } @@ -9,19 +8,19 @@ end basic_bind_variables_list = [ - "inet-address", "link-local-address", - "loopback", "loopback-address", "multicast", - "nic", "nic-match", "point-to-point", "public-address", - "site-local-address", "subnet-match", "up", "virtual" + 'inet-address', 'link-local-address', + 'loopback', 'loopback-address', 'multicast', + 'nic', 'nic-match', 'point-to-point', 'public-address', + 'site-local-address', 'subnet-match', 'up', 'virtual' ] - legacy_bind_variables_list = [ "any-ipv4-address", "any-ipv6-address" ] + legacy_bind_variables_list = ['any-ipv4-address', 'any-ipv6-address'] - let(:title) { 'test-interface' } + let(:title) { 'test-interface' } - let(:generic_params) {{ :any_address => 'true' }} - let(:any_addr_property) {{ 'any-address' => 'true' }} - let(:basic_bind_variables) { Hash[basic_bind_variables_list.map {|x| [x, :undef]}] } - let(:legacy_bind_variables) { Hash[legacy_bind_variables_list.map {|x| [x, :undef]}] } + let(:generic_params) { { :any_address => 'true' } } + let(:any_addr_property) { { 'any-address' => 'true' } } + let(:basic_bind_variables) { Hash[basic_bind_variables_list.map { |x| [x, :undef] }] } + let(:legacy_bind_variables) { Hash[legacy_bind_variables_list.map { |x| [x, :undef] }] } shared_examples 'completly working define' do it { is_expected.to contain_jboss__interface(title) } @@ -35,95 +34,111 @@ end shared_examples 'a define with properly configured interface' do - context 'with jboss_running => true and runasdomain => false parameters set' do - let(:facts) { generic_facts.merge({ :jboss_running => 'true' })} - let(:params) { generic_params.merge({ :runasdomain => 'false' })} - let(:pre_condition) { "class { jboss: product => '#{product}', version => '#{version}'}" } - - context 'with product => wildfly and version => 9.0.2.Final parameters set' do - let(:product) {'wildfly'} - let(:version) {'9.0.2.Final'} - - it { is_expected.to contain_jboss__clientry("/interface=#{title}").with_properties( - basic_bind_variables.merge(any_addr_property) - )} + describe 'with jboss_running => true and runasdomain => false parameters set' do + let(:facts) { generic_facts.merge(:jboss_running => 'true') } + let(:params) { generic_params.merge(:runasdomain => 'false') } + let(:pre_condition) { "class { jboss: product => '#{product}', version => '#{version}'}" } + + describe 'with product => wildfly and version => 9.0.2.Final parameters set' do + let(:product) { 'wildfly' } + let(:version) { '9.0.2.Final' } + + it { + is_expected.to contain_jboss__clientry("/interface=#{title}").with_properties( + basic_bind_variables.merge(any_addr_property) + ) + } end - context 'with product => wildfly and version => 8.2.1.Final parameters set' do - let(:product) {'wildfly'} - let(:version) {'8.2.1.Final'} + describe 'with product => wildfly and version => 8.2.1.Final parameters set' do + let(:product) { 'wildfly' } + let(:version) { '8.2.1.Final' } - it { is_expected.to contain_jboss__clientry("/interface=#{title}").with_properties( - basic_bind_variables.merge(legacy_bind_variables).merge(any_addr_property) - )} + it { + is_expected.to contain_jboss__clientry("/interface=#{title}").with_properties( + basic_bind_variables.merge(legacy_bind_variables).merge(any_addr_property) + ) + } end - context 'with product => jboss-eap and version => 7.0.0.Beta parameters set' do - let(:product) {'jboss-eap'} - let(:version) {'7.0.0.Beta'} + describe 'with product => jboss-eap and version => 7.0.0.Beta parameters set' do + let(:product) { 'jboss-eap' } + let(:version) { '7.0.0.Beta' } - it { is_expected.to contain_jboss__clientry("/interface=#{title}").with_properties( - basic_bind_variables.merge(any_addr_property) - )} + it { + is_expected.to contain_jboss__clientry("/interface=#{title}").with_properties( + basic_bind_variables.merge(any_addr_property) + ) + } end - context 'with product => wildfly and version => 15.0.0.Final parameters set' do - let(:product) {'wildfly'} - let(:version) {'15.0.0.Final'} + describe 'with product => wildfly and version => 15.0.0.Final parameters set' do + let(:product) { 'wildfly' } + let(:version) { '15.0.0.Final' } it { is_expected.to raise_error(Puppet::Error, /Unsupported version wildfly 15.0.0.Final/) } end end - context 'with jboss_running => false and runasdomain => false parameters set' do - let(:facts) { generic_facts.merge({ :jboss_running => 'false' })} - let(:params) { generic_params.merge({ :runasdomain => 'false' })} - let(:pre_condition) { "class { jboss: product => '#{product}', version => '#{version}'}" } + describe 'with jboss_running => false and runasdomain => false parameters set' do + let(:facts) { generic_facts.merge({ :jboss_running => 'false' }) } + let(:params) { generic_params.merge({ :runasdomain => 'false' }) } + let(:pre_condition) { "class { jboss: product => '#{product}', version => '#{version}'}" } - context 'with product => wildfly and version => 9.0.2.Final parameters set' do - let(:product) {'wildfly'} - let(:version) {'9.0.2.Final'} + describe 'with product => wildfly and version => 9.0.2.Final parameters set' do + let(:product) { 'wildfly' } + let(:version) { '9.0.2.Final' } basic_bind_variables_list.each do |var| it { is_expected.to contain_augeas("interface #{title} rm #{var}") } - it { is_expected.to contain_jboss__internal__interface__foreach("#{title}:#{var}").with_bind_variables( - basic_bind_variables.merge(any_addr_property) - )} + it { + is_expected.to contain_jboss__internal__interface__foreach("#{title}:#{var}").with_bind_variables( + basic_bind_variables.merge(any_addr_property) + ) + } end end - context 'with product => wildfly and version => 8.2.1.Final parameters set' do - let(:product) {'wildfly'} - let(:version) {'8.2.1.Final'} + describe 'with product => wildfly and version => 8.2.1.Final parameters set' do + let(:product) { 'wildfly' } + let(:version) { '8.2.1.Final' } basic_bind_variables_list.each do |var| it { is_expected.to contain_augeas("interface #{title} rm #{var}") } - it { is_expected.to contain_jboss__internal__interface__foreach("#{title}:#{var}").with_bind_variables( - basic_bind_variables.merge(legacy_bind_variables).merge(any_addr_property) - )} + it { + is_expected.to contain_jboss__internal__interface__foreach("#{title}:#{var}").with_bind_variables( + basic_bind_variables.merge(legacy_bind_variables).merge(any_addr_property) + ) + } end legacy_bind_variables_list.each do |var| it { is_expected.to contain_augeas("interface #{title} rm #{var}") } it { is_expected.to contain_augeas("interface public rm #{var}") } - it { is_expected.to contain_jboss__internal__interface__foreach("#{title}:#{var}").with_bind_variables( - basic_bind_variables.merge(legacy_bind_variables).merge(any_addr_property) - )} - it { is_expected.to contain_jboss__internal__interface__foreach("public:#{var}").with_bind_variables( - basic_bind_variables.merge(legacy_bind_variables).merge(any_addr_property) - )} + it { + is_expected.to contain_jboss__internal__interface__foreach("#{title}:#{var}").with_bind_variables( + basic_bind_variables.merge(legacy_bind_variables).merge(any_addr_property) + ) + } + it { + is_expected.to contain_jboss__internal__interface__foreach("public:#{var}").with_bind_variables( + basic_bind_variables.merge(legacy_bind_variables).merge(any_addr_property) + ) + } end end - context 'with product => jboss-eap and version => 7.0.0.Beta parameters set' do - let(:product) {'jboss-eap'} - let(:version) {'7.0.0.Beta'} + describe 'with product => jboss-eap and version => 7.0.0.Beta parameters set' do + let(:product) { 'jboss-eap' } + let(:version) { '7.0.0.Beta' } basic_bind_variables_list.each do |var| it { is_expected.to contain_augeas("interface #{title} rm #{var}") } - it { is_expected.to contain_jboss__internal__interface__foreach("#{title}:#{var}").with_bind_variables( - basic_bind_variables.merge(any_addr_property) - )} + it { + is_expected.to contain_jboss__internal__interface__foreach("#{title}:#{var}").with_bind_variables( + basic_bind_variables.merge(any_addr_property) + ) + } end end end end - context 'On RedHat os family' do + describe 'On RedHat os family' do extend Testing::RspecPuppet::SharedExamples let(:generic_facts) do { @@ -134,8 +149,8 @@ :puppetversion => Puppet.version } end - let(:facts) {generic_facts} - let(:params) {generic_params} + let(:facts) { generic_facts } + let(:params) { generic_params } it_behaves_like 'basic class structure' @@ -143,7 +158,7 @@ it_behaves_like 'a define with properly configured interface' end - context 'On Debian os family' do + describe 'On Debian os family' do extend Testing::RspecPuppet::SharedExamples let(:generic_facts) do { @@ -155,8 +170,8 @@ :puppetversion => Puppet.version } end - let(:facts) {generic_facts} - let(:params) {generic_params} + let(:facts) { generic_facts } + let(:params) { generic_params } it_behaves_like 'completly working define' it_behaves_like 'a define with properly configured interface' diff --git a/spec/defines/jmsqueue_spec.rb b/spec/defines/jmsqueue_spec.rb index bb44559..ff2d11c 100644 --- a/spec/defines/jmsqueue_spec.rb +++ b/spec/defines/jmsqueue_spec.rb @@ -2,40 +2,58 @@ describe 'jboss::jmsqueue', :type => :define do shared_examples 'contains self' do - it { is_expected.to contain_jboss_jmsqueue(title).with({ - :ensure => 'present', - :entries => [ - 'queue/app-mails', - 'java:jboss/exported/jms/queue/app-mails'] - }) } - it { is_expected.to contain_jboss_jmsqueue(title). - that_requires('Anchor[jboss::package::end]') } - it { is_expected.to contain_jboss__jmsqueue(title).with({ - :ensure => 'present', - :entries => [ - 'queue/app-mails', - 'java:jboss/exported/jms/queue/app-mails'] - }) } + it { + is_expected.to contain_jboss_jmsqueue(title).with( + :ensure => 'present', + :entries => [ + 'queue/app-mails', + 'java:jboss/exported/jms/queue/app-mails' + ] + ) + } + it { + is_expected.to contain_jboss_jmsqueue(title). + that_requires('Anchor[jboss::package::end]') + } + it { + is_expected.to contain_jboss__jmsqueue(title).with( + :ensure => 'present', + :entries => [ + 'queue/app-mails', + 'java:jboss/exported/jms/queue/app-mails' + ] + ) + } end - context 'On RedHat os family' do + describe 'On RedHat os family' do extend Testing::RspecPuppet::SharedExamples let(:title) { 'test-jmsqueue' } - let(:params) { { :entries => [ - 'queue/app-mails', - 'java:jboss/exported/jms/queue/app-mails'], } } + let(:params) do + { + :entries => [ + 'queue/app-mails', + 'java:jboss/exported/jms/queue/app-mails' + ] + } + end let(:facts) { Testing::RspecPuppet::SharedFacts.oraclelinux_facts } it_behaves_like containing_basic_class_structure it_behaves_like 'contains self' end - context 'On Debian os family' do + describe 'On Debian os family' do extend Testing::RspecPuppet::SharedExamples let(:title) { 'test-jmsqueue' } - let(:params) { { :entries => [ - 'queue/app-mails', - 'java:jboss/exported/jms/queue/app-mails'], } } + let(:params) do + { + :entries => [ + 'queue/app-mails', + 'java:jboss/exported/jms/queue/app-mails' + ] + } + end let(:facts) { Testing::RspecPuppet::SharedFacts.ubuntu_facts } it_behaves_like containing_basic_class_structure diff --git a/spec/defines/logging/async_spec.rb b/spec/defines/logging/async_spec.rb index d258823..f3ef4fb 100644 --- a/spec/defines/logging/async_spec.rb +++ b/spec/defines/logging/async_spec.rb @@ -2,11 +2,13 @@ describe 'jboss::logging::async', :type => :define do let(:title) { 'test-handler' } - let(:facts) { { - :osfamily => "RedHat", - :operatingsystem => "RedHat", - :concat_basedir => "/tmp/" - } } + let(:facts) do + { + :osfamily => 'RedHat', + :operatingsystem => 'RedHat', + :concat_basedir => '/tmp/' + } + end it { is_expected.to compile } it { is_expected.to contain_jboss__logging__async(title) } @@ -14,12 +16,12 @@ it do is_expected.to contain_jboss__clientry("/subsystem=logging/async-handler=#{title}"). with_ensure('present'). - with_properties({ + with_properties( 'level' => 'INFO', 'formatter' => '%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n', - 'subhandlers' => [ 'CONSOLE', 'FILE' ], + 'subhandlers' => %w[CONSOLE FILE], 'overflow-action' => 'BLOCK', - 'queue-length' => '1024', - }) + 'queue-length' => '1024' + ) end end diff --git a/spec/defines/logging/console_spec.rb b/spec/defines/logging/console_spec.rb index d788082..a30b766 100644 --- a/spec/defines/logging/console_spec.rb +++ b/spec/defines/logging/console_spec.rb @@ -2,11 +2,13 @@ describe 'jboss::logging::console', :type => :define do let(:title) { 'test-handler' } - let(:facts) { { - :osfamily => "RedHat", - :operatingsystem => "RedHat", - :concat_basedir => "/tmp/" - } } + let(:facts) do + { + :osfamily => 'RedHat', + :operatingsystem => 'RedHat', + :concat_basedir => '/tmp/' + } + end it { is_expected.to compile } it { is_expected.to contain_jboss__logging__console(title) } @@ -14,10 +16,10 @@ it do is_expected.to contain_jboss__clientry("/subsystem=logging/console-handler=#{title}"). with_ensure('present'). - with_properties({ + with_properties( 'level' => 'INFO', 'target' => 'System.out', - 'formatter' => '%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n', - }) + 'formatter' => '%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n' + ) end end diff --git a/spec/defines/logging/file_spec.rb b/spec/defines/logging/file_spec.rb index d9b18c9..e280369 100644 --- a/spec/defines/logging/file_spec.rb +++ b/spec/defines/logging/file_spec.rb @@ -2,11 +2,13 @@ describe 'jboss::logging::file', :type => :define do let(:title) { 'test-handler' } - let(:facts) { { - :osfamily => "RedHat", - :operatingsystem => "RedHat", - :concat_basedir => "/tmp/" - } } + let(:facts) do + { + :osfamily => 'RedHat', + :operatingsystem => 'RedHat', + :concat_basedir => '/tmp/' + } + end it { is_expected.to compile } it { is_expected.to contain_jboss__logging__file(title) } @@ -14,14 +16,14 @@ it do is_expected.to contain_jboss__clientry("/subsystem=logging/periodic-rotating-file-handler=#{title}"). with_ensure('present'). - with_properties({ + with_properties( 'level' => 'INFO', 'formatter' => '%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n', 'suffix' => '.yyyy-MM-dd', 'file' => { 'relative-to' => 'jboss.server.log.dir', - 'path' => 'server.log', + 'path' => 'server.log' } - }) + ) end end diff --git a/spec/defines/logging/logger_spec.rb b/spec/defines/logging/logger_spec.rb index f3ca238..544ef72 100644 --- a/spec/defines/logging/logger_spec.rb +++ b/spec/defines/logging/logger_spec.rb @@ -2,11 +2,13 @@ describe 'jboss::logging::logger', :type => :define do let(:title) { 'test-handler' } - let(:facts) { { - :osfamily => "RedHat", - :operatingsystem => "RedHat", - :concat_basedir => "/tmp/" - } } + let(:facts) do + { + :osfamily => 'RedHat', + :operatingsystem => 'RedHat', + :concat_basedir => '/tmp/' + } + end it { is_expected.to compile } it { is_expected.to contain_jboss__logging__logger(title) } @@ -14,9 +16,9 @@ it do is_expected.to contain_jboss__clientry("/subsystem=logging/logger=#{title}"). with_ensure('present'). - with_properties({ + with_properties( 'level' => 'INFO', - 'use-parent-handlers' => true, - }) + 'use-parent-handlers' => true + ) end end diff --git a/spec/defines/logging/root_spec.rb b/spec/defines/logging/root_spec.rb index ceaa2b2..5916f15 100644 --- a/spec/defines/logging/root_spec.rb +++ b/spec/defines/logging/root_spec.rb @@ -2,11 +2,13 @@ describe 'jboss::logging::root', :type => :define do let(:title) { 'test-handler' } - let(:facts) { { - :osfamily => "RedHat", - :operatingsystem => "RedHat", - :concat_basedir => "/tmp/" - } } + let(:facts) do + { + :osfamily => 'RedHat', + :operatingsystem => 'RedHat', + :concat_basedir => '/tmp/' + } + end it { is_expected.to compile } it { is_expected.to contain_jboss__logging__root(title) } @@ -14,9 +16,9 @@ it do is_expected.to contain_jboss__clientry("/subsystem=logging/root-logger=#{title}"). with_ensure('present'). - with_properties({ + with_properties( 'level' => 'INFO', - 'handlers' => [ 'CONSOLE', 'FILE' ], - }) + 'handlers' => %w[CONSOLE FILE] + ) end end diff --git a/spec/defines/logging/syslog_spec.rb b/spec/defines/logging/syslog_spec.rb index 5f33314..42c60d7 100644 --- a/spec/defines/logging/syslog_spec.rb +++ b/spec/defines/logging/syslog_spec.rb @@ -2,14 +2,16 @@ describe 'jboss::logging::syslog', :type => :define do let(:title) { 'test-handler' } - let(:params) { { :app_name => 'test-app', } } - let(:facts) { { - :osfamily => "RedHat", - :operatingsystem => "RedHat", - 'jboss::profile' => "domain", - 'jboss::controller' => "controller.example.com", - :concat_basedir => "/tmp/" - } } + let(:params) { { :app_name => 'test-app' } } + let(:facts) do + { + :osfamily => 'RedHat', + :operatingsystem => 'RedHat', + 'jboss::profile' => 'domain', + 'jboss::controller' => 'controller.example.com', + :concat_basedir => '/tmp/' + } + end it { is_expected.to compile } it { is_expected.to contain_jboss__logging__syslog(title) } @@ -17,12 +19,12 @@ it do is_expected.to contain_jboss__clientry("/subsystem=logging/syslog-handler=#{title}"). with_ensure('present'). - with_properties({ + with_properties( 'port' => 514, 'app-name' => 'test-app', 'level' => 'INFO', 'server-address' => '127.0.0.1', - 'syslog-format' => 'RFC5424', - }) + 'syslog-format' => 'RFC5424' + ) end end diff --git a/spec/defines/module_spec.rb b/spec/defines/module_spec.rb index 74e7b19..f52779b 100644 --- a/spec/defines/module_spec.rb +++ b/spec/defines/module_spec.rb @@ -4,18 +4,22 @@ shared_examples 'contains self' do it { is_expected.to contain_class('jboss') } - it { is_expected.to contain_jboss__internal__module__assemble(title).with({ - :layer => 'jdbc', - :artifacts => ["https://jdbc.postgresql.org/download/postgresql-9.4-1204.jdbc41.jar"], - :dependencies => ["javax.transaction.api", "javax.api"] - })} - it { is_expected.to contain_jboss__module(title).with({ - :layer => 'jdbc', - :artifacts => ["https://jdbc.postgresql.org/download/postgresql-9.4-1204.jdbc41.jar"] - }) } + it { + is_expected.to contain_jboss__internal__module__assemble(title).with( + :layer => 'jdbc', + :artifacts => ['https://jdbc.postgresql.org/download/postgresql-9.4-1204.jdbc41.jar'], + :dependencies => ['javax.transaction.api', 'javax.api'] + ) + } + it { + is_expected.to contain_jboss__module(title).with( + :layer => 'jdbc', + :artifacts => ['https://jdbc.postgresql.org/download/postgresql-9.4-1204.jdbc41.jar'] + ) + } end - context 'On RedHat os family' do + describe 'On RedHat os family' do extend Testing::RspecPuppet::SharedExamples let(:title) { 'test-module' } let(:params) do @@ -30,7 +34,7 @@ it_behaves_like 'contains self' end - context 'On Debian os family' do + describe 'On Debian os family' do extend Testing::RspecPuppet::SharedExamples let(:title) { 'test-module' } let(:params) do diff --git a/spec/defines/registerlayer_spec.rb b/spec/defines/registerlayer_spec.rb index 2a05aea..9277753 100644 --- a/spec/defines/registerlayer_spec.rb +++ b/spec/defines/registerlayer_spec.rb @@ -2,34 +2,48 @@ describe 'jboss::internal::module::registerlayer', :type => :define do let(:title) { 'testlayer' } - let(:params) { { :layer => title, } } - let(:pre_condition) { "class { jboss: product => '#{product}', version => '#{version}', jboss_user => '#{user}', jboss_group => '#{group}', install_dir => '#{dir}' }" } - let(:product) {'wildfly'} - let(:version) {'9.0.2.Final'} - let(:dir) {'/jboss'} - let(:user) {'test-user'} - let(:group) {'test-group'} + let(:params) { { :layer => title } } + let(:pre_condition) do + <<-here + class { 'jboss': + product => '#{product}', + version => '#{version}', + jboss_user => '#{user}', + jboss_group => '#{group}', + install_dir => '#{dir}', + } + here + end + let(:product) { 'wildfly' } + let(:version) { '9.0.2.Final' } + let(:dir) { '/jboss' } + let(:user) { 'test-user' } + let(:group) { 'test-group' } let(:facts) do { - :osfamily => 'RedHat', - :operatingsystem => 'OracleLinux', - :concat_basedir => '/tmp/' + :osfamily => 'RedHat', + :operatingsystem => 'OracleLinux', + :concat_basedir => '/tmp/' } end it { is_expected.to compile } it { is_expected.to contain_class 'jboss' } - it { is_expected.to contain_jboss__internal__module__registerlayer("#{title}") } - it { is_expected.to contain_exec("jboss::module::layer::#{title}").with({ - :command => "awk -F'=' 'BEGIN {ins = 0} /^layers=/ { ins = ins + 1; print \$1=testlayer,\$2 } END {if(ins == 0) print \"layers=testlayer,base\"}' > #{dir}/#{product}-#{version}/modules/layers.conf", - :unless => "egrep -e '^layers=.*testlayer.*' #{dir}/#{product}-#{version}/modules/layers.conf", - :user => 'test-user' - }) } + it { is_expected.to contain_jboss__internal__module__registerlayer(title.to_s) } + it { + is_expected.to contain_exec("jboss::module::layer::#{title}").with( + :unless => "egrep -e '^layers=.*testlayer.*' #{dir}/#{product}-#{version}/modules/layers.conf", + :user => 'test-user', + :command => "awk -F'=' 'BEGIN {ins = 0} /^layers=/ { ins = ins + 1; print \$1=testlayer,\$2 } END" \ + " {if(ins == 0) print \"layers=testlayer,base\"}' > #{dir}/#{product}-#{version}/modules/layers.conf" + ) + } it { - is_expected.to contain_file("#{dir}/#{product}-#{version}/modules/system/layers/#{title}").with({ - :ensure => 'directory', - :owner => 'test-user', - :group => 'test-group', - :mode => '0640' - }) } + is_expected.to contain_file("#{dir}/#{product}-#{version}/modules/system/layers/#{title}").with( + :ensure => 'directory', + :owner => 'test-user', + :group => 'test-group', + :mode => '0640' + ) + } end diff --git a/spec/defines/resourceadapter_spec.rb b/spec/defines/resourceadapter_spec.rb index 6c1dd2f..1d7d007 100644 --- a/spec/defines/resourceadapter_spec.rb +++ b/spec/defines/resourceadapter_spec.rb @@ -2,22 +2,27 @@ describe 'jboss::resourceadapter', :type => :define do shared_examples 'contains self' do - - it { is_expected.to contain_jboss_resourceadapter(title).with({ - :ensure => 'present', - :archive => 'jca-filestore.rar' - })} - it { is_expected.to contain_jboss_resourceadapter(title). - that_requires('Anchor[jboss::package::end]') } - it { is_expected.to contain_jboss__resourceadapter(title).with({ - :ensure => 'present', - :archive => 'jca-filestore.rar', - :transactionsupport => 'LocalTransaction', - :classname => 'org.example.jca.FileSystemConnectionFactory', - }) } + it { + is_expected.to contain_jboss_resourceadapter(title).with( + :ensure => 'present', + :archive => 'jca-filestore.rar' + ) + } + it { + is_expected.to contain_jboss_resourceadapter(title). + that_requires('Anchor[jboss::package::end]') + } + it { + is_expected.to contain_jboss__resourceadapter(title).with( + :ensure => 'present', + :archive => 'jca-filestore.rar', + :transactionsupport => 'LocalTransaction', + :classname => 'org.example.jca.FileSystemConnectionFactory' + ) + } end - context 'On RedHat os family' do + describe 'On RedHat os family' do extend Testing::RspecPuppet::SharedExamples let(:title) { 'test-resourceadapter' } let(:params) do @@ -25,7 +30,7 @@ :jndiname => 'java:/jboss/jca/photos', :archive => 'jca-filestore.rar', :transactionsupport => 'LocalTransaction', - :classname => 'org.example.jca.FileSystemConnectionFactory', + :classname => 'org.example.jca.FileSystemConnectionFactory' } end let(:facts) { Testing::RspecPuppet::SharedFacts.oraclelinux_facts } @@ -34,7 +39,7 @@ it_behaves_like 'contains self' end - context 'On Debian os family' do + describe 'On Debian os family' do extend Testing::RspecPuppet::SharedExamples let(:title) { 'test-resourceadapter' } let(:params) do @@ -42,7 +47,7 @@ :jndiname => 'java:/jboss/jca/photos', :archive => 'jca-filestore.rar', :transactionsupport => 'LocalTransaction', - :classname => 'org.example.jca.FileSystemConnectionFactory', + :classname => 'org.example.jca.FileSystemConnectionFactory' } end let(:facts) { Testing::RspecPuppet::SharedFacts.ubuntu_facts } diff --git a/spec/defines/securitydomain_spec.rb b/spec/defines/securitydomain_spec.rb index a66c3a1..01edc0d 100644 --- a/spec/defines/securitydomain_spec.rb +++ b/spec/defines/securitydomain_spec.rb @@ -1,16 +1,15 @@ require 'spec_helper_puppet' describe 'jboss::securitydomain', :type => :define do - shared_examples 'contains class structure' do it { is_expected.to contain_class('jboss') } it { is_expected.to contain_class('jboss::internal::service') } it { is_expected.to contain_class('jboss::internal::runtime::node') } it do - is_expected.to contain_jboss_securitydomain(title).with({ - :ensure => 'present', - :controller => '127.0.0.1', - }) + is_expected.to contain_jboss_securitydomain(title).with( + :ensure => 'present', + :controller => '127.0.0.1' + ) end end @@ -18,27 +17,28 @@ it { is_expected.to contain_jboss__securitydomain('test-securitydomain') } end - context 'On RedHat os family' do + describe 'On RedHat os family' do extend Testing::RspecPuppet::SharedExamples let(:title) { 'test-securitydomain' } - let(:params) {{ - :controller => '127.0.0.1' + let(:params) do + { + :controller => '127.0.0.1' } - } + end let(:facts) { Testing::RspecPuppet::SharedFacts.oraclelinux_facts } it_behaves_like 'contains class structure' it_behaves_like 'contains self' - end - context 'On Debian os family' do + describe 'On Debian os family' do extend Testing::RspecPuppet::SharedExamples let(:title) { 'test-securitydomain' } - let(:params) {{ - :controller => '127.0.0.1' + let(:params) do + { + :controller => '127.0.0.1' } - } + end let(:facts) { Testing::RspecPuppet::SharedFacts.ubuntu_facts } it_behaves_like 'contains class structure' diff --git a/spec/functions/jboss_basename_spec.rb b/spec/functions/jboss_basename_spec.rb index ab790f8..56063a1 100644 --- a/spec/functions/jboss_basename_spec.rb +++ b/spec/functions/jboss_basename_spec.rb @@ -1,7 +1,6 @@ -require "spec_helper" +require 'spec_helper_puppet' describe 'jboss_basename', :type => :puppet_function do - let(:input) { 'path/to/file' } it do is_expected.to run. @@ -12,7 +11,6 @@ it do is_expected.to run. with_params(input2). - and_return(['file', 'file2']) + and_return(%w[file file2]) end - end diff --git a/spec/functions/jboss_dirname_spec.rb b/spec/functions/jboss_dirname_spec.rb index dfbe144..94e34ef 100644 --- a/spec/functions/jboss_dirname_spec.rb +++ b/spec/functions/jboss_dirname_spec.rb @@ -1,7 +1,6 @@ -require "spec_helper" +require 'spec_helper_puppet' describe 'jboss_dirname', :type => :puppet_function do - let(:input) { 'path/to/file' } it do should run. diff --git a/spec/functions/jboss_hash_setvalue_spec.rb b/spec/functions/jboss_hash_setvalue_spec.rb index 76807af..b2e0f97 100644 --- a/spec/functions/jboss_hash_setvalue_spec.rb +++ b/spec/functions/jboss_hash_setvalue_spec.rb @@ -1,39 +1,37 @@ -require "spec_helper" +require 'spec_helper_puppet' describe 'jboss_hash_setvalue', :type => :puppet_function do - - context 'given invalid number of arguments(4)' do + describe 'given invalid number of arguments(4)' do it do - should run. - with_params(1,2,1,1).and_raise_error( + is_expected.to run. + with_params(1, 2, 1, 1).and_raise_error( Puppet::ParseError, - "jboss_hash_setvalue(): wrong lenght of input given (4 for 3)" + 'jboss_hash_setvalue(): wrong lenght of input given (4 for 3)' ) end end - context 'given invalid number of arguments(2)' do + describe 'given invalid number of arguments(2)' do it do - should run. - with_params(1,2).and_raise_error( + is_expected.to run. + with_params(1, 2).and_raise_error( Puppet::ParseError, - "jboss_hash_setvalue(): wrong lenght of input given (2 for 3)" + 'jboss_hash_setvalue(): wrong lenght of input given (2 for 3)' ) end end - context "given input => { 'john' = 'cena' }, 'adam', 'smith' it should return => { john => 'cena', adam => 'smith' }" do - before { skip('FIXME: Method should return hash not only last key, ref coi-gov-pl/puppet-jboss#28 ') } + describe "given input => { 'john' = 'cena' }, 'adam', 'smith' it should return => { john => 'cena', adam => 'smith' }" do + before(:each) do + skip('FIXME: Method should return hash not only last key, ref coi-gov-pl/puppet-jboss#28 ') + end let(:input) { { 'john' => 'cena' } } - it do - should run. - with_params(input, 'adam', 'smith').and_return('smith') - end - - after(:each) do - expect(input).to include('adam' => 'smith') - expect(input).to include('john' => 'cena') - expect(input.size).to eq(2) - end + it do + is_expected.to run. + with_params(input, 'adam', 'smith').and_return( + 'john' => 'cena', + 'adam' => 'smith' + ) + end end end diff --git a/spec/functions/jboss_short_version_spec.rb b/spec/functions/jboss_short_version_spec.rb index e28400e..e0b45f0 100644 --- a/spec/functions/jboss_short_version_spec.rb +++ b/spec/functions/jboss_short_version_spec.rb @@ -1,33 +1,32 @@ -require "spec_helper" +require 'spec_helper_puppet' describe 'jboss_short_version', :type => :puppet_function do - - describe 'with zero parameters given' do - it do - should run. - with_params().and_raise_error( - Puppet::ParseError, - 'jboss_short_version(): Wrong number of arguments given (0 for 1)' - ) - end + describe 'with zero parameters given' do + it do + should run. + with_params.and_raise_error( + Puppet::ParseError, + 'jboss_short_version(): Wrong number of arguments given (0 for 1)' + ) end + end - describe 'with two parameters given' do - it do - should run. - with_params('as-7.1.1.Final', 'eap-6.2.0.GA').and_raise_error( - Puppet::ParseError, - 'jboss_short_version(): Wrong number of arguments given (2 for 1)' - ) - end + describe 'with two parameters given' do + it do + should run. + with_params('as-7.1.1.Final', 'eap-6.2.0.GA').and_raise_error( + Puppet::ParseError, + 'jboss_short_version(): Wrong number of arguments given (2 for 1)' + ) end + end - describe 'with as-7.1.1.Final as input it should return 7.1' do - let(:args) { ['as-7.1.1.Final'] } - it { should run.with_params(args[0]).and_return '7.1' } - end + describe 'with as-7.1.1.Final as input it should return 7.1' do + let(:args) { ['as-7.1.1.Final'] } + it { should run.with_params(args[0]).and_return '7.1' } + end - describe 'with asd as input it should return nil' do - it { should run.with_params('asd').and_return nil } - end + describe 'with asd as input it should return nil' do + it { should run.with_params('asd').and_return nil } + end end diff --git a/spec/functions/jboss_to_bool_spec.rb b/spec/functions/jboss_to_bool_spec.rb index 61311b5..2761410 100644 --- a/spec/functions/jboss_to_bool_spec.rb +++ b/spec/functions/jboss_to_bool_spec.rb @@ -1,22 +1,22 @@ -require 'spec_helper' +require 'spec_helper_puppet' describe 'jboss_to_bool', :type => :puppet_function do it do should run. - with_params().and_raise_error( - Puppet::ParseError, + with_params.and_raise_error( + Puppet::ParseError, 'jboss_to_bool(): Wrong number of arguments given (0 for 1)' ) end - + it do should run. with_params(1, true).and_raise_error( - Puppet::ParseError, + Puppet::ParseError, 'jboss_to_bool(): Wrong number of arguments given (2 for 1)' ) end - + it { should run.with_params(true).and_return true } it { should run.with_params(1).and_return true } it { should run.with_params(:true).and_return true } @@ -27,7 +27,7 @@ it { should run.with_params('t').and_return true } it { should run.with_params('yes').and_return true } it { should run.with_params('y').and_return true } - + it { should run.with_params(nil).and_return false } it { should run.with_params(false).and_return false } it { should run.with_params(:undef).and_return false } @@ -46,5 +46,4 @@ it { should run.with_params(:n).and_return false } it { should run.with_params('no').and_return false } it { should run.with_params('n').and_return false } - -end \ No newline at end of file +end diff --git a/spec/functions/jboss_to_i_spec.rb b/spec/functions/jboss_to_i_spec.rb index a921010..51c10af 100644 --- a/spec/functions/jboss_to_i_spec.rb +++ b/spec/functions/jboss_to_i_spec.rb @@ -1,10 +1,10 @@ -require 'spec_helper' +require 'spec_helper_puppet' describe 'jboss_to_i', :type => :puppet_function do it do should run. - with_params().and_raise_error( - Puppet::ParseError, + with_params.and_raise_error( + Puppet::ParseError, 'jboss_to_i(): Wrong number of arguments given (0 for 1)' ) end @@ -13,10 +13,9 @@ it { should run.with_params('').and_return(0) } it { should run.with_params(123).and_return(123) } it { should run.with_params('67').and_return(67) } - + it do v = :azx should run.with_params(v).and_return(0) end - -end \ No newline at end of file +end diff --git a/spec/functions/jboss_to_s_spec.rb b/spec/functions/jboss_to_s_spec.rb index a169ecf..d52e64a 100644 --- a/spec/functions/jboss_to_s_spec.rb +++ b/spec/functions/jboss_to_s_spec.rb @@ -1,27 +1,27 @@ -require 'spec_helper' +require 'spec_helper_puppet' describe 'jboss_to_s', :type => :puppet_function do it 'should throw Puppet::ParseError if passing 0 args' do should run. - with_params().and_raise_error( - Puppet::ParseError, + with_params.and_raise_error( + Puppet::ParseError, 'jboss_to_s(): Wrong number of arguments given (0 for 1)' ) end - + it 'should throw Puppet::ParseError if passing 2 args' do should run. with_params(1, true).and_raise_error( - Puppet::ParseError, + Puppet::ParseError, 'jboss_to_s(): Wrong number of arguments given (2 for 1)' ) end - + it 'should return "true" if passing true' do should run.with_params(true).and_return 'true' end - + it 'should return "undef" if passing :undef' do should run.with_params(:undef).and_return 'undef' end -end \ No newline at end of file +end diff --git a/spec/functions/jboss_type_version_spec.rb b/spec/functions/jboss_type_version_spec.rb index e3a378b..294ef92 100644 --- a/spec/functions/jboss_type_version_spec.rb +++ b/spec/functions/jboss_type_version_spec.rb @@ -1,18 +1,17 @@ -require "spec_helper" +require 'spec_helper_puppet' describe 'jboss_type_version' do - - context 'given invalid number of parameters' do + describe 'given invalid number of parameters' do it do should run. - with_params().and_raise_error( + with_params.and_raise_error( Puppet::ParseError, 'jboss_type_version(): Given invalid number of parameters(0 instead of 1)' ) end end - context 'given as-7.1.1.Final it should return as' do + describe 'given as-7.1.1.Final it should return as' do let(:input) { 'as-7.1.1.Final' } it do should run. @@ -20,7 +19,7 @@ end end - context 'given invalid input' do + describe 'given invalid input' do let(:input) { 'asd' } it do should run. diff --git a/spec/spec.opts b/spec/spec.opts deleted file mode 100644 index e6ad807..0000000 --- a/spec/spec.opts +++ /dev/null @@ -1,6 +0,0 @@ ---format -d ---colour ---loadby -mtime ---backtrace diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2cf1111..e766324 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,77 +1,34 @@ -require 'puppetlabs_spec_helper/module_spec_helper' -require 'rspec/its' - -unless $executing_puppet - begin - gem 'simplecov' - require 'simplecov' - formatters = [] - formatters << SimpleCov::Formatter::HTMLFormatter - - begin - gem 'coveralls' - require 'coveralls' - formatters << Coveralls::SimpleCov::Formatter if ENV['TRAVIS'] - rescue Gem::LoadError - # do nothing - end - - begin - gem 'codeclimate-test-reporter' - require 'codeclimate-test-reporter' - formatters << CodeClimate::TestReporter::Formatter if (ENV['TRAVIS'] and ENV['CODECLIMATE_REPO_TOKEN']) - rescue Gem::LoadError - # do nothing - end - SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(formatters) - SimpleCov.start do - add_filter "/spec/" - add_filter "/.vendor/" - add_filter "/vendor/" - add_filter "/gems/" - minimum_coverage 76 - refuse_coverage_drop - end - rescue Gem::LoadError - # do nothing - end -end - -begin - gem 'pry' - require 'pry' -rescue Gem::LoadError - # do nothing +def gem_present(name) + !Bundler.rubygems.find_name(name).empty? end -module Testing - module Mock end +if gem_present 'simplecov' + require 'simplecov' + SimpleCov.start do + add_filter '/spec/' + add_filter '/.vendor/' + add_filter '/vendor/' + add_filter '/gems/' + end + formatters = [SimpleCov::Formatter::HTMLFormatter] + if gem_present 'codecov' + require 'codecov' + formatters.push SimpleCov::Formatter::Codecov + end + SimpleCov.formatters = formatters end +require 'pry' if gem_present 'pry' +require 'rspec/its' +require 'puppet' require 'puppet_x/coi/jboss' -require 'testing/mock/mocked_execution_state_wrapper' -require 'testing/mock/mocked_shell_executor' - -require 'rspec-puppet' +require 'testing' RSpec.configure do |c| - c.tty = true unless ENV['JENKINS_URL'].nil? c.mock_with :rspec do |mock| - mock.syntax = [:expect, :should] - end - c.include PuppetlabsSpec::Files - - c.before :each do - # Store any environment variables away to be restored later - @old_env = {} - ENV.each_key {|k| @old_env[k] = ENV[k]} - - if ENV['STRICT_VARIABLES'] == 'yes' - Puppet.settings[:strict_variables]=true - end - end - - c.after :each do - PuppetlabsSpec::Files.cleanup + mock.syntax = [:expect] end + # Readable test descriptions + c.formatter = :documentation + c.order = :rand end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 0dce8b7..1c7d3a4 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,63 +1,23 @@ -require 'beaker-rspec/spec_helper' -require 'beaker-rspec/helpers/serverspec' - -unless ENV['RS_PROVISION'] == 'no' or ENV['BEAKER_provision'] == 'no' - - puppetver = if RUBY_VERSION < '1.9.0' then '2.7.26' else ENV['PUPPET_VERSION'] end - facterver = ENV['FACTER_VERSION'] - # This will install the latest available package on el and deb based - # systems fail on windows and osx, and install via gem on other *nixes - foss_opts = { :default_action => 'gem_install' } - foss_opts[:version] = puppetver unless puppetver.nil? - foss_opts[:facter_version] = facterver unless facterver.nil? - - if default.is_pe? - install_pe - else - install_puppet_on(hosts, foss_opts) - end - - hosts.each do |host| - if fact('osfamily') == 'Debian' - install_package host, 'locales' - on host, 'echo "en_US.UTF-8 UTF-8" > /etc/locale.gen' - on host, '/usr/sbin/locale-gen' - on host, '/usr/sbin/update-locale' - end - shell("mkdir -p #{host['distmoduledir']}") - if ! host.is_pe? - # Augeas is only used in one place, for Redhat. - if fact('osfamily') == 'RedHat' - install_package host, 'ruby-devel' - install_package host, 'tar' - end - end - end -end - -UNSUPPORTED_PLATFORMS = ['AIX','windows','Solaris', 'Suse'] - -module Testing - module Acceptance end +require 'puppet' +require 'beaker-rspec' +require 'beaker/puppeter' +require 'beaker/puppet_install_helper' +require 'beaker/module_install_helper' +require 'puppet-examples-helpers' +require 'testing' + +if default[:type] == 'pe' + run_puppet_install_helper +else + run_puppeter end -require 'testing/acceptance/cleaner' -require 'testing/acceptance/smoke_test_reader' +install_module +install_module_dependencies +shell 'rm -fv /etc/profile.d/python27.sh' RSpec.configure do |c| - # Project root - proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + c.include PuppetExamplesHelpers - # Configure all nodes in nodeset - c.before :suite do - # Install module and dependencies - hosts.each do |host| - on host, "/bin/touch #{default['puppetpath']}/hiera.yaml" - on host, 'chmod 755 /root' - # Installs module for dependencies and then removes it - on host, puppet('module','install','coi/jboss'), { :acceptable_exit_codes => [0,1] } - on host, puppet('module','uninstall','coi/jboss'), { :acceptable_exit_codes => [0,1] } - end - install_dev_puppet_module(:source => proj_root, :module_name => 'jboss') - hosts.each { |host| on host, puppet('module', 'list'), { :acceptable_exit_codes => [0,1] } } - end + c.formatter = :documentation + c.order = :defined end diff --git a/spec/spec_helper_puppet.rb b/spec/spec_helper_puppet.rb index 2d41024..2a3e7ff 100644 --- a/spec/spec_helper_puppet.rb +++ b/spec/spec_helper_puppet.rb @@ -1,10 +1,22 @@ -$executing_puppet = true - require 'spec_helper' -module Testing - module RspecPuppet end -end -require 'testing/rspec_puppet/shared_facts' -require 'testing/rspec_puppet/shared_examples' +require 'puppetlabs_spec_helper/module_spec_helper' +require 'rspec-puppet-facts' + +include RspecPuppetFacts at_exit { RSpec::Puppet::Coverage.report! } + +RSpec.configure do |c| + c.include PuppetlabsSpec::Files + c.before :each do + if ENV['STRICT_VARIABLES'] == 'yes' + Puppet.settings[:strict_variables] = true + end + end + + c.after :each do + PuppetlabsSpec::Files.cleanup + end + + c.hiera_config = File.expand_path(File.join(__FILE__, '../hiera/hiera.yaml')) +end diff --git a/spec/testing.rb b/spec/testing.rb new file mode 100644 index 0000000..493bee6 --- /dev/null +++ b/spec/testing.rb @@ -0,0 +1,14 @@ +module Testing + module Acceptance end + module RspecPuppet end + module Mock end +end + +require 'testing/acceptance/cleaner' +require 'testing/acceptance/javaplatform' + +require 'testing/rspec_puppet/shared_facts' +require 'testing/rspec_puppet/shared_examples' + +require 'testing/mock/mocked_execution_state_wrapper' +require 'testing/mock/mocked_shell_executor' diff --git a/spec/testing/acceptance/javaplatform.rb b/spec/testing/acceptance/javaplatform.rb new file mode 100644 index 0000000..2fdfab6 --- /dev/null +++ b/spec/testing/acceptance/javaplatform.rb @@ -0,0 +1,16 @@ +class Testing::Acceptance::JavaPlatform + JAVA6_PLATFORMS = [ + 'Ubuntu 14.04', + 'CentOS 6' + ].freeze + + class << self + def java6compatibile? + JAVA6_PLATFORMS.any? do |c| + os = fact('operatingsystem') + rel = fact('operatingsystemmajrelease') + c == "#{os} #{rel}" + end + end + end +end diff --git a/spec/testing/acceptance/smoke_test_reader.rb b/spec/testing/acceptance/smoke_test_reader.rb deleted file mode 100644 index 79f3e7d..0000000 --- a/spec/testing/acceptance/smoke_test_reader.rb +++ /dev/null @@ -1,18 +0,0 @@ -module Testing::Acceptance::SmokeTestReader - class << self - def smoke_pp(pp_symbol) - path = smokedir.join(pp_symbol.to_s.gsub(/::/, '/') + '.pp') - path.read - end - - private - - def smokedir - rootdir.join('examples') - end - - def rootdir - Pathname.new(__FILE__).parent.parent.parent.parent.realpath - end - end -end diff --git a/spec/testing/files/already_sanitized.txt b/spec/testing/files/already_sanitized.txt new file mode 100644 index 0000000..1c8d62a --- /dev/null +++ b/spec/testing/files/already_sanitized.txt @@ -0,0 +1,26 @@ +"other" => { +"acl" => undefined, +"audit" => undefined, +"authorization" => undefined, +"cache-type" => "default", +"identity-trust" => undefined, +"jsse" => undefined, +"mapping" => undefined, +"authentication" => {"classic" => {"login-modules" => [ + { + "code" => "Remoting", + "flag" => "optional", + "module-options" => [{"password-stacking" => "useFirstPass"}] + }, + { + "code" => "RealmUsersRoles", + "flag" => "required", + "module-options" => [ + {"usersProperties" => "${jboss.server.config.dir}/application-users.properties"}, + {"rolesProperties" => "${jboss.server.config.dir}/application-roles.properties"}, + {"realm" => "ApplicationRealm"}, + {"password-stacking" => "useFirstPass"} + ] + } +]}} +}, diff --git a/spec/testing/files/sanitized_output.txt b/spec/testing/files/sanitized_output.txt new file mode 100644 index 0000000..1062687 --- /dev/null +++ b/spec/testing/files/sanitized_output.txt @@ -0,0 +1,63 @@ +{ + "outcome" => "success", + "result" => { + "deep-copy-subject-mode" => false, + "vault" => undefined, + "security-domain" => { + "jboss-web-policy" => { + "acl" => undefined, + "audit" => undefined, + "authentication" => undefined, + "cache-type" => "default", + "identity-trust" => undefined, + "jsse" => undefined, + "mapping" => undefined, + "authorization" => {"classic" => {"policy-modules" => [{ + "code" => "Delegating", + "flag" => "required", + "module-options" => undefined + }]}} + }, + "other" => { + "acl" => undefined, + "audit" => undefined, + "authorization" => undefined, + "cache-type" => "default", + "identity-trust" => undefined, + "jsse" => undefined, + "mapping" => undefined, + "authentication" => {"classic" => {"login-modules" => [ + { + "code" => "Remoting", + "flag" => "optional", + "module-options" => [{'password-stacking' => 'useFirstPass'}] + }, + { + "code" => "RealmUsersRoles", + "flag" => "required", + "module-options" => [ + {'usersProperties' => '${jboss.server.config.dir}/application-users.properties'}, + {'rolesProperties' => '${jboss.server.config.dir}/application-roles.properties'}, + {'realm' => 'ApplicationRealm'}, + {'password-stacking' => 'useFirstPass'} + ] + } + ]}} + }, + "jboss-ejb-policy" => { + "acl" => undefined, + "audit" => undefined, + "authentication" => undefined, + "cache-type" => "default", + "identity-trust" => undefined, + "jsse" => undefined, + "mapping" => undefined, + "authorization" => {"classic" => {"policy-modules" => [{ + "code" => "Delegating", + "flag" => "required", + "module-options" => undefined + }]}} + } + } + } + } diff --git a/spec/testing/mock/mocked_execution_state_wrapper.rb b/spec/testing/mock/mocked_execution_state_wrapper.rb index 2cd42ec..f81e9ea 100644 --- a/spec/testing/mock/mocked_execution_state_wrapper.rb +++ b/spec/testing/mock/mocked_execution_state_wrapper.rb @@ -1,5 +1,6 @@ require 'spec_helper' require 'ostruct' + class Testing::Mock::ExecutionStateWrapper < Puppet_X::Coi::Jboss::Internal::ExecutionStateWrapper def initialize @commands = {} @@ -7,11 +8,12 @@ def initialize end def register_command(command, expected_status, expected_lines, expected_result) - execution_state = Puppet_X::Coi::Jboss::Internal::State::ExecutionState.new(expected_result, - expected_status, - expected_lines, - command - ) + execution_state = Puppet_X::Coi::Jboss::Internal::State::ExecutionState.new( + expected_result, + expected_status, + expected_lines, + command + ) @commands[command] = execution_state end diff --git a/spec/testing/mock/mocked_shell_executor.rb b/spec/testing/mock/mocked_shell_executor.rb index 7f95530..6f04242 100644 --- a/spec/testing/mock/mocked_shell_executor.rb +++ b/spec/testing/mock/mocked_shell_executor.rb @@ -1,9 +1,11 @@ require 'ostruct' + class Testing::Mock::MockedShellExecutor def initialize @commands = {} @last_exetuded_command = nil end + def register_command(cmd, output, existstatus, success) result = OpenStruct.new(:exitstatus => existstatus, :success? => success) @last_exetuded_command = result diff --git a/spec/testing/rspec_puppet/shared_examples.rb b/spec/testing/rspec_puppet/shared_examples.rb index e0fcf2d..5c38b7c 100644 --- a/spec/testing/rspec_puppet/shared_examples.rb +++ b/spec/testing/rspec_puppet/shared_examples.rb @@ -1,20 +1,19 @@ module Testing::RspecPuppet::SharedExamples - DEFAULT_VERSION = '9.0.2.Final' - DEFAULT_PRODUCT = 'wildfly' + DEFAULT_VERSION = '9.0.2.Final'.freeze + DEFAULT_PRODUCT = 'wildfly'.freeze DEFAULT_WITH = [ :anchors, :interfaces, :packages - ] + ].freeze DEFAULT_OPTIONS = { :product => DEFAULT_PRODUCT, :version => DEFAULT_VERSION, :with => DEFAULT_WITH - } - + }.freeze def containing_basic_class_structure - name = "containing basic class structure" + name = 'containing basic class structure' shared_examples(name) do it { is_expected.to compile } it { is_expected.to contain_class 'jboss' } @@ -26,13 +25,14 @@ def containing_basic_class_structure def common_anchors anchor_list = [ - "begin", "end", "configuration::begin", "configuration::end", - "installed", "package::begin", "package::end", - "service::begin", "service::end", "service::started"].map {|item| "jboss::#{item}"} + 'begin', 'end', 'configuration::begin', 'configuration::end', + 'installed', 'package::begin', 'package::end', + 'service::begin', 'service::end', 'service::started' + ].map { |item| "jboss::#{item}" } name = 'having common anchors' shared_examples(name) do anchor_list.each do |item| - it { is_expected.to contain_anchor("#{item}") } + it { is_expected.to contain_anchor(item.to_s) } end end name @@ -40,45 +40,60 @@ def common_anchors def common_interfaces(version = DEFAULT_VERSION, product = DEFAULT_PRODUCT) basic_bind_variables_list = [ - "inet-address", "link-local-address", - "loopback", "loopback-address", "multicast", - "nic", "nic-match", "point-to-point", "public-address", - "site-local-address", "subnet-match", "up", "virtual" ] + 'inet-address', 'link-local-address', + 'loopback', 'loopback-address', 'multicast', + 'nic', 'nic-match', 'point-to-point', 'public-address', + 'site-local-address', 'subnet-match', 'up', 'virtual' + ] name = 'common interfaces' shared_examples(name) do it { is_expected.to contain_class 'jboss::internal::configure::interfaces' } - it { is_expected.to contain_jboss__interface('public').with({ - :ensure => 'present', - :inet_address => nil - }) } - it { is_expected.to contain_augeas('ensure present interface public').with({ + it { + is_expected.to contain_jboss__interface('public').with( + :ensure => 'present', + :inet_address => nil + ) + } + it { + is_expected.to contain_augeas('ensure present interface public').with( :context => "/files/usr/lib/#{product}-#{version}/standalone/configuration/standalone-full.xml/", - :changes => "set server/interfaces/interface[last()+1]/#attribute/name public", + :changes => 'set server/interfaces/interface[last()+1]/#attribute/name public', :onlyif => "match server/interfaces/interface[#attribute/name='public'] size == 0" - }) } - it { is_expected.to contain_augeas('interface public set any-address').with({ - :context => "/files/usr/lib/#{product}-#{version}/standalone/configuration/standalone-full.xml/", - :changes => "set server/interfaces/interface[#attribute/name='public']/any-address/#attribute/value 'true'", - :onlyif => "get server/interfaces/interface[#attribute/name='public']/any-address/#attribute/value != 'true'" - }) } - it { is_expected.to contain_jboss__internal__interface__foreach("public:any-address").with({ - :cfg_file => "/usr/lib/#{product}-#{version}/standalone/configuration/standalone-full.xml", - :path => 'server/interfaces' - }) } - it { is_expected.to contain_service(product).with({ - :ensure => 'running', - :enable => true - }) } - basic_bind_variables_list.each do |var| - it { is_expected.to contain_augeas("interface public rm #{var}").with({ + ) + } + it { + is_expected.to contain_augeas('interface public set any-address').with( :context => "/files/usr/lib/#{product}-#{version}/standalone/configuration/standalone-full.xml/", - :changes => "rm server/interfaces/interface[#attribute/name='public']/#{var}", - :onlyif => "match server/interfaces/interface[#attribute/name='public']/#{var} size != 0" - }) } - it { is_expected.to contain_jboss__internal__interface__foreach("public:#{var}").with({ + :changes => "set server/interfaces/interface[#attribute/name='public']/any-address/#attribute/value 'true'", + :onlyif => "get server/interfaces/interface[#attribute/name='public']/any-address/#attribute/value != 'true'" + ) + } + it { + is_expected.to contain_jboss__internal__interface__foreach('public:any-address').with( :cfg_file => "/usr/lib/#{product}-#{version}/standalone/configuration/standalone-full.xml", :path => 'server/interfaces' - }) } + ) + } + it { + is_expected.to contain_service(product).with( + :ensure => 'running', + :enable => true + ) + } + basic_bind_variables_list.each do |var| + it { + is_expected.to contain_augeas("interface public rm #{var}").with( + :context => "/files/usr/lib/#{product}-#{version}/standalone/configuration/standalone-full.xml/", + :changes => "rm server/interfaces/interface[#attribute/name='public']/#{var}", + :onlyif => "match server/interfaces/interface[#attribute/name='public']/#{var} size != 0" + ) + } + it { + is_expected.to contain_jboss__internal__interface__foreach("public:#{var}").with( + :cfg_file => "/usr/lib/#{product}-#{version}/standalone/configuration/standalone-full.xml", + :path => 'server/interfaces' + ) + } end end name diff --git a/spec/testing/rspec_puppet/shared_facts.rb b/spec/testing/rspec_puppet/shared_facts.rb index 3a0ba16..40b6423 100644 --- a/spec/testing/rspec_puppet/shared_facts.rb +++ b/spec/testing/rspec_puppet/shared_facts.rb @@ -1,6 +1,6 @@ class Testing::RspecPuppet::SharedFacts - DEFAULT_IP = '192.168.0.1' - DEFAULT_CONCAT_DIR = '/root/concat' + DEFAULT_IP = '192.168.0.1'.freeze + DEFAULT_CONCAT_DIR = '/root/concat'.freeze DEFAULT_ORACLELINUX_FACTS = { :operatingsystem => 'OracleLinux', @@ -11,8 +11,8 @@ class Testing::RspecPuppet::SharedFacts :operatingsystemmajrelease => '6', :puppetversion => Puppet.version.to_s, :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' - } - DEFAULT_UBUNTU_RELEASE = '14.04' + }.freeze + DEFAULT_UBUNTU_RELEASE = '14.04'.freeze DEFAULT_UBUNTU_FACTS = { :operatingsystem => 'Ubuntu', :osfamily => 'Debian', @@ -27,7 +27,7 @@ class Testing::RspecPuppet::SharedFacts :lsbmajdistrelease => DEFAULT_UBUNTU_RELEASE, :puppetversion => Puppet.version.to_s, :path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' - } + }.freeze class << self def ubuntu_facts(override = {}) DEFAULT_UBUNTU_FACTS.merge(override) diff --git a/spec/unit/facter/facts_spec.rb b/spec/unit/facter/facts_refresher_spec.rb similarity index 71% rename from spec/unit/facter/facts_spec.rb rename to spec/unit/facter/facts_refresher_spec.rb index 0f73ef3..265ba0f 100644 --- a/spec/unit/facter/facts_spec.rb +++ b/spec/unit/facter/facts_refresher_spec.rb @@ -1,9 +1,9 @@ -require 'spec_helper' +require 'spec_helper_puppet' describe Puppet_X::Coi::Jboss::FactsRefresher do - context 'basic test to check if fact is deleted' do + describe 'basic test to check if fact is deleted' do before :each do - fct = Facter.add(:test_fact) { setcode { 'test value' } } + Facter.add(:test_fact) { setcode { 'test value' } } end after :each do @@ -15,8 +15,7 @@ describe '#delete_resolves' do subject { described_class.delete_resolves(fact) } - context 'delete selfmade fact' do - + describe 'delete selfmade fact' do after :each do fct = Facter.fact fact facter_value = fct.instance_variable_get(:@resolves) @@ -31,8 +30,7 @@ describe '#delete value' do subject { described_class.delete_value(fact) } - context '#delete_value selfmade fact' do - + describe '#delete_value selfmade fact' do after :each do fct = Facter.fact fact facter_value = fct.instance_variable_get(:@value) @@ -45,14 +43,16 @@ end end - context 'tests for refreshing facts' do + describe 'tests for refreshing facts' do describe '#refresh_facts' do subject { described_class.refresh_facts(facts) } - context 'refresh facts from correct list of facts' do + describe 'refresh facts from correct list of facts' do before :each do - expect(Facter).to receive(:list).and_return(['test_fact', 'jboss_test_fact']) - expect(Puppet_X::Coi::Jboss::Configuration).to receive(:read).at_least(1).times.and_return({ :jboss_test_fact => 'test' }) + expect(Facter).to receive(:list).and_return(%w[test_fact jboss_test_fact]) + expect(Puppet_X::Coi::Jboss::Configuration).to receive(:read).at_least(1).times.and_return( + :jboss_test_fact => 'test' + ) end let(:facts) { [:jboss_test_fact] } it { expect(subject).to eq([:jboss_test_fact]) } diff --git a/spec/unit/facter/jboss_configfile_spec.rb b/spec/unit/facter/jboss_configfile_spec.rb index f70ebcb..5c65b99 100644 --- a/spec/unit/facter/jboss_configfile_spec.rb +++ b/spec/unit/facter/jboss_configfile_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'spec_helper_puppet' describe 'Fact jboss_configfile', :type => :fact do subject { Facter.value(:jboss_configfile) } @@ -12,7 +12,7 @@ fct = Facter.fact :jboss_configfile fct.instance_variable_set(:@value, nil) end - context "with sample file \"export JBOSS_CONF='/etc/jboss-eap/jboss-eap.conf'\"" do + describe "with sample file \"export JBOSS_CONF='/etc/jboss-eap/jboss-eap.conf'\"" do it { expect(subject).to eq(sample_config) } end -end \ No newline at end of file +end diff --git a/spec/unit/facter/jboss_fullconfig_spec.rb b/spec/unit/facter/jboss_fullconfig_spec.rb index 9100056..d780f26 100644 --- a/spec/unit/facter/jboss_fullconfig_spec.rb +++ b/spec/unit/facter/jboss_fullconfig_spec.rb @@ -1,7 +1,6 @@ -require 'spec_helper' +require 'spec_helper_puppet' describe 'Fact jboss_fullconfig', :type => :fact do - let(:sample_config) do t = Tempfile.new('rspec-jboss-fullconfig') path = t.path @@ -67,7 +66,7 @@ 'runasdomain' => false, 'mode' => 'standalone', 'controller' => '127.0.0.1:9990', - 'profile' => 'full', + 'profile' => 'full' } end before :all do @@ -79,7 +78,7 @@ Facter.clear expect(Puppet_X::Coi::Jboss::Configuration).to receive(:read_raw_profile_d). at_least(:once).and_return(profile_d_content) - File.open(sample_config, 'w') {|f| f.write(sample_content) } + File.open(sample_config, 'w') { |f| f.write(sample_content) } end after :each do fct = Facter.fact :jboss_fullconfig @@ -93,34 +92,37 @@ it { expect(subject).not_to be_nil } it { expect(subject).not_to be_empty } end - context 'with sample config file for WildFly 8.2' do - context 'without mocking RUBY_VERSION' do + describe 'with sample config file for WildFly 8.2' do + describe 'without mocking RUBY_VERSION' do it_behaves_like 'is not nill and empty' it { expect(subject).to respond_to(:[]) } its(:size) { should eq(10) } it { expect(subject).to eq(expected_hash) } end - context 'with mocking RUBY_VERSION to 1.8.7' do + describe 'with mocking RUBY_VERSION to 1.8.7' do before :each do expect(Puppet_X::Coi::Jboss::Configuration).to receive(:ruby_version).once.and_return('1.8.7') end it_behaves_like 'is not nill and empty' - let('subject_sorted') { eval(subject.to_s).to_a.sort } - let("expected_output") {[["config", "standalone-full.xml"], - ["console_log", "/var/log/wildfly/console.log"], - ["controller", "127.0.0.1:9990"], - ["home", "/usr/lib/wildfly-12.2.0.Final"], - ["mode", "standalone"], - ["product", "wildfly"], - ["profile", "full"], - ["runasdomain", false], - ["user", "wildfly"], - ["version", "12.2.0.Final"]] - } + let(:subject_sorted) { eval(subject.to_s).to_a.sort } + let(:expected_output) do + [ + ['config', 'standalone-full.xml'], + ['console_log', '/var/log/wildfly/console.log'], + ['controller', '127.0.0.1:9990'], + ['home', '/usr/lib/wildfly-12.2.0.Final'], + %w[mode standalone], + %w[product wildfly], + %w[profile full], + ['runasdomain', false], + %w[user wildfly], + ['version', '12.2.0.Final'] + ] + end - it { expect(subject_sorted).to eq(expected_output)} + it { expect(subject_sorted).to eq(expected_output) } end end end diff --git a/spec/unit/facter/jboss_running_spec.rb b/spec/unit/facter/jboss_running_spec.rb index 8365948..07efd48 100644 --- a/spec/unit/facter/jboss_running_spec.rb +++ b/spec/unit/facter/jboss_running_spec.rb @@ -1,7 +1,7 @@ -require 'spec_helper' +require 'spec_helper_puppet' describe 'jboss_running', :type => :fact do subject { Facter.value(:jboss_running) } it { expect { subject }.not_to raise_error } it { expect(subject).to match('^(?:true|false)$') } -end \ No newline at end of file +end diff --git a/spec/unit/facter/jboss_virtual_spec.rb b/spec/unit/facter/jboss_virtual_spec.rb index 9bdabbf..529b684 100644 --- a/spec/unit/facter/jboss_virtual_spec.rb +++ b/spec/unit/facter/jboss_virtual_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'spec_helper_puppet' describe 'jboss_virtual', :type => :fact do let(:lines) do @@ -27,7 +27,7 @@ fct.instance_variable_set(:@value, nil) end subject { Facter.value(:jboss_virtual) } - context 'on Docker container' do + describe 'on Docker container' do before(:each) do allow(Pathname).to receive(:new).and_call_original allow(Pathname).to receive(:new).with('/proc/1/cgroup').and_return(docker_pathname) @@ -35,7 +35,7 @@ it { expect { subject }.not_to raise_error } it { expect(subject).to eq('docker') } end - context 'on non-Docker machine' do + describe 'on non-Docker machine' do before(:each) do allow(Pathname).to receive(:new).and_call_original allow(Pathname).to receive(:new).with('/proc/1/cgroup').and_return(nondocker_pathname) diff --git a/spec/unit/internal/execution_state_wrapper_spec.rb b/spec/unit/internal/execution_state_wrapper_spec.rb index a5cdcb4..34b9c8a 100644 --- a/spec/unit/internal/execution_state_wrapper_spec.rb +++ b/spec/unit/internal/execution_state_wrapper_spec.rb @@ -1,19 +1,20 @@ require 'spec_helper' describe Puppet_X::Coi::Jboss::Internal::ExecutionStateWrapper do - context 'execute method' do + describe 'execute method' do let(:mocked_shell_executor) { Testing::Mock::MockedShellExecutor.new } let(:instance) { described_class.new(mocked_shell_executor) } subject { instance.execute(cmd, jbosscmd, environment) } - context 'destroy method' do + describe 'destroy method' do before :each do mocked_shell_executor.register_command( '/profille=full-ha/subsystem=securitydomain:remove()', 'asdads', true, - true) + true + ) end let(:cmd) { '/profille=full-ha/subsystem=securitydomain:remove()' } let(:jbosscmd) { 'asd' } @@ -21,13 +22,14 @@ it { expect(subject.success).to eq(true) } end - context 'read method' do + describe 'read method' do before :each do mocked_shell_executor.register_command( '/profille=full-ha/subsystem=securitydomain:read-resource(recursive=true)', 'result => succes, asdadass', true, - true) + true + ) end let(:cmd) { '/profille=full-ha/subsystem=securitydomain:read-resource(recursive=true)' } let(:jbosscmd) { 'asd' } diff --git a/spec/unit/internal/logic_creator_spec.rb b/spec/unit/internal/logic_creator_spec.rb index cc841c7..07c7de3 100644 --- a/spec/unit/internal/logic_creator_spec.rb +++ b/spec/unit/internal/logic_creator_spec.rb @@ -1,19 +1,18 @@ -require "spec_helper" +require 'spec_helper' describe Puppet_X::Coi::Jboss::Internal::LogicCreator do - let(:resource) do { :name => 'testing', :code => 'Database', :codeflag => true, - :moduleoptions => { + :moduleoptions => { 'principalsQuery' => "select 'password' from users u where u.login = ?", 'hashUserPassword' => false } } end - let(:system_executor) {Puppet_X::Coi::Jboss::Internal::Executor::ShellExecutor.new } + let(:system_executor) { Puppet_X::Coi::Jboss::Internal::Executor::ShellExecutor.new } let(:system_runner) { Puppet_X::Coi::Jboss::Internal::ExecutionStateWrapper.new(system_executor) } let(:runner) { Puppet_X::Coi::Jboss::Internal::CliExecutor.new(system_runner) } let(:compilator) { Puppet_X::Coi::Jboss::Internal::CommandCompilator.new } @@ -25,7 +24,7 @@ describe 'pre wildfly provider' do let(:provider) { Puppet_X::Coi::Jboss::Provider::SecurityDomain::PreWildFlyProvider.new(resource, compilator) } - context '#calculate_state with everything set to true' do + describe '#calculate_state with everything set to true' do before(:each) do state = Puppet_X::Coi::Jboss::Internal::State::SecurityDomainState.new(true, true, true) expect(auditor).to receive(:fetch_securtydomain_state).and_return(state) @@ -33,36 +32,72 @@ it { expect(subject).to eq([]) } end - context '#calculate_state with everything false' do + describe '#calculate_state with everything false' do before(:each) do state = Puppet_X::Coi::Jboss::Internal::State::SecurityDomainState.new expect(auditor).to receive(:fetch_securtydomain_state).and_return(state) end - it { expect(subject).to eq([["Security Domain Cache Type", "/subsystem=security/security-domain=testing:add(cache-type=default)"], ["Security Domain Login Modules", "/subsystem=security/security-domain=testing/authentication=classic:add(login-modules=[{code=>\"Database\",flag=>true,module-options=>[\"hashUserPassword\"=>false,\"principalsQuery\"=>\"select 'password' from users u where u.login = ?\"]}])"]]) } + it do + expect(subject).to eq( + [ + [ + 'Security Domain Cache Type', + '/subsystem=security/security-domain=testing:add(cache-type=default)' + ], + [ + 'Security Domain Login Modules', + '/subsystem=security/security-domain=testing/authentication=classic:add(login-modules=' \ + '[{code=>"Database",flag=>true,module-options=>["hashUserPassword"=>false,' \ + '"principalsQuery"=>"select \'password\' from users u where u.login = ?"]}])' + ] + ] + ) + end end - context '#calculate_state with cache type and authentication set' do + describe '#calculate_state with cache type and authentication set' do before(:each) do state = Puppet_X::Coi::Jboss::Internal::State::SecurityDomainState.new(true, true) expect(auditor).to receive(:fetch_securtydomain_state).and_return(state) end - it { expect(subject).to eq([["Security Domain Login Modules", "/subsystem=security/security-domain=testing/authentication=classic:add(login-modules=[{code=>\"Database\",flag=>true,module-options=>[\"hashUserPassword\"=>false,\"principalsQuery\"=>\"select 'password' from users u where u.login = ?\"]}])"]])} + it do + expect(subject).to eq( + [ + [ + 'Security Domain Login Modules', + '/subsystem=security/security-domain=testing/authentication=classic:add(login-modules=' \ + '[{code=>"Database",flag=>true,module-options=>["hashUserPassword"=>false,' \ + '"principalsQuery"=>"select \'password\' from users u where u.login = ?"]}])' + ] + ] + ) + end end - context '#calculate_state with cache type' do + describe '#calculate_state with cache type' do before(:each) do state = Puppet_X::Coi::Jboss::Internal::State::SecurityDomainState.new(true) expect(auditor).to receive(:fetch_securtydomain_state).and_return(state) end - it { expect(subject).to eq([["Security Domain Login Modules", "/subsystem=security/security-domain=testing/authentication=classic:add(login-modules=[{code=>\"Database\",flag=>true,module-options=>[\"hashUserPassword\"=>false,\"principalsQuery\"=>\"select 'password' from users u where u.login = ?\"]}])"]]) } + it do + expect(subject).to eq( + [ + [ + 'Security Domain Login Modules', + '/subsystem=security/security-domain=testing/authentication=classic:add(login-modules=[{code=>' \ + '"Database",flag=>true,module-options=>["hashUserPassword"=>false,"principalsQuery"=>' \ + '"select \'password\' from users u where u.login = ?"]}])' + ] + ] + ) + end end - end describe 'post wildfly provider' do let(:provider) { Puppet_X::Coi::Jboss::Provider::SecurityDomain::PostWildFlyProvider.new(resource, compilator) } - context '#calculate state with everything set' do + describe '#calculate state with everything set' do before(:each) do state = Puppet_X::Coi::Jboss::Internal::State::SecurityDomainState.new(true, true, true) expect(auditor).to receive(:fetch_securtydomain_state).and_return(state) @@ -70,29 +105,73 @@ it { expect(subject).to eq([]) } end - context '#calculate state with everything not set' do + describe '#calculate state with everything not set' do before(:each) do state = Puppet_X::Coi::Jboss::Internal::State::SecurityDomainState.new expect(auditor).to receive(:fetch_securtydomain_state).and_return(state) end - it { expect(subject).to eq([["Security Domain Cache Type", "/subsystem=security/security-domain=testing:add(cache-type=default)"], ["Security Domain Authentication", "/subsystem=security/security-domain=testing/authentication=classic:add()"], ["Security Domain Login Modules", "/subsystem=security/security-domain=testing/authentication=classic/login-module=testing:add(code=\"Database\",flag=true,module-options=[(\"hashUserPassword\"=>false),(\"principalsQuery\"=>\"select 'password' from users u where u.login = ?\")])"]]) } - + it do + expect(subject).to eq( + [ + [ + 'Security Domain Cache Type', + '/subsystem=security/security-domain=testing:add(cache-type=default)' + ], + [ + 'Security Domain Authentication', + '/subsystem=security/security-domain=testing/authentication=classic:add()' + ], + [ + 'Security Domain Login Modules', + '/subsystem=security/security-domain=testing/authentication=classic/login-module=testing' \ + ':add(code="Database",flag=true,module-options=[("hashUserPassword"=>false),' \ + '("principalsQuery"=>"select \'password\' from users u where u.login = ?")])' + ] + ] + ) + end end - context '#calculate_state with cache type and authentication set' do + describe '#calculate_state with cache type and authentication set' do before(:each) do state = Puppet_X::Coi::Jboss::Internal::State::SecurityDomainState.new(true, true) expect(auditor).to receive(:fetch_securtydomain_state).and_return(state) end - it { expect(subject).to eq([["Security Domain Login Modules", "/subsystem=security/security-domain=testing/authentication=classic/login-module=testing:add(code=\"Database\",flag=true,module-options=[(\"hashUserPassword\"=>false),(\"principalsQuery\"=>\"select 'password' from users u where u.login = ?\")])"]]) } + it do + expect(subject).to eq( + [ + [ + 'Security Domain Login Modules', + '/subsystem=security/security-domain=testing/authentication=classic/login-module=testing:' \ + 'add(code="Database",flag=true,module-options=[("hashUserPassword"=>false),' \ + '("principalsQuery"=>"select \'password\' from users u where u.login = ?")])' + ] + ] + ) + end end - context '#calculate_state with cache type' do + describe '#calculate_state with cache type' do before(:each) do state = Puppet_X::Coi::Jboss::Internal::State::SecurityDomainState.new(true) expect(auditor).to receive(:fetch_securtydomain_state).and_return(state) end - it { expect(subject).to eq([["Security Domain Authentication", "/subsystem=security/security-domain=testing/authentication=classic:add()"], ["Security Domain Login Modules", "/subsystem=security/security-domain=testing/authentication=classic/login-module=testing:add(code=\"Database\",flag=true,module-options=[(\"hashUserPassword\"=>false),(\"principalsQuery\"=>\"select 'password' from users u where u.login = ?\")])"]]) } + it do + expect(subject).to eq( + [ + [ + 'Security Domain Authentication', + '/subsystem=security/security-domain=testing/authentication=classic:add()' + ], + [ + 'Security Domain Login Modules', + '/subsystem=security/security-domain=testing/authentication=classic/login-module=testing' \ + ':add(code="Database",flag=true,module-options=[("hashUserPassword"=>false),' \ + '("principalsQuery"=>"select \'password\' from users u where u.login = ?")])' + ] + ] + ) + end end end end diff --git a/spec/unit/internal/sanitize_output_spec.rb b/spec/unit/internal/sanitize_output_spec.rb index 5bff08c..7b72daf 100644 --- a/spec/unit/internal/sanitize_output_spec.rb +++ b/spec/unit/internal/sanitize_output_spec.rb @@ -1,45 +1,29 @@ require 'spec_helper' describe Puppet_X::Coi::Jboss::Internal::Sanitizer do - let(:instance) { described_class.new } - let(:file_location) { File.dirname(__FILE__) } - let(:content) { File.read("#{file_location}/../../testing/files/evaluated.txt") } + let(:content) { File.read('spec/testing/files/evaluated.txt') } - context 'Should evaluate given input' do + describe 'should evaluate given input' do let(:test_content) { content.dup } subject { instance.sanitize(test_content) } - it { expect(subject).to eq("{\n \"outcome\" => \"success\",\n \"result\" => {\n \"deep-copy-subject-mode\" => false,\n \"vault\" => undefined,\n \"security-domain\" => {\n \"jboss-web-policy\" => {\n \"acl\" => undefined,\n \"audit\" => undefined,\n \"authentication\" => undefined,\n \"cache-type\" => \"default\",\n \"identity-trust\" => undefined,\n \"jsse\" => undefined,\n \"mapping\" => undefined,\n \"authorization\" => {\"classic\" => {\"policy-modules\" => [{\n \"code\" => \"Delegating\",\n \"flag\" => \"required\",\n \"module-options\" => undefined\n }]}}\n },\n \"other\" => {\n \"acl\" => undefined,\n \"audit\" => undefined,\n \"authorization\" => undefined,\n \"cache-type\" => \"default\",\n \"identity-trust\" => undefined,\n \"jsse\" => undefined,\n \"mapping\" => undefined,\n \"authentication\" => {\"classic\" => {\"login-modules\" => [\n {\n \"code\" => \"Remoting\",\n \"flag\" => \"optional\",\n \"module-options\" => [{'password-stacking' => 'useFirstPass'}]\n },\n {\n \"code\" => \"RealmUsersRoles\",\n \"flag\" => \"required\",\n \"module-options\" => [\n {'usersProperties' => '${jboss.server.config.dir}/application-users.properties'},\n {'rolesProperties' => '${jboss.server.config.dir}/application-roles.properties'},\n {'realm' => 'ApplicationRealm'},\n {'password-stacking' => 'useFirstPass'}\n ]\n }\n ]}}\n },\n \"jboss-ejb-policy\" => {\n \"acl\" => undefined,\n \"audit\" => undefined,\n \"authentication\" => undefined,\n \"cache-type\" => \"default\",\n \"identity-trust\" => undefined,\n \"jsse\" => undefined,\n \"mapping\" => undefined,\n \"authorization\" => {\"classic\" => {\"policy-modules\" => [{\n \"code\" => \"Delegating\",\n \"flag\" => \"required\",\n \"module-options\" => undefined\n }]}}\n }\n }\n }\n }\n") } + it do + expect(subject).to eq File.read('spec/testing/files/sanitized_output.txt') + end end - context 'should make no changes' do - let(:data) { '"other" => { - "acl" => undefined, - "audit" => undefined, - "authorization" => undefined, - "cache-type" => "default", - "identity-trust" => undefined, - "jsse" => undefined, - "mapping" => undefined, - "authentication" => {"classic" => {"login-modules" => [ - { - "code" => "Remoting", - "flag" => "optional", - "module-options" => [{"password-stacking" => "useFirstPass"}] - }, - { - "code" => "RealmUsersRoles", - "flag" => "required", - "module-options" => [ - {"usersProperties" => "${jboss.server.config.dir}/application-users.properties"}, - {"rolesProperties" => "${jboss.server.config.dir}/application-roles.properties"}, - {"realm" => "ApplicationRealm"}, - {"password-stacking" => "useFirstPass"} - ] - } - ]}} - },'} + describe 'should make no changes' do + let(:data) do + File.read "spec/testing/files/#{filename}" + end subject { instance.sanitize(data) } - it { expect(subject).to eq(data) } + describe 'on already_sanitized.txt file' do + let(:filename) { 'already_sanitized.txt' } + it { expect(subject).to eq data } + end + describe 'on sanitized_output.txt file' do + let(:filename) { 'sanitized_output.txt' } + it { expect(subject).to eq data } + end end end diff --git a/spec/unit/lib/coi_require_relative_spec.rb b/spec/unit/lib/coi_require_relative_spec.rb index b0f87da..6d3dd4b 100644 --- a/spec/unit/lib/coi_require_relative_spec.rb +++ b/spec/unit/lib/coi_require_relative_spec.rb @@ -3,7 +3,7 @@ describe Puppet_X::Coi do describe '#require_relative' do let(:target) { 'mocked/file' } - subject { Puppet_X::Coi::require_relative(target) } + subject { Puppet_X::Coi.require_relative(target) } let(:test_stmt) do subject NonExistentInAnyContextClassUsedOnlyForTesting.new.test diff --git a/spec/unit/lib/provider/datasource/post_wildfly_provider_spec.rb b/spec/unit/lib/provider/datasource/post_wildfly_provider_spec.rb index ec865b8..dd64a99 100644 --- a/spec/unit/lib/provider/datasource/post_wildfly_provider_spec.rb +++ b/spec/unit/lib/provider/datasource/post_wildfly_provider_spec.rb @@ -1,10 +1,9 @@ -require 'spec_helper' +require 'spec_helper_puppet' describe Puppet_X::Coi::Jboss::Provider::Datasource::PostWildFlyProvider do - let(:xa) { false } let(:jta) { true } - let(:provider) { double("Provider") } + let(:provider) { double('Provider') } before do allow(provider).to receive(:xa?).and_return(xa) allow(provider).to receive(:getattrib).and_return(jta) diff --git a/spec/unit/lib/provider/datasource/pre_wildfly_provider_spec.rb b/spec/unit/lib/provider/datasource/pre_wildfly_provider_spec.rb index 3d3a014..62a030b 100644 --- a/spec/unit/lib/provider/datasource/pre_wildfly_provider_spec.rb +++ b/spec/unit/lib/provider/datasource/pre_wildfly_provider_spec.rb @@ -1,7 +1,6 @@ -require 'spec_helper' +require 'spec_helper_puppet' describe Puppet_X::Coi::Jboss::Provider::Datasource::PreWildFlyProvider do - let(:target) { described_class.new(nil) } describe 'xa_datasource_properties_wrapper' do diff --git a/spec/unit/lib/provider/securitydomain/abstract_provider_spec.rb b/spec/unit/lib/provider/securitydomain/abstract_provider_spec.rb index 921223d..018910b 100644 --- a/spec/unit/lib/provider/securitydomain/abstract_provider_spec.rb +++ b/spec/unit/lib/provider/securitydomain/abstract_provider_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require 'spec_helper_puppet' describe Puppet_X::Coi::Jboss::Provider::SecurityDomain::AbstractProvider do let(:instance) { described_class.new } diff --git a/spec/unit/lib/provider/securitydomain/post_wildfly_provider_spec.rb b/spec/unit/lib/provider/securitydomain/post_wildfly_provider_spec.rb index 65dda9a..1deafb2 100644 --- a/spec/unit/lib/provider/securitydomain/post_wildfly_provider_spec.rb +++ b/spec/unit/lib/provider/securitydomain/post_wildfly_provider_spec.rb @@ -1,4 +1,4 @@ -require "spec_helper" +require 'spec_helper_puppet' describe Puppet_X::Coi::Jboss::Provider::SecurityDomain::PostWildFlyProvider do let(:resource) do @@ -6,7 +6,7 @@ :name => 'testing', :code => 'Database', :codeflag => true, - :moduleoptions => { + :moduleoptions => { 'principalsQuery' => "select 'password' from users u where u.login = ?", 'hashUserPassword' => false } @@ -18,17 +18,27 @@ let(:instance) { described_class.new(provider, compilator) } describe '#create_parametrized_cmd with post wildfly' do - subject { instance.make_command_templates } before :each do - result = ["subsystem=security", "security-domain=testing", "authentication=classic", "login-module=UsersRoles:add(code=\"Database\",flag=true,module-options=[(\"hashUserPassword\"=>false),(\"principalsQuery\"=>\"select 'password' from users u where u.login = ?\")])"] + result = [ + 'subsystem=security', + 'security-domain=testing', + 'authentication=classic', + 'login-module=UsersRoles:add(code="Database",flag=true,module-options=[("hashUserPassword"=>false),' \ + '("principalsQuery"=>"select \'password\' from users u where u.login = ?")])' + ] expect(instance).to receive(:make_command_templates).and_return(result) end let(:cli_command) do - ["subsystem=security", "security-domain=testing", "authentication=classic", "login-module=UsersRoles:add(code=\"Database\",flag=true,module-options=[(\"hashUserPassword\"=>false),(\"principalsQuery\"=>\"select 'password' from users u where u.login = ?\")])"] - + [ + 'subsystem=security', + 'security-domain=testing', + 'authentication=classic', + 'login-module=UsersRoles:add(code="Database",flag=true,module-options=[("hashUserPassword"=>false),' \ + '("principalsQuery"=>"select \'password\' from users u where u.login = ?")])' + ] end it { is_expected.to eq cli_command } end diff --git a/spec/unit/lib/provider/securitydomain/pre_wildfly_provider_spec.rb b/spec/unit/lib/provider/securitydomain/pre_wildfly_provider_spec.rb index 6bbfeb2..e265992 100644 --- a/spec/unit/lib/provider/securitydomain/pre_wildfly_provider_spec.rb +++ b/spec/unit/lib/provider/securitydomain/pre_wildfly_provider_spec.rb @@ -1,4 +1,4 @@ -require "spec_helper" +require 'spec_helper_puppet' describe Puppet_X::Coi::Jboss::Provider::SecurityDomain::PreWildFlyProvider do let(:resource) do @@ -6,9 +6,9 @@ :name => 'testing-is-awesome', :code => 'DB', :codeflag => false, - :moduleoptions => { + :moduleoptions => { 'hashUserPassword' => true, - 'principalsQuery' => 'select passwd from users where login = ?', + 'principalsQuery' => 'select passwd from users where login = ?' } } end @@ -21,11 +21,21 @@ subject { instance.make_command_templates } before :each do - result = ["subsystem=security", "security-domain=testing-is-awesome", "authentication=classic:add(login-modules=[{code=>\"DB\",flag=>false,module-options=>[\"hashUserPassword\"=>true,\"principalsQuery\"=>\"select passwd from users where login = ?\"]}])"] + result = [ + 'subsystem=security', + 'security-domain=testing-is-awesome', + 'authentication=classic:add(login-modules=[{code=>"DB",flag=>false,module-options=>' \ + '["hashUserPassword"=>true,"principalsQuery"=>"select passwd from users where login = ?"]}])' + ] expect(instance).to receive(:make_command_templates).and_return(result) end let(:cli_command) do - ["subsystem=security", "security-domain=testing-is-awesome", "authentication=classic:add(login-modules=[{code=>\"DB\",flag=>false,module-options=>[\"hashUserPassword\"=>true,\"principalsQuery\"=>\"select passwd from users where login = ?\"]}])"] + [ + 'subsystem=security', + 'security-domain=testing-is-awesome', + 'authentication=classic:add(login-modules=[{code=>"DB",flag=>false,module-options=>' \ + '["hashUserPassword"=>true,"principalsQuery"=>"select passwd from users where login = ?"]}])' + ] end it { is_expected.to eq cli_command } end diff --git a/spec/unit/provider/jboss_confignode/confignode_spec.rb b/spec/unit/provider/jboss_confignode/confignode_spec.rb index 795eecc..cf83c17 100644 --- a/spec/unit/provider/jboss_confignode/confignode_spec.rb +++ b/spec/unit/provider/jboss_confignode/confignode_spec.rb @@ -1,12 +1,11 @@ -require "spec_helper" - -context "mocking default values" do +require 'spec_helper_puppet' +describe 'mocking default values' do let(:mock_values) do { :product => 'jboss-eap', :version => '6.4.0.GA', - :controller => '127.0.0.1:9999', + :controller => '127.0.0.1:9999' } end @@ -19,7 +18,6 @@ end describe 'Puppet::Type::Jboss_confignode::ProviderJbosscli' do - let(:described_class) do Puppet::Type.type(:jboss_confignode).provider(:jbosscli) end @@ -45,7 +43,7 @@ Puppet::Type.type(:jboss_confignode).new(raw) end - + let(:provider) do resource.provider end @@ -56,15 +54,15 @@ describe '#exists? with clean => true and result => false' do before :each do - provider.instance_variable_set(:@clean, false) + provider.instance_variable_set(:@clean, false) - cmd = + cmd = '/profile=full/subsystem=messaging/hornetq-server=default:read-resource(include-runtime=true, include-defaults=false)' - expected_output = { - :result => false, - } - expect(provider).to receive(:executeAndGet).with(cmd).and_return(expected_output) + expected_output = { + :result => false + } + expect(provider).to receive(:executeAndGet).with(cmd).and_return(expected_output) end subject { provider.exists? } @@ -73,20 +71,20 @@ describe '#exists? with clean => true and result => true' do before :each do - provider.instance_variable_set(:@clean, false) + provider.instance_variable_set(:@clean, false) - cmd = + cmd = '/profile=full/subsystem=messaging/hornetq-server=default:read-resource(include-runtime=true, include-defaults=false)' - expected_output = { - :result => true, - :data => { - :includeruntime => true, - :includedefaults => false, - } + expected_output = { + :result => true, + :data => { + :includeruntime => true, + :includedefaults => false } + } - expect(provider).to receive(:executeAndGet).with(cmd).and_return(expected_output) + expect(provider).to receive(:executeAndGet).with(cmd).and_return(expected_output) end subject { provider.exists? } @@ -95,7 +93,7 @@ describe '#exists? with clean => false [wrong context]' do before :each do - provider.instance_variable_set(:@clean, true) + provider.instance_variable_set(:@clean, true) end subject { provider.exists? } @@ -113,18 +111,17 @@ describe '#destroy with status == :running and later on :ensure' do before :each do - - bringDownName = 'Configuration node STOP' + bring_down_name = 'Configuration node STOP' cmd = '/profile=full/subsystem=messaging/hornetq-server=default:stop(blocking=true)' - bringDownNameDestroy = 'Configuration node' - cmdDestroy = '/profile=full/subsystem=messaging/hornetq-server=default:remove()' + bring_down_name_destroy = 'Configuration node' + cmd_destroy = '/profile=full/subsystem=messaging/hornetq-server=default:remove()' expect(provider).to receive(:exists?).and_return(true) expect(provider).to receive(:status).and_return(:running) expect(provider).to receive(:status).and_return(:ensure) - expect(provider).to receive(:bringDown).with(bringDownName, cmd).and_return(true) - expect(provider).to receive(:bringDown).with(bringDownNameDestroy, cmdDestroy).and_return(true) + expect(provider).to receive(:bringDown).with(bring_down_name, cmd).and_return(true) + expect(provider).to receive(:bringDown).with(bring_down_name_destroy, cmd_destroy).and_return(true) end subject { provider.destroy } @@ -133,20 +130,18 @@ describe '#destroy with exists? => true and status :running => nil' do before :each do - - bringDownName = 'Configuration node' + bring_down_name = 'Configuration node' cmd = '/profile=full/subsystem=messaging/hornetq-server=default:remove()' - expect(provider).to receive(:bringDown).with(bringDownName, cmd).and_return(true) + expect(provider).to receive(:bringDown).with(bring_down_name, cmd).and_return(true) expect(provider).to receive(:exists?).and_return(true, true) end - subject { provider.destroy } it { expect(subject).to eq(true) } end - describe "#create with exists? => true" do + describe '#create with exists? => true' do before :each do expect(provider).to receive(:exists?).and_return(true) end @@ -155,15 +150,13 @@ it { expect(subject).to eq(nil) } end - - describe "#create with exists? => false" do + describe '#create with exists? => false' do before :each do - - bringUpName = 'Configuration node' + bring_up_name = 'Configuration node' cmd = '/profile=full/subsystem=messaging/hornetq-server=default:add(security-enabled=false)' expect(provider).to receive(:exists?).and_return(false) - expect(provider).to receive(:bringUp).with(bringUpName, cmd).and_return(true) + expect(provider).to receive(:bringUp).with(bring_up_name, cmd).and_return(true) end subject { provider.create } @@ -173,7 +166,7 @@ describe '#ensure no specific value' do before :each do data = { - :status => 'true', + :status => 'true' } provider.instance_variable_set(:@data, data) @@ -188,7 +181,7 @@ describe '#ensure with status => disabled' do before :each do data = { - 'status' => 'disabled', + 'status' => 'disabled' } provider.instance_variable_set(:@data, data) @@ -203,7 +196,7 @@ describe '#ensure with status => RUNNING' do before :each do data = { - 'status' => 'RUNNING', + 'status' => 'RUNNING' } provider.instance_variable_set(:@data, data) @@ -218,7 +211,7 @@ describe '#ensure with status => else' do before :each do data = { - 'status' => 'else', + 'status' => 'else' } provider.instance_variable_set(:@data, data) @@ -233,7 +226,7 @@ describe '#ensure with enabled => true' do before :each do data = { - 'enabled' => true, + 'enabled' => true } provider.instance_variable_set(:@data, data) @@ -248,7 +241,7 @@ describe '#ensure with enabled => else' do before :each do data = { - 'enabled' => false, + 'enabled' => false } provider.instance_variable_set(:@data, data) @@ -278,7 +271,6 @@ describe '#ensure :present' do before :each do - expect(provider).to receive(:create).and_return(true) end @@ -288,7 +280,6 @@ describe '#ensure :absent' do before :each do - expect(provider).to receive(:destroy).and_return(true) end @@ -298,7 +289,6 @@ describe '#ensure :running' do before :each do - expect(provider).to receive(:doStart).and_return(true) end @@ -308,7 +298,6 @@ describe '#ensure :stopped' do before :each do - expect(provider).to receive(:doStop).and_return(true) end @@ -318,12 +307,11 @@ describe '#ensure :enabled with status :ensure' do before :each do - - bringUpName = 'Configuration node ENABLE' + bring_up_name = 'Configuration node ENABLE' cmd = '/profile=full/subsystem=messaging/hornetq-server=default:enable()' expect(provider).to receive(:status).and_return(:ensure) - expect(provider).to receive(:bringUp).with(bringUpName, cmd).and_return(true) + expect(provider).to receive(:bringUp).with(bring_up_name, cmd).and_return(true) end subject { provider.ensure = :enabled } @@ -332,12 +320,11 @@ describe '#ensure :enabled with status :absent' do before :each do - - bringUpName = 'Configuration node ENABLE' + bring_up_name = 'Configuration node ENABLE' cmd = '/profile=full/subsystem=messaging/hornetq-server=default:enable()' expect(provider).to receive(:status).and_return(:ensure) - expect(provider).to receive(:bringUp).with(bringUpName, cmd).and_return(true) + expect(provider).to receive(:bringUp).with(bring_up_name, cmd).and_return(true) end subject { provider.ensure = :enabled } @@ -345,22 +332,21 @@ end describe '#ensure= value with value => :running' do - before :each do - bringUpName = 'Configuration node START' - cmd = '/profile=full/subsystem=messaging/hornetq-server=default:start(blocking=true)' + before :each do + bring_up_name = 'Configuration node START' + cmd = '/profile=full/subsystem=messaging/hornetq-server=default:start(blocking=true)' - expect(provider).to receive(:status).and_return(:absent) - expect(provider).to receive(:create).and_return(true) - expect(provider).to receive(:bringUp).with(bringUpName, cmd).and_return(true) - end + expect(provider).to receive(:status).and_return(:absent) + expect(provider).to receive(:create).and_return(true) + expect(provider).to receive(:bringUp).with(bring_up_name, cmd).and_return(true) + end - subject {provider.ensure= :running} - it { expect(subject).to eq(:running) } + subject { provider.ensure = :running } + it { expect(subject).to eq(:running) } end describe '#ensure :disabled' do before :each do - expect(provider).to receive(:doDisable).and_return(true) end @@ -369,45 +355,45 @@ end describe '#ensure= value with value => :stopped' do - before :each do - bringUpName = 'Configuration node STOP' - cmd = '/profile=full/subsystem=messaging/hornetq-server=default:stop(blocking=true)' + before :each do + bring_up_name = 'Configuration node STOP' + cmd = '/profile=full/subsystem=messaging/hornetq-server=default:stop(blocking=true)' - expect(provider).to receive(:status).and_return(:absent) - expect(provider).to receive(:create).and_return(true) - expect(provider).to receive(:bringDown).with(bringUpName, cmd).and_return(true) - end + expect(provider).to receive(:status).and_return(:absent) + expect(provider).to receive(:create).and_return(true) + expect(provider).to receive(:bringDown).with(bring_up_name, cmd).and_return(true) + end - subject {provider.ensure= :stopped} - it { expect(subject).to eq(:stopped) } + subject { provider.ensure = :stopped } + it { expect(subject).to eq(:stopped) } end describe '#ensure= value with value => :enabled' do - before :each do - bringUpName = 'Configuration node ENABLE' - cmd = '/profile=full/subsystem=messaging/hornetq-server=default:enable()' + before :each do + bring_up_name = 'Configuration node ENABLE' + cmd = '/profile=full/subsystem=messaging/hornetq-server=default:enable()' - expect(provider).to receive(:status).and_return(:absent) - expect(provider).to receive(:create).and_return(true) - expect(provider).to receive(:bringUp).with(bringUpName, cmd).and_return(true) - end + expect(provider).to receive(:status).and_return(:absent) + expect(provider).to receive(:create).and_return(true) + expect(provider).to receive(:bringUp).with(bring_up_name, cmd).and_return(true) + end - subject {provider.ensure= :enabled} - it { expect(subject).to eq(:enabled) } + subject { provider.ensure = :enabled } + it { expect(subject).to eq(:enabled) } end describe '#ensure= value with value => :disabled' do - before :each do - bringUpName = 'Configuration node DISABLE' - cmd = '/profile=full/subsystem=messaging/hornetq-server=default:disable()' + before :each do + bring_up_name = 'Configuration node DISABLE' + cmd = '/profile=full/subsystem=messaging/hornetq-server=default:disable()' - expect(provider).to receive(:status).and_return(:absent) - expect(provider).to receive(:create).and_return(true) - expect(provider).to receive(:bringDown).with(bringUpName, cmd).and_return(true) - end + expect(provider).to receive(:status).and_return(:absent) + expect(provider).to receive(:create).and_return(true) + expect(provider).to receive(:bringDown).with(bring_up_name, cmd).and_return(true) + end - subject {provider.ensure= :disabled} - it { expect(subject).to eq(:disabled) } + subject { provider.ensure = :disabled } + it { expect(subject).to eq(:disabled) } end describe '#properties and @data => nil' do @@ -421,46 +407,46 @@ describe '#properties and @data => asd ' do before :each do - property_hash = { :properties => { - 'security-enabled' => false, - }} + property_hash = { + :properties => { 'security-enabled' => false } + } provider.instance_variable_set(:@data, 'asd') provider.instance_variable_set(:@property_hash, property_hash) end subject { provider.properties } - it { expect(subject).to eq({"security-enabled"=>false}) } + it { expect(subject).to eq('security-enabled' => false) } end describe '#properties and @data => asd and value is keyword' do before :each do - property_hash = { :properties => { - 'security-enabled' => :false, - }} + property_hash = { + :properties => { 'security-enabled' => :false } + } provider.instance_variable_set(:@data, 'asd') provider.instance_variable_set(:@property_hash, property_hash) end subject { provider.properties } - it { expect(subject).to eq({"security-enabled"=>"false"}) } + it { expect(subject).to eq('security-enabled' => 'false') } end describe '#properties' do before :each do - data = { :aaa => :bbb} + data = { :aaa => :bbb } provider.instance_variable_set(:@data, data) - bringUpName = 'Configuration node property' + bring_up_name = 'Configuration node property' cmd = '/profile=full/subsystem=messaging/hornetq-server=default:write-attribute(name=security-enabled, value=:false)' - expect(provider).to receive(:bringUp).with(bringUpName, cmd).and_return(true) + expect(provider).to receive(:bringUp).with(bring_up_name, cmd).and_return(true) end props = { - 'security-enabled' => :false, - } + 'security-enabled' => :false + } subject { provider.properties = props } - it { expect(subject).to eq({"security-enabled"=>:false}) } + it { expect(subject).to eq('security-enabled' => :false) } end -end + end end diff --git a/spec/unit/provider/jboss_datasource/jbosscli_spec.rb b/spec/unit/provider/jboss_datasource/jbosscli_spec.rb index 8ea4328..0916dc0 100644 --- a/spec/unit/provider/jboss_datasource/jbosscli_spec.rb +++ b/spec/unit/provider/jboss_datasource/jbosscli_spec.rb @@ -1,13 +1,12 @@ -require "spec_helper" -require "puppet_x/coi/jboss/configuration" - -context "While mocking facts :jboss_product => 'jboss-eap' and :jboss_version => '6.4.0.GA'" do +require 'spec_helper_puppet' +require 'puppet_x/coi/jboss/configuration' +describe "While mocking facts :jboss_product => 'jboss-eap' and :jboss_version => '6.4.0.GA'" do let(:mock_values) do { :product => 'jboss-eap', :version => '6.4.0.GA', - :controller => '127.0.0.1:9999', + :controller => '127.0.0.1:9999' } end @@ -20,7 +19,6 @@ end describe 'Puppet::Type::Jboss_datasource::ProviderJbosscli' do - let(:described_class) do Puppet::Type.type(:jboss_datasource).provider(:jbosscli) end @@ -29,7 +27,7 @@ :name => 'testing', :xa => false, :runasdomain => false, - :jdbcscheme => 'h2:mem', + :jdbcscheme => 'h2:mem' } end @@ -47,7 +45,7 @@ allow(provider.class).to receive(:suitable?).and_return(true) end - context 'Given `testing` Non-XA datasource using h2:mem' do + describe 'Given `testing` Non-XA datasource using h2:mem' do let(:command) do '/subsystem=datasources/data-source=testing:read-resource(recursive=true)' end @@ -56,7 +54,7 @@ let(:retry_count) { 0 } let(:ctrlcfg) do { - :controller => "127.0.0.1:9990", + :controller => '127.0.0.1:9990', :ctrluser => nil, :ctrlpasswd => nil } @@ -65,70 +63,70 @@ { :result => true, :data => { - "allocation-retry" => nil, - "allocation-retry-wait-millis" => nil, - "allow-multiple-users" => false, - "background-validation" => false, - "background-validation-millis" => nil, - "blocking-timeout-wait-millis" => nil, - "capacity-decrementer-class" => nil, - "capacity-decrementer-properties" => nil, - "capacity-incrementer-class" => nil, - "capacity-incrementer-properties" => nil, - "check-valid-connection-sql" => nil, - "connection-listener-class" => nil, - "connection-listener-property" => nil, - "connection-properties" => nil, - "connection-url" => "jdbc:h2:mem:///testing;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE", - "datasource-class" => nil, - "driver-class" => nil, - "driver-name" => "h2", - "enabled" => true, - "exception-sorter-class-name" => nil, - "exception-sorter-properties" => nil, - "flush-strategy" => nil, - "idle-timeout-minutes" => nil, - "initial-pool-size" => nil, - "jndi-name" => "java:jboss/datasources/testing", - "jta" => true, - "max-pool-size" => 50, - "min-pool-size" => 1, - "new-connection-sql" => nil, - "password" => "test-password", - "pool-prefill" => nil, - "pool-use-strict-min" => nil, - "prepared-statements-cache-size" => 0, - "query-timeout" => nil, - "reauth-plugin-class-name" => nil, - "reauth-plugin-properties" => nil, - "security-domain" => nil, - "set-tx-query-timeout" => false, - "share-prepared-statements" => false, - "spy" => false, - "stale-connection-checker-class-name" => nil, - "stale-connection-checker-properties" => nil, - "track-statements" => "NOWARN", - "transaction-isolation" => nil, - "url-delimiter" => nil, - "url-selector-strategy-class-name" => nil, - "use-ccm" => true, - "use-fast-fail" => false, - "use-java-context" => true, - "use-try-lock" => nil, - "user-name" => "test-username", - "valid-connection-checker-class-name" => nil, - "valid-connection-checker-properties" => nil, - "validate-on-match" => false, - "statistics" => nil + 'allocation-retry' => nil, + 'allocation-retry-wait-millis' => nil, + 'allow-multiple-users' => false, + 'background-validation' => false, + 'background-validation-millis' => nil, + 'blocking-timeout-wait-millis' => nil, + 'capacity-decrementer-class' => nil, + 'capacity-decrementer-properties' => nil, + 'capacity-incrementer-class' => nil, + 'capacity-incrementer-properties' => nil, + 'check-valid-connection-sql' => nil, + 'connection-listener-class' => nil, + 'connection-listener-property' => nil, + 'connection-properties' => nil, + 'connection-url' => 'jdbc:h2:mem:///testing;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE', + 'datasource-class' => nil, + 'driver-class' => nil, + 'driver-name' => 'h2', + 'enabled' => true, + 'exception-sorter-class-name' => nil, + 'exception-sorter-properties' => nil, + 'flush-strategy' => nil, + 'idle-timeout-minutes' => nil, + 'initial-pool-size' => nil, + 'jndi-name' => 'java:jboss/datasources/testing', + 'jta' => true, + 'max-pool-size' => 50, + 'min-pool-size' => 1, + 'new-connection-sql' => nil, + 'password' => 'test-password', + 'pool-prefill' => nil, + 'pool-use-strict-min' => nil, + 'prepared-statements-cache-size' => 0, + 'query-timeout' => nil, + 'reauth-plugin-class-name' => nil, + 'reauth-plugin-properties' => nil, + 'security-domain' => nil, + 'set-tx-query-timeout' => false, + 'share-prepared-statements' => false, + 'spy' => false, + 'stale-connection-checker-class-name' => nil, + 'stale-connection-checker-properties' => nil, + 'track-statements' => 'NOWARN', + 'transaction-isolation' => nil, + 'url-delimiter' => nil, + 'url-selector-strategy-class-name' => nil, + 'use-ccm' => true, + 'use-fast-fail' => false, + 'use-java-context' => true, + 'use-try-lock' => nil, + 'user-name' => 'test-username', + 'valid-connection-checker-class-name' => nil, + 'valid-connection-checker-properties' => nil, + 'validate-on-match' => false, + 'statistics' => nil } } end let(:expected_connection) do - "testing;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" + 'testing;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE' end before :each do expect(provider).to receive(:executeAndGet). - with("/subsystem=datasources/data-source=testing:read-resource(recursive=true)").and_return(result) + with('/subsystem=datasources/data-source=testing:read-resource(recursive=true)').and_return(result) end describe 'result of dbname()' do @@ -170,18 +168,18 @@ :jndiname => 'jboss:/datasources/testing' } end - let(:datasource_options) do {} end + let(:datasource_options) { {} } before :each do cli = '/subsystem=datasources/xa-data-source=testing:read-resource(recursive=true)' - expect(provider).to receive(:executeAndGet).with(cli).at_least(:once).and_return({ + expect(provider).to receive(:executeAndGet).with(cli).at_least(:once).and_return( :result => true, :data => { 'jta' => false } - }) + ) provider.exists? end - context 'while using JBoss EAP 6.4.0.GA' do + describe 'while using JBoss EAP 6.4.0.GA' do describe 'jta()' do subject { provider.jta } it { expect(subject).not_to be_nil } @@ -205,7 +203,7 @@ } end let(:datasource_options_setattrb_response) do - { :result => true, :data => {} } + { :result => true, :data => {} } end before :each do datasource_options.each do |k, v| @@ -216,45 +214,44 @@ shared_examples 'is working like a charm' do it { expect { subject }.not_to raise_error } end - context 'with new_options equal to { "xa-some-opt" => false }' do + describe 'with new_options equal to { "xa-some-opt" => false }' do let(:new_options) do - { "xa-some-opt" => false, 'sample-opt' => 'gigabyte' } + { 'xa-some-opt' => false, 'sample-opt' => 'gigabyte' } end before :each do new_options.each do |k, v| - if datasource_options[k] != v - expect(provider).to receive(:executeAndGet). - with("/subsystem=datasources/xa-data-source=testing:write-attribute(name=\"#{k}\", value=#{v.inspect})"). - and_return(datasource_options_setattrb_response) - end + next unless datasource_options[k] != v + expect(provider).to receive(:executeAndGet). + with("/subsystem=datasources/xa-data-source=testing:write-attribute(name=\"#{k}\", value=#{v.inspect})"). + and_return(datasource_options_setattrb_response) end end it_behaves_like 'is working like a charm' end - context 'for cases that undefines setted values' do + describe 'for cases that undefines setted values' do before :each do - datasource_options.each do |k, v| + datasource_options.each do |k, _v| expect(provider).to receive(:executeAndGet). with("/subsystem=datasources/xa-data-source=testing:undefine-attribute(name=\"#{k}\")"). and_return(datasource_options_setattrb_response) end end - context 'with new_options equal to :absent' do + describe 'with new_options equal to :absent' do let(:new_options) { :absent } it_behaves_like 'is working like a charm' end - context 'with new_options equal to :undef' do + describe 'with new_options equal to :undef' do let(:new_options) { :undef } it_behaves_like 'is working like a charm' end - context 'with new_options equal to nil' do + describe 'with new_options equal to nil' do let(:new_options) { nil } it_behaves_like 'is working like a charm' end end end end - context 'while using JBoss EAP 6.2.0.GA' do + describe 'while using JBoss EAP 6.2.0.GA' do let(:mock_values) do { :product => 'jboss-eap', @@ -270,10 +267,10 @@ describe 'jta_opt(cmd)' do before :each do cli2 = '/subsystem=datasources/xa-data-source=testing:write-attribute(name="jta", value="true")' - expect(provider).to receive(:executeAndGet).with(cli2).and_return({ + expect(provider).to receive(:executeAndGet).with(cli2).and_return( :result => true, :data => {} - }) + ) provider.jta = true end let(:cmd) { [] } @@ -284,16 +281,16 @@ describe 'create()' do before :each do - cmd = 'xa-data-source add --name=testing --jta=true --jndi-name="jboss:/datasources/testing" ' + - '--driver-name=nil --min-pool-size=nil --max-pool-size=nil' + - ' --user-name=nil --password=nil --xa-datasource-properties=' + - '[ServerName=nil,PortNumber=nil,DatabaseName="testing"]' + cmd = 'xa-data-source add --name=testing --jta=true --jndi-name="jboss:/datasources/testing" ' \ + '--driver-name=nil --min-pool-size=nil --max-pool-size=nil' \ + ' --user-name=nil --password=nil --xa-datasource-properties=' \ + '[ServerName=nil,PortNumber=nil,DatabaseName="testing"]' expect(provider).to receive(:executeWithFail).with('Datasource', cmd, 'to create') cli = '/subsystem=datasources/xa-data-source=testing:read-attribute(name=enabled)' - expect(provider).to receive(:executeAndGet).with(cli).and_return({ + expect(provider).to receive(:executeAndGet).with(cli).and_return( :result => true, :data => true - }) + ) end subject { provider.create } it { expect { subject }.not_to raise_error } @@ -317,6 +314,5 @@ subject { provider.prepare_resource } it { expect { subject }.not_to raise_error } end - end end diff --git a/spec/unit/provider/jboss_deploy/jboss_deploy_spec.rb b/spec/unit/provider/jboss_deploy/jboss_deploy_spec.rb index 03af589..0627f00 100644 --- a/spec/unit/provider/jboss_deploy/jboss_deploy_spec.rb +++ b/spec/unit/provider/jboss_deploy/jboss_deploy_spec.rb @@ -1,12 +1,11 @@ -require "spec_helper" - -context "mocking default values" do +require 'spec_helper_puppet' +describe 'mocking default values' do let(:mock_values) do { :product => 'jboss-eap', :version => '6.4.0.GA', - :controller => '127.0.0.1:9999', + :controller => '127.0.0.1:9999' } end @@ -19,14 +18,13 @@ end describe 'Puppet::Type::Jboss_deploy::ProviderJbosscli' do - let(:described_class) do Puppet::Type.type(:jboss_deploy).provider(:jbosscli) end let(:sample_repl) do { - :name => 'super-crm-1.1.0', - :source => '/usr/src/super-crm-1.1.0.war', + :name => 'super-crm-1.1.0', + :source => '/usr/src/super-crm-1.1.0.war' } end @@ -47,10 +45,10 @@ describe '#create with servergroups nill' do before :each do - bringDownName = 'Deployment' + bring_down_name = 'Deployment' cmd = 'deploy /usr/src/super-crm-1.1.0.war --name=super-crm-1.1.0 --all-server-groups --force' - expect(provider).to receive(:bringUp).with(bringDownName, cmd ).and_return('asd') + expect(provider).to receive(:bringUp).with(bring_down_name, cmd).and_return('asd') end subject { provider.create } it { expect(subject).to eq('asd') } @@ -58,15 +56,17 @@ describe '#create wit servergroups not nill' do before :each do - bringDownName = 'Deployment' + bring_down_name = 'Deployment' cmd = 'deploy /usr/src/super-crm-1.1.0.war --name=super-crm-1.1.0 --server-groups=crm-servers --force' - expect(provider).to receive(:bringUp).with(bringDownName, cmd).and_return('asd') + expect(provider).to receive(:bringUp).with(bring_down_name, cmd).and_return('asd') end - let(:extended_repl) { { - :servergroups => ['crm-servers'], - } } + let(:extended_repl) do + { + :servergroups => ['crm-servers'] + } + end subject { provider.create } it { expect(subject).to eq('asd') } @@ -74,28 +74,32 @@ describe '#create with redeploy_on_refresh' do before :each do - bringDownName = 'Deployment' + bring_down_name = 'Deployment' cmd = 'deploy /usr/src/super-crm-1.1.0.war --name=super-crm-1.1.0 --all-server-groups --force' - expect(provider).to receive(:bringUp).with(bringDownName, cmd).and_return('asd') + expect(provider).to receive(:bringUp).with(bring_down_name, cmd).and_return('asd') + end + let(:extended_repl) do + { + :redeploy_on_refresh => true + } end - let(:extended_repl) { { - :redeploy_on_refresh => true, - } } subject { provider.create } it { expect(subject).to eq('asd') } end describe '#destroy with runasdomain => true' do before :each do - bringDownName = 'Deployment' + bring_down_name = 'Deployment' cmd = 'undeploy super-crm-1.1.0 --all-relevant-server-groups' - expect(provider).to receive(:bringDown).with(bringDownName, cmd).and_return('asd') + expect(provider).to receive(:bringDown).with(bring_down_name, cmd).and_return('asd') end - let(:extended_repl) { { + let(:extended_repl) do + { :runasdomain => true - } } + } + end subject { provider.destroy } it { expect(subject).to eq('asd') } @@ -103,14 +107,16 @@ describe '#destroy with servergroups nill' do before :each do - bringDownName = 'Deployment' + bring_down_name = 'Deployment' cmd = 'undeploy super-crm-1.1.0 --all-relevant-server-groups' - expect(provider).to receive(:bringDown).with(bringDownName, cmd).and_return('asd') + expect(provider).to receive(:bringDown).with(bring_down_name, cmd).and_return('asd') end - let(:extended_repl) { { + let(:extended_repl) do + { :runasdomain => true - } } + } + end subject { provider.destroy } it { expect(subject).to eq('asd') } @@ -118,15 +124,17 @@ describe '#destroy with servergroups not nill' do before :each do - bringDownName = 'Deployment' + bring_down_name = 'Deployment' cmd = 'undeploy super-crm-1.1.0 --server-groups=crm-servers' - expect(provider).to receive(:bringDown).with(bringDownName, cmd).and_return('asd') + expect(provider).to receive(:bringDown).with(bring_down_name, cmd).and_return('asd') end - let(:extended_repl) { { - :runasdomain => true, - :servergroups => ['crm-servers'], - } } + let(:extended_repl) do + { + :runasdomain => true, + :servergroups => ['crm-servers'] + } + end subject { provider.destroy } it { expect(subject).to eq('asd') } @@ -138,8 +146,8 @@ end describe '#name_exists? and outcome => failed' do before :each do - cmd = "/deployment=super-crm-1.1.0:read-resource()" - expected_output = { :outcome => 'failed'} + cmd = '/deployment=super-crm-1.1.0:read-resource()' + expected_output = { :outcome => 'failed' } expect(provider).to receive(:executeWithoutRetry).with(cmd).and_return(expected_output) end @@ -150,11 +158,11 @@ describe '#exists? and :outcome => success and :name => asd' do before :each do - cmd = "/deployment=super-crm-1.1.0:read-resource()" + cmd = '/deployment=super-crm-1.1.0:read-resource()' expected_output = { :outcome => 'success', - :name => 'asd', - } + :name => 'asd' + } expect(provider).to receive(:executeWithoutRetry).with(cmd).and_return(expected_output) end @@ -165,10 +173,10 @@ describe '#name_exists? and :outcome => success and :name => nil' do before :each do - cmd = "/deployment=super-crm-1.1.0:read-resource()" + cmd = '/deployment=super-crm-1.1.0:read-resource()' expected_output = { - :outcome => 'success', - } + :outcome => 'success' + } expect(provider).to receive(:executeWithoutRetry).with(cmd).and_return(expected_output) end @@ -182,10 +190,12 @@ before :each do end - let(:extended_repl) { { - :runasdomain => false, - :servergroups => ['crm-servers'], - } } + let(:extended_repl) do + { + :runasdomain => false, + :servergroups => ['crm-servers'] + } + end subject { provider.servergroups } it { expect(subject).to eq(['crm-servers']) } @@ -193,20 +203,21 @@ describe '#servergroups with runasdomain => true and :result => false' do before :each do - expected_output = { :result => false, - :name => 'asd', - } + :name => 'asd' + } cmd = "deployment-info --name=#{resource[:name]}" expect(provider).to receive(:execute).with(cmd).and_return(expected_output) end - let(:extended_repl) { { - :runasdomain => true, - } } + let(:extended_repl) do + { + :runasdomain => true + } + end subject { provider.servergroups } it { expect(subject).to eq([]) } @@ -214,7 +225,6 @@ describe '#servergroups with runasdomain => true and :result => true and lines => added and :servergroups => not nil' do before :each do - content = <<-eos NAME RUNTIME-NAME super-crm super-crm @@ -228,18 +238,20 @@ expected_output = { :result => true, :name => 'asd', - :lines => lines, - } + :lines => lines + } cmd = "deployment-info --name=#{resource[:name]}" expect(provider).to receive(:execute).with(cmd).and_return(expected_output) end - let(:extended_repl) { { - :runasdomain => true, - :servergroups => 'crm-servers', - } } + let(:extended_repl) do + { + :runasdomain => true, + :servergroups => 'crm-servers' + } + end subject { provider.servergroups } it { expect(subject).to eq(['app-group']) } @@ -247,7 +259,6 @@ describe '#servergroups with runasdomain => true and :result => true and lines => added and :servergroups => nil' do before :each do - content = <<-eos NAME RUNTIME-NAME super-crm super-crm @@ -261,17 +272,19 @@ expected_output = { :result => true, :name => 'asd', - :lines => lines, - } + :lines => lines + } cmd = "deployment-info --name=#{resource[:name]}" expect(provider).to receive(:execute).with(cmd).and_return(expected_output) end - let(:extended_repl) { { - :runasdomain => true, - } } + let(:extended_repl) do + { + :runasdomain => true + } + end subject { provider.servergroups } it { expect(subject).to eq(nil) } @@ -286,48 +299,46 @@ end subject { provider.servergroups = ['super-crm', 'super-crm-1'] } - it { expect(subject).to eq(["super-crm", "super-crm-1"]) } + it { expect(subject).to eq(['super-crm', 'super-crm-1']) } end describe '#redeploy_on_refresh' do - - context 'with default value' do + describe 'with default value' do before :each do - - bringDownName = 'Deployment' + bring_down_name = 'Deployment' cmd = 'undeploy super-crm-1.1.0 --all-relevant-server-groups' - - bringUpName = 'Deployment' cmd2 = 'deploy /usr/src/super-crm-1.1.0.war --name=super-crm-1.1.0 --all-server-groups --force' - expect(provider).to receive(:bringDown).with(bringDownName, cmd).and_return('asd') - expect(provider).to receive(:bringUp).with(bringDownName, cmd2).and_return('asd') - + expect(provider).to receive(:bringDown).with(bring_down_name, cmd).and_return('asd') + expect(provider).to receive(:bringUp).with(bring_down_name, cmd2).and_return('asd') end - let(:extended_repl) { { - :redeploy_on_refresh => true, - } } + let(:extended_repl) do + { + :redeploy_on_refresh => true + } + end subject { provider.redeploy_on_refresh } it { expect(subject).to eq('asd') } end - context 'with value set to false' do + describe 'with value set to false' do before :each do - - bringUpName = 'Deployment' + bring_up_name = 'Deployment' cmd = 'deploy /usr/src/super-crm-1.1.0.war --name=super-crm-1.1.0 --all-server-groups' - expect(provider).to receive(:bringUp).with(bringUpName, cmd).and_return('asd') + expect(provider).to receive(:bringUp).with(bring_up_name, cmd).and_return('asd') + end + let(:extended_repl) do + { + :redeploy_on_refresh => false + } end - let(:extended_repl) { { - :redeploy_on_refresh => false, - } } subject { provider.redeploy_on_refresh } it { expect(subject).to eq('asd') } end end -end + end end diff --git a/spec/unit/provider/jboss_jdbcdriver/jbosscli_spec.rb b/spec/unit/provider/jboss_jdbcdriver/jbosscli_spec.rb index f4e57cf..99604ad 100644 --- a/spec/unit/provider/jboss_jdbcdriver/jbosscli_spec.rb +++ b/spec/unit/provider/jboss_jdbcdriver/jbosscli_spec.rb @@ -1,12 +1,11 @@ -require "spec_helper" - -context "mocking default values" do +require 'spec_helper_puppet' +describe 'mocking default values' do let(:mock_values) do { :product => 'jboss-eap', :version => '6.4.0.GA', - :controller => '127.0.0.1:9999', + :controller => '127.0.0.1:9999' } end @@ -19,17 +18,16 @@ end describe 'Puppet::Type::Jboss_jdbcdriver::ProviderJbosscli' do - let(:described_class) do Puppet::Type.type(:jboss_jdbcdriver).provider(:jbosscli) end let(:sample_repl) do { - :name => 'app-mails', - :modulename => 'super-crm', - :datasourceclassname => 'datasourceclassname', - :xadatasourceclassname => 'xadsname', - :classname => 'driverclasname', + :name => 'app-mails', + :modulename => 'super-crm', + :datasourceclassname => 'datasourceclassname', + :xadatasourceclassname => 'xadsname', + :classname => 'driverclasname' } end @@ -54,31 +52,29 @@ describe '#create' do before :each do + cmdlized_map = 'driver-class-name="driverclasname",driver-datasource-class-name="datasourceclassname",' \ + 'driver-module-name="super-crm",driver-name="app-mails",driver-xa-datasource-class-name="xadsname"' - cmdlizedMap = 'driver-class-name="driverclasname",driver-datasource-class-name="datasourceclassname",driver-module-name="super-crm",driver-name="app-mails",driver-xa-datasource-class-name="xadsname"' - - - cmd = "/subsystem=datasources/jdbc-driver=app-mails:add(#{cmdlizedMap})" - compiledcmd = "/profile=full-ha/#{cmd}" - bringUpName = 'JDBC-Driver' - expect(provider).to receive(:compilecmd).with(cmd).and_return(compiledcmd) + cmd = "/subsystem=datasources/jdbc-driver=app-mails:add(#{cmdlized_map})" + compiledcmd = "/profile=full-ha/#{cmd}" + bring_up_name = 'JDBC-Driver' + expect(provider).to receive(:compilecmd).with(cmd).and_return(compiledcmd) - expect(provider).to receive(:bringUp).with(bringUpName, compiledcmd).and_return(true) - end + expect(provider).to receive(:bringUp).with(bring_up_name, compiledcmd).and_return(true) + end - subject { provider.create } - it { expect(subject).to eq(true) } + subject { provider.create } + it { expect(subject).to eq(true) } end describe '#destroy' do before :each do - cmd = "/subsystem=datasources/jdbc-driver=#{resource[:name]}:remove" compiledcmd = "/profile=full-ha/#{cmd}" - bringDownName = 'JDBC-Driver' + bring_down_name = 'JDBC-Driver' expect(provider).to receive(:compilecmd).with(cmd).and_return(compiledcmd) - expect(provider).to receive(:bringDown).with(bringDownName, compiledcmd).and_return(true) + expect(provider).to receive(:bringDown).with(bring_down_name, compiledcmd).and_return(true) end subject { provider.destroy } @@ -90,7 +86,7 @@ cmd = "/subsystem=datasources/jdbc-driver=#{resource[:name]}:read-resource(recursive=true)" compiledcmd = "/profile=full-ha/#{cmd}" expected_output = { - :result => true, + :result => true } expect(provider).to receive(:compilecmd).with(cmd).and_return(compiledcmd) @@ -98,7 +94,7 @@ end subject { provider.exists? } - it { expect(subject).to eq(true)} + it { expect(subject).to eq(true) } end describe 'exists? when result is flse' do @@ -106,7 +102,7 @@ cmd = "/subsystem=datasources/jdbc-driver=#{resource[:name]}:read-resource(recursive=true)" compiledcmd = "/profile=full-ha/#{cmd}" expected_output = { - :result => false, + :result => false } expect(provider).to receive(:compilecmd).with(cmd).and_return(compiledcmd) @@ -114,17 +110,16 @@ end subject { provider.exists? } - it { expect(subject).to eq(false)} + it { expect(subject).to eq(false) } end describe 'setattrib' do - before :each do - cmd = "/subsystem=datasources/jdbc-driver=app-mails:write-attribute(name=super-name, value=driver-xa-datasource-class-name)" + cmd = '/subsystem=datasources/jdbc-driver=app-mails:write-attribute(name=super-name, value=driver-xa-datasource-class-name)' compiledcmd = "/profile=full-ha/#{cmd}" data = { - :asd => '1', + :asd => '1' } expected_res = { @@ -137,9 +132,8 @@ end subject { provider.setattrib 'super-name', 'driver-xa-datasource-class-name' } - let(:res_result) { false } - it { expect {subject}.to raise_error(RuntimeError) } + let(:res_result) { false } + it { expect { subject }.to raise_error(RuntimeError) } end - -end + end end diff --git a/spec/unit/provider/jboss_jmsqueue/jbosscli_spec.rb b/spec/unit/provider/jboss_jmsqueue/jbosscli_spec.rb index 14eed22..71d5571 100644 --- a/spec/unit/provider/jboss_jmsqueue/jbosscli_spec.rb +++ b/spec/unit/provider/jboss_jmsqueue/jbosscli_spec.rb @@ -1,12 +1,17 @@ -require "spec_helper" +require 'spec_helper_puppet' -context "mocking default values" do +describe 'mocking default values' do + module DataSetter + def data=(data) + @data = data + end + end let(:mock_values) do { :product => 'jboss-eap', :version => '6.4.0.GA', - :controller => '127.0.0.1:9999', + :controller => '127.0.0.1:9999' } end @@ -19,20 +24,19 @@ end describe 'Puppet::Type::JBoss_jmsqueue::ProviderJbosscli' do - let(:described_class) do Puppet::Type.type(:jboss_jmsqueue).provider(:jbosscli) end let(:sample_repl) do { - :name => 'app-mails', - :durable => true, - :ensure => 'present', + :name => 'app-mails', + :durable => true, + :ensure => 'present', + :profile => 'full-ha', :entries => [ 'queue/app-mails', - 'java:jboss/exported/jms/queue/app-mails', - ], - :profile => 'full-ha' + 'java:jboss/exported/jms/queue/app-mails' + ] } end @@ -48,6 +52,7 @@ end let(:provider) do + resource.provider.extend DataSetter resource.provider end @@ -57,69 +62,64 @@ describe '#create wth runasdomain? => true' do before :each do - - - bringUpName = 'Extension - messaging' - bringUpNameSubsytem = 'Subsystem - messaging' - profile = resource[:profile] - cmd = "/extension=org.jboss.as.messaging:add()" - cmd2 = - execCMD = '/extension=org.jboss.as.messaging:read-resource()' - execCMD_expected_output = { - :result => false, + bring_up_name = 'Extension - messaging' + bring_up_name_subsytem = 'Subsystem - messaging' + exec_cmd = '/extension=org.jboss.as.messaging:read-resource()' + exec_cmd_expected_output = { + :result => false } - execCMD2 = '/extension=org.jboss.as.messaging:add()' + exec_cmd2 = '/extension=org.jboss.as.messaging:add()' # line 4 expect(provider).to receive(:is_runasdomain).and_return(true) # line 17 - expect(provider).to receive(:execute).with(execCMD).and_return(execCMD_expected_output) + expect(provider).to receive(:execute).with(exec_cmd).and_return(exec_cmd_expected_output) # line 18 - expect(provider).to receive(:bringUp).with(bringUpName, execCMD2).and_return(true) + expect(provider).to receive(:bringUp).with(bring_up_name, exec_cmd2).and_return(true) # line 20 - cmdCompile = '/subsystem=messaging' - compiledCMDSubsystem = '/profile=full-ha/subsystem=messaging' - expect(provider).to receive(:compilecmd).with(cmdCompile).and_return(compiledCMDSubsystem) + cmd_compile = '/subsystem=messaging' + compiled_cmd_subsystem = '/profile=full-ha/subsystem=messaging' + expect(provider).to receive(:compilecmd).with(cmd_compile).and_return(compiled_cmd_subsystem) # line 21 - execCMDSubsystem = "#{compiledCMDSubsystem}:read-resource()" - expect(provider).to receive(:execute).with(execCMDSubsystem).and_return(execCMD_expected_output) + exec_cmd_subsystem = "#{compiled_cmd_subsystem}:read-resource()" + expect(provider).to receive(:execute).with(exec_cmd_subsystem).and_return(exec_cmd_expected_output) # line 22 - cmdSubsystem = "#{compiledCMDSubsystem}:add()" - expect(provider).to receive(:bringUp).with(bringUpNameSubsytem, cmdSubsystem).and_return(true) + cmd_subsystem = "#{compiled_cmd_subsystem}:add()" + expect(provider).to receive(:bringUp).with(bring_up_name_subsytem, cmd_subsystem).and_return(true) # line 24 - hornetCMD = '/subsystem=messaging/hornetq-server=default' - compiledHornetCMD = "/profile=full-ha/#{hornetCMD}" - execHornetCMD = "#{compiledHornetCMD}:read-resource()" - hornetBringUpName = 'Default HornetQ' - horneBringUpCMD = "#{compiledHornetCMD}:add()" + hornet_cmd = '/subsystem=messaging/hornetq-server=default' + compiled_hornet_cmd = "/profile=full-ha/#{hornet_cmd}" + exec_hornet_cmd = "#{compiled_hornet_cmd}:read-resource()" + hornet_bring_up_name = 'Default HornetQ' + hornet_bring_up_cmd = "#{compiled_hornet_cmd}:add()" - expect(provider).to receive(:compilecmd).with(hornetCMD).and_return(compiledHornetCMD) - expect(provider).to receive(:execute).with(execHornetCMD).and_return(execCMD_expected_output) - expect(provider).to receive(:bringUp).with(hornetBringUpName, horneBringUpCMD).and_return(true) + expect(provider).to receive(:compilecmd).with(hornet_cmd).and_return(compiled_hornet_cmd) + expect(provider).to receive(:execute).with(exec_hornet_cmd).and_return(exec_cmd_expected_output) + expect(provider).to receive(:bringUp).with(hornet_bring_up_name, hornet_bring_up_cmd).and_return(true) # line 28 - finalCMD = 'jms-queue --profile=full-ha add --queue-address=app-mails --entries=["queue/app-mails", "java:jboss/exported/jms/queue/app-mails"] --durable=true' - finalBringUpName = 'JMS Queue' - expect(provider).to receive(:bringUp).with(finalBringUpName, finalCMD).and_return(true) - + final_cmd = 'jms-queue --profile=full-ha add --queue-address=app-mails ' \ + '--entries=["queue/app-mails", "java:jboss/exported/jms/queue/app-mails"] --durable=true' + final_bring_up_name = 'JMS Queue' + expect(provider).to receive(:bringUp).with(final_bring_up_name, final_cmd).and_return(true) end subject { provider.create } - it {expect(subject).to eq(true)} + it { expect(subject).to eq(true) } end describe '#destroy' do before :each do expect(provider).to receive(:is_runasdomain).and_return(true) cmd = "jms-queue --profile=#{resource[:profile]} remove --queue-address=#{resource[:name]}" - bringDownName = 'JMS Queue' - expect(provider).to receive(:bringDown).with(bringDownName, cmd).and_return(true) + bring_down_name = 'JMS Queue' + expect(provider).to receive(:bringDown).with(bring_down_name, cmd).and_return(true) end subject { provider.destroy } @@ -128,17 +128,16 @@ describe '#exists? with result => true' do before :each do - $data = nil cmd = "/subsystem=messaging/hornetq-server=default/jms-queue=#{resource[:name]}:read-resource()" - compiledCMD = "/profile=full-ha#{cmd}" + compiled_cmd = "/profile=full-ha#{cmd}" expected_output = { :result => true, - :data => 'asd', + :data => 'asd' } - expect(provider).to receive(:compilecmd).with(cmd).and_return(compiledCMD) - expect(provider).to receive(:executeAndGet).with(compiledCMD).and_return(expected_output) + expect(provider).to receive(:compilecmd).with(cmd).and_return(compiled_cmd) + expect(provider).to receive(:executeAndGet).with(compiled_cmd).and_return(expected_output) end subject { provider.exists? } @@ -147,17 +146,16 @@ describe '#exists? with result => false' do before :each do - $data = nil cmd = "/subsystem=messaging/hornetq-server=default/jms-queue=#{resource[:name]}:read-resource()" - compiledCMD = "/profile=full-ha#{cmd}" + compiled_cmd = "/profile=full-ha#{cmd}" expected_output = { :result => false, - :data => 'asd', + :data => 'asd' } - expect(provider).to receive(:compilecmd).with(cmd).and_return(compiledCMD) - expect(provider).to receive(:executeAndGet).with(compiledCMD).and_return(expected_output) + expect(provider).to receive(:compilecmd).with(cmd).and_return(compiled_cmd) + expect(provider).to receive(:executeAndGet).with(compiled_cmd).and_return(expected_output) end subject { provider.exists? } @@ -166,40 +164,36 @@ describe '#durable' do before :each do - $data = { - 'durable' => 'true', - } + provider.data = { 'durable' => 'true' } end subject { provider.durable } - it { expect(subject).to eq("true") } + it { expect(subject).to eq('true') } end describe '#durable = true' do before :each do - expect(provider).to receive(:setattr).with('durable', "\"true\"").and_return(true) + expect(provider).to receive(:setattr).with('durable', '"true"').and_return(true) end - subject { provider.durable = "true" } - it { expect(subject).to eq("true") } + subject { provider.durable = 'true' } + it { expect(subject).to eq('true') } end describe '#entries' do before :each do - $data = { - 'entries' => 'asd', - } + provider.data = { 'entries' => 'asd' } end subject { provider.entries } it { expect(subject).to eq('asd') } end - describe "#entries with true" do + describe '#entries with true' do before :each do - entries = "[\"true\", \"false\"]" - expect(provider).to receive(:setattr).with('entries', entries).and_return("true") + entries = '["true", "false"]' + expect(provider).to receive(:setattr).with('entries', entries).and_return('true') end - subject { provider.entries = ['true', 'false'] } - it { expect(subject).to eq (['true', 'false']) } + subject { provider.entries = %w[true false] } + it { expect(subject).to eq(%w[true false]) } end -end + end end diff --git a/spec/unit/provider/jboss_securitydomain/jbosscli_spec.rb b/spec/unit/provider/jboss_securitydomain/jbosscli_spec.rb index 013b03d..d37100e 100644 --- a/spec/unit/provider/jboss_securitydomain/jbosscli_spec.rb +++ b/spec/unit/provider/jboss_securitydomain/jbosscli_spec.rb @@ -1,6 +1,6 @@ -require 'spec_helper' +require 'spec_helper_puppet' -context 'mocking default values for SecurityDomain' do +describe 'mocking default values for SecurityDomain' do let(:mock_values) do { :product => 'jboss-eap', @@ -29,14 +29,14 @@ :name => 'db-auth-default', :code => 'Database', :codeflag => false, + :profile => 'full', :moduleoptions => { - 'dsJndiName' => ':jboss/datasources/default-db', + 'dsJndiName' => ':jboss/datasources/default-db', 'hashStorePassword' => 'false', - 'hashUserPassword' => 'true', - 'principalsQuery' => "select 'password' from users u where u.login = ?", - 'rolesQuery' => "select r.name, 'Roles' from users" - }, - :profile => 'full' + 'hashUserPassword' => 'true', + 'principalsQuery' => "select 'password' from users u where u.login = ?", + 'rolesQuery' => "select r.name, 'Roles' from users" + } } end @@ -57,7 +57,7 @@ let(:mocked_execution_state_wrapper) { Testing::Mock::ExecutionStateWrapper.new } - context 'before 6.4' do + describe 'before 6.4' do describe 'exists? when everything is set' do before :each do output = <<-eos @@ -111,14 +111,15 @@ '/profile=full/subsystem=security:read-resource(recursive=true)', true, output, - true) + true + ) provider.execution_state_wrapper = mocked_execution_state_wrapper end subject { provider.exists? } it { expect(subject).to eq(true) } end - context 'exists? with securitydomain not present in system' do + describe 'exists? with securitydomain not present in system' do before :each do output = <<-eos { @@ -146,7 +147,8 @@ '/profile=full/subsystem=security:read-resource(recursive=true)', true, output, - true) + true + ) provider.execution_state_wrapper = mocked_execution_state_wrapper end @@ -154,7 +156,7 @@ it { expect(subject).to eq(false) } end - context 'exists? with login-modules not present in system' do + describe 'exists? with login-modules not present in system' do before :each do output = <<-eos { @@ -201,7 +203,8 @@ '/profile=full/subsystem=security:read-resource(recursive=true)', true, output, - true) + true + ) provider.execution_state_wrapper = mocked_execution_state_wrapper end @@ -209,7 +212,7 @@ it { expect(subject).to eq(false) } end - context 'destroy method' do + describe 'destroy method' do before :each do output = <<-eos { @@ -256,7 +259,8 @@ '/profile=full/subsystem=security/security-domain=db-auth-default/authentication=classic:remove()', true, output, - true) + true + ) provider.execution_state_wrapper = mocked_execution_state_wrapper end @@ -265,8 +269,8 @@ end end - context 'create methods' do - context 'create? when there is no login modules' do + describe 'create methods' do + describe 'create? when there is no login modules' do before :each do output = <<-eos { @@ -313,12 +317,17 @@ '/profile=full/subsystem=security:read-resource(recursive=true)', true, output, - true) + true + ) provider.execution_state_wrapper = mocked_execution_state_wrapper provider.exists? mocked_execution_state_wrapper.register_command( - "/profile=full/subsystem=security/security-domain=db-auth-default/authentication=classic/login-module=db-auth-default:add(code=\"Database\",flag=false,module-options=[(\"dsJndiName\"=>\":jboss/datasources/default-db\"),(\"hashStorePassword\"=>\"false\"),(\"hashUserPassword\"=>\"true\"),(\"principalsQuery\"=>\"select 'password' from users u where u.login = ?\"),(\"rolesQuery\"=>\"select r.name, 'Roles' from users\")])", + '/profile=full/subsystem=security/security-domain=db-auth-default/authentication=classic/login-module=db-auth-default' \ + ':add(code="Database",flag=false,module-options=[("dsJndiName"=>":jboss/datasources/default-db"),' \ + '("hashStorePassword"=>"false"),("hashUserPassword"=>"true"),("principalsQuery"=>' \ + '"select \'password\' from users u where u.login = ?"),("rolesQuery"=>' \ + '"select r.name, \'Roles\' from users")])', true, 'asd', true @@ -326,10 +335,24 @@ end subject { provider.create } - it { expect(subject).to eq([['Security Domain Login Modules', "/profile=full/subsystem=security/security-domain=db-auth-default/authentication=classic/login-module=db-auth-default:add(code=\"Database\",flag=false,module-options=[(\"dsJndiName\"=>\":jboss/datasources/default-db\"),(\"hashStorePassword\"=>\"false\"),(\"hashUserPassword\"=>\"true\"),(\"principalsQuery\"=>\"select 'password' from users u where u.login = ?\"),(\"rolesQuery\"=>\"select r.name, 'Roles' from users\")])"]]) } + it do + expect(subject).to eq( + [ + [ + 'Security Domain Login Modules', + + '/profile=full/subsystem=security/security-domain=db-auth-default/authentication=classic/login-module=' \ + 'db-auth-default:add(code="Database",flag=false,module-options=[("dsJndiName"=>' \ + '":jboss/datasources/default-db"),("hashStorePassword"=>"false"),("hashUserPassword"=>"true"),' \ + '("principalsQuery"=>"select \'password\' from users u where u.login = ?"),("rolesQuery"=>' \ + '"select r.name, \'Roles\' from users")])' + ] + ] + ) + end end - context 'create? when there is no authentication' do + describe 'create? when there is no authentication' do before :each do output = <<-eos { @@ -357,7 +380,8 @@ '/profile=full/subsystem=security:read-resource(recursive=true)', true, output, - true) + true + ) provider.execution_state_wrapper = mocked_execution_state_wrapper provider.exists? @@ -369,7 +393,11 @@ ) mocked_execution_state_wrapper.register_command( - "/profile=full/subsystem=security/security-domain=db-auth-default/authentication=classic/login-module=db-auth-default:add(code=\"Database\",flag=false,module-options=[(\"dsJndiName\"=>\":jboss/datasources/default-db\"),(\"hashStorePassword\"=>\"false\"),(\"hashUserPassword\"=>\"true\"),(\"principalsQuery\"=>\"select 'password' from users u where u.login = ?\"),(\"rolesQuery\"=>\"select r.name, 'Roles' from users\")])", + '/profile=full/subsystem=security/security-domain=db-auth-default/authentication=classic/login-module=' \ + 'db-auth-default:add(code="Database",flag=false,module-options=[("dsJndiName"=>' \ + '":jboss/datasources/default-db"),("hashStorePassword"=>"false"),("hashUserPassword"=>"true"),' \ + '("principalsQuery"=>"select \'password\' from users u where u.login = ?"),("rolesQuery"=>' \ + '"select r.name, \'Roles\' from users")])', true, 'asd', true @@ -377,9 +405,26 @@ end subject { provider.create } - it { expect(subject).to eq([["Security Domain Authentication", "/profile=full/subsystem=security/security-domain=db-auth-default/authentication=classic:add()"], ["Security Domain Login Modules", "/profile=full/subsystem=security/security-domain=db-auth-default/authentication=classic/login-module=db-auth-default:add(code=\"Database\",flag=false,module-options=[(\"dsJndiName\"=>\":jboss/datasources/default-db\"),(\"hashStorePassword\"=>\"false\"),(\"hashUserPassword\"=>\"true\"),(\"principalsQuery\"=>\"select 'password' from users u where u.login = ?\"),(\"rolesQuery\"=>\"select r.name, 'Roles' from users\")])"]]) } + it do + expect(subject).to eq( + [ + [ + 'Security Domain Authentication', + '/profile=full/subsystem=security/security-domain=db-auth-default/authentication=classic:add()' + ], + [ + 'Security Domain Login Modules', + '/profile=full/subsystem=security/security-domain=db-auth-default/authentication=classic/login-module=' \ + 'db-auth-default:add(code="Database",flag=false,module-options=[("dsJndiName"=>":jboss/datasources/' \ + 'default-db"),("hashStorePassword"=>"false"),("hashUserPassword"=>"true"),("principalsQuery"=>' \ + '"select \'password\' from users u where u.login = ?"),("rolesQuery"=>"select r.name, \'Roles\' ' \ + 'from users")])' + ] + ] + ) + end end - context 'create? when there is no securitydomain' do + describe 'create? when there is no securitydomain' do before :each do output = <<-eos { @@ -426,11 +471,11 @@ '/profile=full/subsystem=security:read-resource(recursive=true)', true, output, - true) + true + ) provider.execution_state_wrapper = mocked_execution_state_wrapper provider.exists? - mocked_execution_state_wrapper.register_command( '/profile=full/subsystem=security/security-domain=db-auth-default:add(cache-type=default)', true, @@ -446,21 +491,41 @@ ) mocked_execution_state_wrapper.register_command( - "/profile=full/subsystem=security/security-domain=db-auth-default/authentication=classic/login-module=db-auth-default:add(code=\"Database\",flag=false,module-options=[(\"dsJndiName\"=>\":jboss/datasources/default-db\"),(\"hashStorePassword\"=>\"false\"),(\"hashUserPassword\"=>\"true\"),(\"principalsQuery\"=>\"select 'password' from users u where u.login = ?\"),(\"rolesQuery\"=>\"select r.name, 'Roles' from users\")])", + '/profile=full/subsystem=security/security-domain=db-auth-default/authentication=classic/login-module=' \ + 'db-auth-default:add(code="Database",flag=false,module-options=[("dsJndiName"=>":jboss/datasources/' \ + 'default-db"),("hashStorePassword"=>"false"),("hashUserPassword"=>"true"),("principalsQuery"=>' \ + '"select \'password\' from users u where u.login = ?"),("rolesQuery"=>"select r.name, \'Roles\' ' \ + 'from users")])', true, 'asd', true ) - end subject { provider.create } - it { expect(subject).to eq([["Security Domain Cache Type", "/profile=full/subsystem=security/security-domain=db-auth-default:add(cache-type=default)"], ["Security Domain Authentication", "/profile=full/subsystem=security/security-domain=db-auth-default/authentication=classic:add()"], ["Security Domain Login Modules", "/profile=full/subsystem=security/security-domain=db-auth-default/authentication=classic/login-module=db-auth-default:add(code=\"Database\",flag=false,module-options=[(\"dsJndiName\"=>\":jboss/datasources/default-db\"),(\"hashStorePassword\"=>\"false\"),(\"hashUserPassword\"=>\"true\"),(\"principalsQuery\"=>\"select 'password' from users u where u.login = ?\"),(\"rolesQuery\"=>\"select r.name, 'Roles' from users\")])"]]) } - end - - end - - context 'after 6.4' do + it do + expect(subject).to eq( + [ + [ + 'Security Domain Cache Type', + '/profile=full/subsystem=security/security-domain=db-auth-default:add(cache-type=default)' + ], + [ + 'Security Domain Authentication', + '/profile=full/subsystem=security/security-domain=db-auth-default/authentication=classic:add()' + ], + [ + 'Security Domain Login Modules', + '/profile=full/subsystem=security/security-domain=db-auth-default/authentication=classic/login-module=' \ + 'db-auth-default:add(code="Database",flag=false,module-options=[("dsJndiName"=>":jboss/datasources' \ + '/default-db"),("hashStorePassword"=>"false"),("hashUserPassword"=>"true"),("principalsQuery"=>' \ + '"select \'password\' from users u where u.login = ?"),("rolesQuery"=>"select r.name, \'Roles\' ' \ + 'from users")])' + ] + ] + ) + end end end end +end diff --git a/spec/unit/selfcheck_spec.rb b/spec/unit/selfcheck_spec.rb new file mode 100644 index 0000000..e95370f --- /dev/null +++ b/spec/unit/selfcheck_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper_puppet' + +describe 'selfcheck' do + class SelfCheck + def test(motd = false) + value = File.read '/etc/passwd' + value = File.read '/etc/motd' if motd + value + end + end + + it { expect(subject).to eq 'selfcheck' } + it 'returns :rspec' do + expect(RSpec.configuration.mock_framework.framework_name).to eq(:rspec) + end + + describe 'validate mocks' do + before(:each) do + expect(File).to receive(:read).with('/etc/passwd').and_return( + 'secret' + ) + allow(File).to receive(:read).with('/etc/motd').and_raise('Access denied') + end + let(:instance) { SelfCheck.new } + subject { instance.test(motd) } + + describe 'on motd' do + let(:motd) { true } + it { expect { subject }.to raise_error(/Access denied/) } + end + describe 'on passwd' do + let(:motd) { false } + it { is_expected.to eq 'secret' } + end + end +end diff --git a/spec/unit/types/jboss_confignode_spec.rb b/spec/unit/types/jboss_confignode_spec.rb index 9bae25f..ee9c56d 100644 --- a/spec/unit/types/jboss_confignode_spec.rb +++ b/spec/unit/types/jboss_confignode_spec.rb @@ -1,9 +1,9 @@ -require 'spec_helper' +require 'spec_helper_puppet' describe 'jboss_confignode', :type => :type do let(:described_class) { Puppet::Type.type(:jboss_confignode) } subject { described_class } - let(:ex_class) { if Puppet.version > '3.0.0' then Puppet::ResourceError else Puppet::Error end } + let(:ex_class) { Puppet.version > '3.0.0' ? Puppet::ResourceError : Puppet::Error } def extend_params(given) { @@ -17,19 +17,24 @@ def extend_params(given) it { expect(type).not_to be_nil } describe 'controller == :undef' do let(:params) { extend_params({ :controller => :undef }) } - it { expect { type }.to raise_error(ex_class, 'Parameter controller failed on Jboss_confignode[/sybsystem=datasources]: Domain controller must be provided') } + it do + expect { type }.to raise_error( + ex_class, + 'Parameter controller failed on Jboss_confignode[/sybsystem=datasources]: Domain controller must be provided' + ) + end end describe 'properties' do let(:params) { extend_params({ :properties => properties }) } describe 'munge' do - context 'not respond_to? :[]' do + describe 'not respond_to? :[]' do let(:properties) { false } subject { type.property :properties } its(:value) { is_expected.to eq({}) } end - context 'respond_to? :[]' do - let(:properties) { {'example' => false} } + describe 'respond_to? :[]' do + let(:properties) { { 'example' => false } } subject { type.property :properties } its(:value) { is_expected.to eq(properties) } end @@ -38,23 +43,32 @@ def extend_params(given) describe 'change_to_s' do let(:properties) { false } subject { type.property(:properties).change_to_s(from, to) } - context 'from :absent and to hash', :from => :absent, :to => { 'alice' => 'five', 'bob' => 'seven' } do + describe 'from :absent and to hash', + :from => :absent, + :to => { 'alice' => 'five', 'bob' => 'seven' } do let(:from) { |expl| expl.metadata[:from] } let(:to) { |expl| expl.metadata[:to] } it { expect(subject).to eq("property 'alice' has been set to \"five\", property 'bob' has been set to \"seven\"") } end - context 'from hash and to changed hash', :from => { 'alice' => 'five', 'bob' => 'nine' }, :to => { 'alice' => 'five', 'bob' => 'seven' } do + describe 'from hash and to changed hash', + :from => { 'alice' => 'five', 'bob' => 'nine' }, + :to => { 'alice' => 'five', 'bob' => 'seven' } do let(:from) { |expl| expl.metadata[:from] } let(:to) { |expl| expl.metadata[:to] } it { expect(subject).to eq("property 'bob' has changed from \"nine\" to \"seven\"") } end - context 'from hash and to :absent', :from => { 'alice' => 'five', 'bob' => 'nine' }, :to => :absent do + describe 'from hash and to :absent', + :from => { 'alice' => 'five', 'bob' => 'nine' }, + :to => :absent do let(:from) { |expl| expl.metadata[:from] } let(:to) { |expl| expl.metadata[:to] } - it { expect(subject).to eq("property 'alice' was \"five\" and has been removed, property 'bob' was \"nine\" and has been removed") } + it do + expect(subject).to eq( + "property 'alice' was \"five\" and has been removed, property 'bob' was \"nine\" and has been removed" + ) + end end end end end - end diff --git a/spec/unit/types/jboss_datasource_spec.rb b/spec/unit/types/jboss_datasource_spec.rb index 01d1906..8dda1c0 100644 --- a/spec/unit/types/jboss_datasource_spec.rb +++ b/spec/unit/types/jboss_datasource_spec.rb @@ -1,10 +1,10 @@ -require 'spec_helper' +require 'spec_helper_puppet' describe 'jboss_datasource', :type => :type do let(:described_class) { Puppet::Type.type(:jboss_datasource) } subject { described_class } it { expect(subject).not_to be_nil } - let(:ex_class) { if Puppet.version > '3.0.0' then Puppet::ResourceError else Puppet::Error end } + let(:ex_class) { Puppet.version > '3.0.0' ? Puppet::ResourceError : Puppet::Error } def extend_params(given) { @@ -15,123 +15,133 @@ def extend_params(given) let(:type) { described_class.new(params) } describe 'controller' do - context 'given :undef' do + describe 'given :undef' do let(:params) { extend_params({ :controller => :undef }) } it do - expect { type }.to raise_error(ex_class, - 'Parameter controller failed on Jboss_datasource[spec-datasource]: Domain controller must be provided') + expect { type }.to raise_error( + ex_class, + 'Parameter controller failed on Jboss_datasource[spec-datasource]: Domain controller must be provided' + ) end end end describe 'port' do - context 'given invalid text' do - let(:params) { extend_params({ :port => "an invalid port" }) } + describe 'given invalid text' do + let(:params) { extend_params(:port => 'an invalid port') } it do - expect { type }.to raise_error(ex_class, - 'Parameter port failed on Jboss_datasource[spec-datasource]: Datasource port is invalid, given "an invalid port"') + expect { type }.to raise_error( + ex_class, + 'Parameter port failed on Jboss_datasource[spec-datasource]: Datasource port is invalid, given "an invalid port"' + ) end end - context 'given "5x45"' do - let(:params) { extend_params({ :port => "5x45" }) } + describe 'given "5x45"' do + let(:params) { extend_params(:port => '5x45') } it do - expect { type }.to raise_error(ex_class, - 'Parameter port failed on Jboss_datasource[spec-datasource]: Datasource port is invalid, given "5x45"') + expect { type }.to raise_error( + ex_class, + 'Parameter port failed on Jboss_datasource[spec-datasource]: Datasource port is invalid, given "5x45"' + ) end end - context 'property :port' do + describe 'property :port' do subject { type.property :port } - context 'given as "7778"' do - let(:params) { extend_params({ :port => "7778" }) } + describe 'given as "7778"' do + let(:params) { extend_params(:port => '7778') } its(:value) { should == 7778 } end - context 'given as ""' do - let(:params) { extend_params({ :port => "" }) } + describe 'given as ""' do + let(:params) { extend_params(:port => '') } its(:value) { should == 0 } end end end describe 'host' do - context 'given invalid text " "' do - let(:params) { extend_params({ :host => ' ' }) } + describe 'given invalid text " "' do + let(:params) { extend_params(:host => ' ') } it do - expect { type }.to raise_error(ex_class, - 'Parameter host failed on Jboss_datasource[spec-datasource]: Datasource host is invalid, given " "') + expect { type }.to raise_error( + ex_class, + 'Parameter host failed on Jboss_datasource[spec-datasource]: Datasource host is invalid, given " "' + ) end end - context 'given "an invalid host"' do - let(:params) { extend_params({ :host => "an invalid host" }) } + describe 'given "an invalid host"' do + let(:params) { extend_params(:host => 'an invalid host') } it do - expect { type }.to raise_error(ex_class, - 'Parameter host failed on Jboss_datasource[spec-datasource]: Datasource host is invalid, given "an invalid host"') + expect { type }.to raise_error( + ex_class, + 'Parameter host failed on Jboss_datasource[spec-datasource]: Datasource host is invalid, given "an invalid host"' + ) end end - context 'given "node-01.example.org"' do - let(:params) { extend_params({ :host => "node-01.example.org" }) } + describe 'given "node-01.example.org"' do + let(:params) { extend_params(:host => 'node-01.example.org') } it { expect { type }.not_to raise_error } end - context 'given "192.168.16.2"' do - let(:params) { extend_params({ :host => "192.168.16.2" }) } + describe 'given "192.168.16.2"' do + let(:params) { extend_params(:host => '192.168.16.2') } it { expect { type }.not_to raise_error } end - context 'given "fe80::250:56ff:fec0:8"' do - let(:params) { extend_params({ :host => "fe80::250:56ff:fec0:8" }) } + describe 'given "fe80::250:56ff:fec0:8"' do + let(:params) { extend_params(:host => 'fe80::250:56ff:fec0:8') } it { expect { type }.not_to raise_error } end end describe 'minpoolsize' do subject { type.property :minpoolsize } - context 'given invalid text' do - let(:params) { extend_params({ :minpoolsize => "an invalid text" }) } + describe 'given invalid text' do + let(:params) { extend_params(:minpoolsize => 'an invalid text') } its(:value) { should == 1 } end - context 'given 13.45' do - let(:params) { extend_params({ :minpoolsize => 13.45 }) } + describe 'given 13.45' do + let(:params) { extend_params(:minpoolsize => 13.45) } its(:value) { should == 13 } end - context 'given :undef' do - let(:params) { extend_params({ :minpoolsize => :undef }) } + describe 'given :undef' do + let(:params) { extend_params(:minpoolsize => :undef) } its(:value) { should == 1 } end - context 'given "17"' do - let(:params) { extend_params({ :minpoolsize => '17' }) } + describe 'given "17"' do + let(:params) { extend_params(:minpoolsize => '17') } its(:value) { should == 17 } end end describe 'maxpoolsize' do subject { type.property :maxpoolsize } - context 'given invalid text' do - let(:params) { extend_params({ :maxpoolsize => "an invalid text" }) } + describe 'given invalid text' do + let(:params) { extend_params(:maxpoolsize => 'an invalid text') } its(:value) { should == 50 } end - context 'given 13.45' do - let(:params) { extend_params({ :maxpoolsize => 13.45 }) } + describe 'given 13.45' do + let(:params) { extend_params(:maxpoolsize => 13.45) } its(:value) { should == 13 } end - context 'given :undef' do - let(:params) { extend_params({ :maxpoolsize => :undef }) } + describe 'given :undef' do + let(:params) { extend_params(:maxpoolsize => :undef) } its(:value) { should == 50 } end - context 'given "17"' do - let(:params) { extend_params({ :maxpoolsize => '17' }) } + describe 'given "17"' do + let(:params) { extend_params(:maxpoolsize => '17') } its(:value) { should == 17 } end end describe 'password' do - let(:params) { extend_params({ :password => "an invalid text" }) } + let(:params) { extend_params(:password => 'an invalid text') } let(:expected_message) { 'password has been changed.' } subject { type.property(:password).change_to_s(from, to) } - context 'change_to_s' do - context ':absent, "test-passwd"' do + describe 'change_to_s' do + describe ':absent, "test-passwd"' do let(:from) { :absent } let(:to) { 'test-passwd' } it { expect(subject).to eq(expected_message) } end - context '"test-passwd", :absent' do + describe '"test-passwd", :absent' do let(:from) { 'test-passwd' } let(:to) { :absent } it { expect(subject).to eq(expected_message) } @@ -141,60 +151,76 @@ def extend_params(given) describe 'options' do let(:params) do - extend_params({ + extend_params( :options => options - }) + ) end - context 'given invalid text' do - let(:options) { "an invalid text" } + describe 'given invalid text' do + let(:options) { 'an invalid text' } it do - expect { type }.to raise_error(ex_class, - 'Parameter options failed on Jboss_datasource[spec-datasource]: You can pass only hash-like objects or absent and undef values, given "an invalid text"') + expect { type }.to raise_error( + ex_class, + 'Parameter options failed on Jboss_datasource[spec-datasource]: You can pass only hash-like' \ + ' objects or absent and undef values, given "an invalid text"' + ) end end - context 'given invalid boolean' do + describe 'given invalid boolean' do let(:options) { true } it do - expect { type }.to raise_error(ex_class, - 'Parameter options failed on Jboss_datasource[spec-datasource]: You can pass only hash-like objects or absent and undef values, given true') + expect { type }.to raise_error( + ex_class, + 'Parameter options failed on Jboss_datasource[spec-datasource]: You can pass only hash-like' \ + ' objects or absent and undef values, given true' + ) end end - context 'display changes via change_to_s(from, to) using' do + describe 'display changes via change_to_s(from, to) using' do let(:options) { {} } subject { type.property(:options).change_to_s(from, to) } - context 'from :absent and to hash', :from => :absent, :to => { 'alice' => 'five', 'bob' => 'seven' } do + describe 'from :absent and to hash', + :from => :absent, + :to => { 'alice' => 'five', 'bob' => 'seven' } do let(:from) { |expl| expl.metadata[:from] } let(:to) { |expl| expl.metadata[:to] } it { expect(subject).to eq("option 'alice' has been set to \"five\", option 'bob' has been set to \"seven\"") } end - context 'from hash and to changed hash', :from => { 'alice' => 'five', 'bob' => 'nine' }, :to => { 'alice' => 'five', 'bob' => 'seven' } do + describe 'from hash and to changed hash', + :from => { 'alice' => 'five', 'bob' => 'nine' }, + :to => { 'alice' => 'five', 'bob' => 'seven' } do let(:from) { |expl| expl.metadata[:from] } let(:to) { |expl| expl.metadata[:to] } it { expect(subject).to eq("option 'bob' has changed from \"nine\" to \"seven\"") } end - context 'from hash and to :absent', :from => { 'alice' => 'five', 'bob' => 'nine' }, :to => :absent do + describe 'from hash and to :absent', + :from => { 'alice' => 'five', 'bob' => 'nine' }, + :to => :absent do let(:from) { |expl| expl.metadata[:from] } let(:to) { |expl| expl.metadata[:to] } - it { expect(subject).to eq('option \'alice\' was "five" and has been removed, option \'bob\' was "nine" and has been removed') } + it do + expect(subject).to eq( + 'option \'alice\' was "five" and has been removed, option \'bob\' was' \ + ' "nine" and has been removed' + ) + end end end - context 'munge new values using' do + describe 'munge new values using' do let(:options) { {} } subject { type.property(:options).munge(new_values) } - context 'regular hash' do + describe 'regular hash' do let(:new_values) { { 'alice' => 'five', 'bob' => 'seven' } } - it { expect(subject).to eq({ 'alice' => 'five', 'bob' => 'seven' }) } + it { expect(subject).to eq('alice' => 'five', 'bob' => 'seven') } end - context 'hash with :undef\'s' do + describe 'hash with :undef\'s' do let(:new_values) { { 'alice' => :undef, 'bob' => 'seven' } } - it { expect(subject).to eq({ 'alice' => nil, 'bob' => 'seven' }) } + it { expect(subject).to eq('alice' => nil, 'bob' => 'seven') } end - context 'an :undef\'s' do + describe 'an :undef\'s' do let(:new_values) { :undef } it { expect(subject).to eq(:undef) } end end end - end diff --git a/spec/unit/types/jboss_deploy_spec.rb b/spec/unit/types/jboss_deploy_spec.rb index 2c1c6ae..995a92c 100644 --- a/spec/unit/types/jboss_deploy_spec.rb +++ b/spec/unit/types/jboss_deploy_spec.rb @@ -1,10 +1,10 @@ -require 'spec_helper' +require 'spec_helper_puppet' describe 'jboss_deploy', :type => :type do let(:described_class) { Puppet::Type.type(:jboss_deploy) } subject { described_class } it { expect(subject).not_to be_nil } - let(:ex_class) { if Puppet.version > '3.0.0' then Puppet::ResourceError else Puppet::Error end } + let(:ex_class) { Puppet.version > '3.0.0' ? Puppet::ResourceError : Puppet::Error } def extend_params(given) { @@ -14,29 +14,33 @@ def extend_params(given) let(:type) { described_class.new(params) } - context 'no parameters given' do + describe 'no parameters given' do let(:params) { extend_params({}) } it { expect(type).not_to be_nil } end describe 'controler' do - context 'given :undef' do + describe 'given :undef' do let(:params) { extend_params({ :controller => :undef }) } it do - expect { type }.to raise_error(ex_class, - 'Parameter controller failed on Jboss_deploy[spec-artifact]: Domain controller must be provided') - end + expect { type }.to raise_error( + ex_class, + 'Parameter controller failed on Jboss_deploy[spec-artifact]: Domain controller must be provided' + ) + end end end describe ':runtime_name' do - context 'given invalid input' do - let(:params) { extend_params( :runtime_name => 'not_valid_runtime_name' ) } + describe 'given invalid input' do + let(:params) { extend_params(:runtime_name => 'not_valid_runtime_name') } it do - expect { type }.to raise_error(ex_class, - 'Parameter runtime_name failed on Jboss_deploy[spec-artifact]: Invalid file extension, module only supports: .jar, .war, .ear, .rar') - end + expect { type }.to raise_error( + ex_class, + 'Parameter runtime_name failed on Jboss_deploy[spec-artifact]: Invalid file extension, module only' \ + ' supports: .jar, .war, .ear, .rar' + ) + end end end - end diff --git a/spec/unit/types/jboss_jdbcdriver_spec.rb b/spec/unit/types/jboss_jdbcdriver_spec.rb index 716416e..28a83ee 100644 --- a/spec/unit/types/jboss_jdbcdriver_spec.rb +++ b/spec/unit/types/jboss_jdbcdriver_spec.rb @@ -1,11 +1,11 @@ -require 'spec_helper' +require 'spec_helper_puppet' describe 'jboss_jdbcdriver', :type => :type do let(:described_class) { Puppet::Type.type(:jboss_jdbcdriver) } subject { described_class } it { expect(subject).not_to be_nil } - context 'controller == nil' do + describe 'controller == nil' do let(:params) do { :title => 'test-driver', @@ -15,9 +15,11 @@ subject { described_class.new(params) } it do - ex_class = if Puppet.version > '3.0.0' then Puppet::ResourceError else Puppet::Error end - expect { subject }.to raise_error(ex_class, - 'Parameter controller failed on Jboss_jdbcdriver[test-driver]: Domain controller must be provided') + ex_class = Puppet.version > '3.0.0' ? Puppet::ResourceError : Puppet::Error + expect { subject }.to raise_error( + ex_class, + 'Parameter controller failed on Jboss_jdbcdriver[test-driver]: Domain controller must be provided' + ) end end -end \ No newline at end of file +end diff --git a/spec/unit/types/jboss_jmsqueue_spec.rb b/spec/unit/types/jboss_jmsqueue_spec.rb index 5793d64..8dda457 100644 --- a/spec/unit/types/jboss_jmsqueue_spec.rb +++ b/spec/unit/types/jboss_jmsqueue_spec.rb @@ -1,45 +1,45 @@ -require "spec_helper" +require 'spec_helper_puppet' describe 'jboss_jmsqueue', :type => :type do - let(:described_class) { Puppet::Type.type(:jboss_jmsqueue) } - subject { described_class } - it { expect(subject).not_to be_nil } - let(:ex_class) { if Puppet.version > '3.0.0' then Puppet::ResourceError else Puppet::Error end } + let(:described_class) { Puppet::Type.type(:jboss_jmsqueue) } + subject { described_class } + it { expect(subject).not_to be_nil } + let(:ex_class) { Puppet.version > '3.0.0' ? Puppet::ResourceError : Puppet::Error } - def extend_params(given) - { - :title => 'spec-jmsqueue_spec' - }.merge(given) - end + def extend_params(given) + { :title => 'spec-jmsqueue_spec' }.merge(given) + end - let(:type) { described_class.new(params) } + let(:type) { described_class.new(params) } - describe 'controller' do - context 'given :undef' do - let(:params) { extend_params({ :controller => :undef }) } - it do - expect { type }.to raise_error(ex_class, - 'Parameter controller failed on Jboss_jmsqueue[spec-jmsqueue_spec]: Domain controller must be provided') - end - end + describe 'controller' do + describe 'given :undef' do + let(:params) { extend_params({ :controller => :undef }) } + it do + expect { type }.to raise_error( + ex_class, + 'Parameter controller failed on Jboss_jmsqueue[spec-jmsqueue_spec]: Domain controller must be provided' + ) + end end + end - describe 'entries' do - context 'is_to_s' do - let(:entries) { [ 'queue/app-mails', 'java:jboss/exported/jms/queue/app-mails'] } - let(:params) { extend_params({ :entries => entries }) } - let(:property) { type.property(:entries) } - it do - expect(property.is_to_s(entries)).to eq( "[\"queue/app-mails\", \"java:jboss/exported/jms/queue/app-mails\"]" ) - end + describe 'entries' do + describe 'is_to_s' do + let(:entries) { ['queue/app-mails', 'java:jboss/exported/jms/queue/app-mails'] } + let(:params) { extend_params({ :entries => entries }) } + let(:property) { type.property(:entries) } + it do + expect(property.is_to_s(entries)).to eq('["queue/app-mails", "java:jboss/exported/jms/queue/app-mails"]') end - context 'should_to_s' do - let(:entries) { [ 'queue/app-mails', 'java:jboss/exported/jms/queue/app-mails'] } - let(:params) { extend_params({ :entries => entries }) } - let(:property) { type.property(:entries) } - it do - expect(property.should_to_s(entries)).to eq( "[\"queue/app-mails\", \"java:jboss/exported/jms/queue/app-mails\"]" ) - end + end + describe 'should_to_s' do + let(:entries) { ['queue/app-mails', 'java:jboss/exported/jms/queue/app-mails'] } + let(:params) { extend_params({ :entries => entries }) } + let(:property) { type.property(:entries) } + it do + expect(property.should_to_s(entries)).to eq('["queue/app-mails", "java:jboss/exported/jms/queue/app-mails"]') end end + end end diff --git a/spec/unit/types/jboss_resourceadapter_spec.rb b/spec/unit/types/jboss_resourceadapter_spec.rb index ee25a55..6c735b1 100644 --- a/spec/unit/types/jboss_resourceadapter_spec.rb +++ b/spec/unit/types/jboss_resourceadapter_spec.rb @@ -1,26 +1,26 @@ -require "spec_helper" +require 'spec_helper_puppet' describe 'jboss_resourceadapter', :type => :type do - let(:described_class) { Puppet::Type.type(:jboss_resourceadapter) } - subject { described_class } - it { expect(subject).not_to be_nil } - let(:ex_class) { if Puppet.version > '3.0.0' then Puppet::ResourceError else Puppet::Error end } + let(:described_class) { Puppet::Type.type(:jboss_resourceadapter) } + subject { described_class } + it { expect(subject).not_to be_nil } + let(:ex_class) { Puppet.version > '3.0.0' ? Puppet::ResourceError : Puppet::Error } - def extend_params(given) - { - :title => 'spec-resourceadapter_spec' - }.merge(given) - end + def extend_params(given) + { :title => 'spec-resourceadapter_spec' }.merge(given) + end - let(:type) { described_class.new(params) } + let(:type) { described_class.new(params) } - describe 'controler' do - context 'given :undef' do - let(:params) { extend_params({ :controller => :undef }) } - it do - expect { type }.to raise_error(ex_class, - 'Parameter controller failed on Jboss_resourceadapter[spec-resourceadapter_spec]: Domain controller must be provided') - end - end + describe 'controler' do + describe 'given :undef' do + let(:params) { extend_params(:controller => :undef) } + it do + expect { type }.to raise_error( + ex_class, + 'Parameter controller failed on Jboss_resourceadapter[spec-resourceadapter_spec]: Domain controller must be provided' + ) + end end + end end diff --git a/spec/unit/types/jboss_securitydomain_spec.rb b/spec/unit/types/jboss_securitydomain_spec.rb index 684f757..c1f874a 100644 --- a/spec/unit/types/jboss_securitydomain_spec.rb +++ b/spec/unit/types/jboss_securitydomain_spec.rb @@ -1,28 +1,27 @@ -require "spec_helper" +require 'spec_helper_puppet' describe 'jboss_securitydomain', :type => :type do - let(:described_class) { Puppet::Type.type(:jboss_securitydomain) } - subject { described_class } - it { expect(subject).not_to be_nil } + let(:described_class) { Puppet::Type.type(:jboss_securitydomain) } + subject { described_class } + it { expect(subject).not_to be_nil } + let(:ex_class) { Puppet.version > '3.0.0' ? Puppet::ResourceError : Puppet::Error } - let(:ex_class) { if Puppet.version > '3.0.0' then Puppet::ResourceError else Puppet::Error end } + def extend_params(given) + { :title => 'spec-resourceadapter_spec' }.merge(given) + end - def extend_params(given) - { - :title => 'spec-resourceadapter_spec' - }.merge(given) - end - - let(:type) { described_class.new(params) } + let(:type) { described_class.new(params) } - describe 'controler' do - context 'given :undef' do - let(:params) { extend_params({ :controller => :undef }) } - it do - expect { type }.to raise_error(ex_class, - 'Parameter controller failed on Jboss_securitydomain[spec-resourceadapter_spec]: Domain controller must be provided') - end - end + describe 'controler' do + describe 'given :undef' do + let(:params) { extend_params(:controller => :undef) } + it do + expect { type }.to raise_error( + ex_class, + 'Parameter controller failed on Jboss_securitydomain[spec-resourceadapter_spec]: Domain controller must be provided' + ) + end end + end end