From e1d5e6a781f8f1db609e2274ed0de6ebf700acca Mon Sep 17 00:00:00 2001 From: david22swan Date: Fri, 21 Apr 2023 10:05:46 +0100 Subject: [PATCH 01/18] (CONT-773) PDK Update --- Rakefile | 1 - metadata.json | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index 8fdf11b998..4477dcbc56 100644 --- a/Rakefile +++ b/Rakefile @@ -4,7 +4,6 @@ require 'bundler' require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-syntax/tasks/puppet-syntax' -require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any? require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any? diff --git a/metadata.json b/metadata.json index 0565eaa205..dd61423405 100644 --- a/metadata.json +++ b/metadata.json @@ -37,6 +37,6 @@ } ], "template-url": "https://github.com/puppetlabs/pdk-templates.git#main", - "template-ref": "tags/2.7.3-0-g8f110f1", - "pdk-version": "2.7.0 (8)" + "template-ref": "heads/main-0-ge5b0114", + "pdk-version": "2.7.1" } From 25604e69e9de1e2a5e895a74c5959eda16ca3453 Mon Sep 17 00:00:00 2001 From: david22swan Date: Fri, 21 Apr 2023 10:06:24 +0100 Subject: [PATCH 02/18] (CONT-773) Add Support for Puppet 8 / Remove Support for Puppet 6 --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index dd61423405..076f068de1 100644 --- a/metadata.json +++ b/metadata.json @@ -33,7 +33,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 6.24.0 < 8.0.0" + "version_requirement": ">= 7.0.0 < 9.0.0" } ], "template-url": "https://github.com/puppetlabs/pdk-templates.git#main", From ba56c173554d0806ae6afa00f3337a168474132a Mon Sep 17 00:00:00 2001 From: david22swan Date: Fri, 21 Apr 2023 10:07:06 +0100 Subject: [PATCH 03/18] (CONT-773) Re-pin puppet_agent --- .fixtures.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.fixtures.yml b/.fixtures.yml index 1cfbdc361e..7e9bfa941f 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -5,7 +5,7 @@ fixtures: facts: 'https://github.com/puppetlabs/puppetlabs-facts.git' puppet_agent: repo: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git' - ref: v4.12.1 + ref: v4.13.0 provision: 'https://github.com/puppetlabs/provision.git' symlinks: "apt": "#{source_dir}" From 88a921c82338c0116c3cadf0623e67f9dd899a3f Mon Sep 17 00:00:00 2001 From: david22swan Date: Fri, 21 Apr 2023 10:14:12 +0100 Subject: [PATCH 04/18] (CONT-773) Update Rubocop Versions New Versions: rubocop = 1.48.1 rubocop-performance = 1.16.0 rubocop-rspec = 2.19.0 --- .rubocop.yml | 447 +--------------------------------------------- .rubocop_todo.yml | 359 ++++++++++++++++++++++++++++++++++++- Gemfile | 6 +- 3 files changed, 369 insertions(+), 443 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 31e8248ff8..2dbf4503f8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,10 +1,15 @@ --- +inherit_from: .rubocop_todo.yml + require: - rubocop-performance - rubocop-rspec AllCops: + NewCops: enable DisplayCopNames: true - TargetRubyVersion: '2.5' + ExtraDetails: true + DisplayStyleGuide: true + TargetRubyVersion: '2.7' Include: - "**/*.rb" Exclude: @@ -79,441 +84,7 @@ Style/Documentation: - spec/**/* Style/WordArray: EnforcedStyle: brackets -Performance/AncestorsInclude: - Enabled: true -Performance/BigDecimalWithNumericArgument: - Enabled: true -Performance/BlockGivenWithExplicitBlock: - Enabled: true -Performance/CaseWhenSplat: - Enabled: true -Performance/ConstantRegexp: - Enabled: true -Performance/MethodObjectAsBlock: - Enabled: true -Performance/RedundantSortBlock: - Enabled: true -Performance/RedundantStringChars: - Enabled: true -Performance/ReverseFirst: - Enabled: true -Performance/SortReverse: - Enabled: true -Performance/Squeeze: - Enabled: true -Performance/StringInclude: - Enabled: true -Performance/Sum: - Enabled: true -Style/CollectionMethods: - Enabled: true -Style/MethodCalledOnDoEndBlock: - Enabled: true -Style/StringMethods: - Enabled: true -Bundler/InsecureProtocolSource: - Enabled: false -Gemspec/DuplicatedAssignment: - Enabled: false -Gemspec/OrderedDependencies: - Enabled: false -Gemspec/RequiredRubyVersion: - Enabled: false -Gemspec/RubyVersionGlobalsUsage: - Enabled: false -Layout/ArgumentAlignment: - Enabled: false -Layout/BeginEndAlignment: - Enabled: false -Layout/ClosingHeredocIndentation: - Enabled: false -Layout/EmptyComment: - Enabled: false -Layout/EmptyLineAfterGuardClause: - Enabled: false -Layout/EmptyLinesAroundArguments: - Enabled: false -Layout/EmptyLinesAroundAttributeAccessor: - Enabled: false -Layout/EndOfLine: - Enabled: false -Layout/FirstArgumentIndentation: - Enabled: false -Layout/HashAlignment: - Enabled: false -Layout/HeredocIndentation: - Enabled: false -Layout/LeadingEmptyLines: - Enabled: false -Layout/SpaceAroundMethodCallOperator: - Enabled: false -Layout/SpaceInsideArrayLiteralBrackets: - Enabled: false -Layout/SpaceInsideReferenceBrackets: - Enabled: false -Lint/BigDecimalNew: - Enabled: false -Lint/BooleanSymbol: - Enabled: false -Lint/ConstantDefinitionInBlock: - Enabled: false -Lint/DeprecatedOpenSSLConstant: - Enabled: false -Lint/DisjunctiveAssignmentInConstructor: - Enabled: false -Lint/DuplicateElsifCondition: - Enabled: false -Lint/DuplicateRequire: - Enabled: false -Lint/DuplicateRescueException: - Enabled: false -Lint/EmptyConditionalBody: - Enabled: false -Lint/EmptyFile: - Enabled: false -Lint/ErbNewArguments: - Enabled: false -Lint/FloatComparison: - Enabled: false -Lint/HashCompareByIdentity: - Enabled: false -Lint/IdentityComparison: - Enabled: false -Lint/InterpolationCheck: - Enabled: false -Lint/MissingCopEnableDirective: - Enabled: false -Lint/MixedRegexpCaptureTypes: - Enabled: false -Lint/NestedPercentLiteral: - Enabled: false -Lint/NonDeterministicRequireOrder: - Enabled: false -Lint/OrderedMagicComments: - Enabled: false -Lint/OutOfRangeRegexpRef: - Enabled: false -Lint/RaiseException: - Enabled: false -Lint/RedundantCopEnableDirective: - Enabled: false -Lint/RedundantRequireStatement: - Enabled: false -Lint/RedundantSafeNavigation: - Enabled: false -Lint/RedundantWithIndex: - Enabled: false -Lint/RedundantWithObject: - Enabled: false -Lint/RegexpAsCondition: - Enabled: false -Lint/ReturnInVoidContext: - Enabled: false -Lint/SafeNavigationConsistency: - Enabled: false -Lint/SafeNavigationWithEmpty: - Enabled: false -Lint/SelfAssignment: - Enabled: false -Lint/SendWithMixinArgument: - Enabled: false -Lint/ShadowedArgument: - Enabled: false -Lint/StructNewOverride: - Enabled: false -Lint/ToJSON: - Enabled: false -Lint/TopLevelReturnWithArgument: - Enabled: false -Lint/TrailingCommaInAttributeDeclaration: - Enabled: false -Lint/UnreachableLoop: - Enabled: false -Lint/UriEscapeUnescape: - Enabled: false -Lint/UriRegexp: - Enabled: false -Lint/UselessMethodDefinition: - Enabled: false -Lint/UselessTimes: - Enabled: false -Metrics/AbcSize: - Enabled: false -Metrics/BlockLength: - Enabled: false -Metrics/BlockNesting: - Enabled: false -Metrics/ClassLength: - Enabled: false -Metrics/CyclomaticComplexity: - Enabled: false -Metrics/MethodLength: - Enabled: false -Metrics/ModuleLength: - Enabled: false -Metrics/ParameterLists: - Enabled: false -Metrics/PerceivedComplexity: - Enabled: false -Migration/DepartmentName: - Enabled: false -Naming/AccessorMethodName: - Enabled: false -Naming/BlockParameterName: - Enabled: false -Naming/HeredocDelimiterCase: - Enabled: false -Naming/HeredocDelimiterNaming: - Enabled: false -Naming/MemoizedInstanceVariableName: - Enabled: false -Naming/MethodParameterName: - Enabled: false -Naming/RescuedExceptionsVariableName: - Enabled: false -Naming/VariableNumber: - Enabled: false -Performance/BindCall: - Enabled: false -Performance/DeletePrefix: - Enabled: false -Performance/DeleteSuffix: - Enabled: false -Performance/InefficientHashSearch: - Enabled: false -Performance/UnfreezeString: - Enabled: false -Performance/UriDefaultParser: - Enabled: false -RSpec/Be: - Enabled: false -RSpec/Capybara/CurrentPathExpectation: - Enabled: false -RSpec/Capybara/FeatureMethods: - Enabled: false -RSpec/Capybara/VisibilityMatcher: - Enabled: false -RSpec/ContextMethod: - Enabled: false -RSpec/ContextWording: - Enabled: false -RSpec/DescribeClass: - Enabled: false -RSpec/EmptyHook: - Enabled: false -RSpec/EmptyLineAfterExample: - Enabled: false -RSpec/EmptyLineAfterExampleGroup: - Enabled: false -RSpec/EmptyLineAfterHook: - Enabled: false -RSpec/ExampleLength: - Enabled: false -RSpec/ExampleWithoutDescription: - Enabled: false -RSpec/ExpectChange: - Enabled: false -RSpec/ExpectInHook: - Enabled: false -RSpec/FactoryBot/AttributeDefinedStatically: - Enabled: false -RSpec/FactoryBot/CreateList: - Enabled: false -RSpec/FactoryBot/FactoryClassName: - Enabled: false -RSpec/HooksBeforeExamples: - Enabled: false -RSpec/ImplicitBlockExpectation: - Enabled: false -RSpec/ImplicitSubject: - Enabled: false -RSpec/LeakyConstantDeclaration: - Enabled: false -RSpec/LetBeforeExamples: - Enabled: false -RSpec/MissingExampleGroupArgument: - Enabled: false RSpec/MultipleExpectations: - Enabled: false -RSpec/MultipleMemoizedHelpers: - Enabled: false -RSpec/MultipleSubjects: - Enabled: false -RSpec/NestedGroups: - Enabled: false -RSpec/PredicateMatcher: - Enabled: false -RSpec/ReceiveCounts: - Enabled: false -RSpec/ReceiveNever: - Enabled: false -RSpec/RepeatedExampleGroupBody: - Enabled: false -RSpec/RepeatedExampleGroupDescription: - Enabled: false -RSpec/RepeatedIncludeExample: - Enabled: false -RSpec/ReturnFromStub: - Enabled: false -RSpec/SharedExamples: - Enabled: false -RSpec/StubbedMock: - Enabled: false -RSpec/UnspecifiedException: - Enabled: false -RSpec/VariableDefinition: - Enabled: false -RSpec/VoidExpect: - Enabled: false -RSpec/Yield: - Enabled: false -Security/Open: - Enabled: false -Style/AccessModifierDeclarations: - Enabled: false -Style/AccessorGrouping: - Enabled: false -Style/AsciiComments: - Enabled: false -Style/BisectedAttrAccessor: - Enabled: false -Style/CaseLikeIf: - Enabled: false -Style/ClassEqualityComparison: - Enabled: false -Style/ColonMethodDefinition: - Enabled: false -Style/CombinableLoops: - Enabled: false -Style/CommentedKeyword: - Enabled: false -Style/Dir: - Enabled: false -Style/DoubleCopDisableDirective: - Enabled: false -Style/EmptyBlockParameter: - Enabled: false -Style/EmptyLambdaParameter: - Enabled: false -Style/Encoding: - Enabled: false -Style/EvalWithLocation: - Enabled: false -Style/ExpandPathArguments: - Enabled: false -Style/ExplicitBlockArgument: - Enabled: false -Style/ExponentialNotation: - Enabled: false -Style/FloatDivision: - Enabled: false -Style/FrozenStringLiteralComment: - Enabled: false -Style/GlobalStdStream: - Enabled: false -Style/HashAsLastArrayItem: - Enabled: false -Style/HashLikeCase: - Enabled: false -Style/HashTransformKeys: - Enabled: false -Style/HashTransformValues: - Enabled: false -Style/IfUnlessModifier: - Enabled: false -Style/KeywordParametersOrder: - Enabled: false -Style/MinMax: - Enabled: false -Style/MixinUsage: - Enabled: false -Style/MultilineWhenThen: - Enabled: false -Style/NegatedUnless: - Enabled: false -Style/NumericPredicate: - Enabled: false -Style/OptionalBooleanParameter: - Enabled: false -Style/OrAssignment: - Enabled: false -Style/RandomWithOffset: - Enabled: false -Style/RedundantAssignment: - Enabled: false -Style/RedundantCondition: - Enabled: false -Style/RedundantConditional: - Enabled: false -Style/RedundantFetchBlock: - Enabled: false -Style/RedundantFileExtensionInRequire: - Enabled: false -Style/RedundantRegexpCharacterClass: - Enabled: false -Style/RedundantRegexpEscape: - Enabled: false -Style/RedundantSelfAssignment: - Enabled: false -Style/RedundantSort: - Enabled: false -Style/RescueStandardError: - Enabled: false -Style/SingleArgumentDig: - Enabled: false -Style/SlicingWithRange: - Enabled: false -Style/SoleNestedConditional: - Enabled: false -Style/StderrPuts: - Enabled: false -Style/StringConcatenation: - Enabled: false -Style/Strip: - Enabled: false -Style/SymbolProc: - Enabled: false -Style/TrailingBodyOnClass: - Enabled: false -Style/TrailingBodyOnMethodDefinition: - Enabled: false -Style/TrailingBodyOnModule: - Enabled: false -Style/TrailingCommaInHashLiteral: - Enabled: false -Style/TrailingMethodEndStatement: - Enabled: false -Style/UnpackFirst: - Enabled: false -Lint/DuplicateBranch: - Enabled: false -Lint/DuplicateRegexpCharacterClassElement: - Enabled: false -Lint/EmptyBlock: - Enabled: false -Lint/EmptyClass: - Enabled: false -Lint/NoReturnInBeginEndBlocks: - Enabled: false -Lint/ToEnumArguments: - Enabled: false -Lint/UnexpectedBlockArity: - Enabled: false -Lint/UnmodifiedReduceAccumulator: - Enabled: false -Performance/CollectionLiteralInLoop: - Enabled: false -Style/ArgumentsForwarding: - Enabled: false -Style/CollectionCompact: - Enabled: false -Style/DocumentDynamicEvalDefinition: - Enabled: false -Style/NegatedIfElseCondition: - Enabled: false -Style/NilLambda: - Enabled: false -Style/RedundantArgument: - Enabled: false -Style/SwapValues: - Enabled: false + Max: 3 +Naming/MethodParameterName: + AllowedNames: 'is' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 23d36faa4d..b938048e16 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,2 +1,357 @@ -GetText/DecorateString: - Enabled: false \ No newline at end of file +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2023-04-21 09:13:34 UTC using RuboCop version 1.48.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: 32 +# This cop supports safe autocorrection (--autocorrect). +Layout/ClosingHeredocIndentation: + Exclude: + - 'spec/acceptance/apt_key_provider_spec.rb' + - 'spec/acceptance/apt_spec.rb' + - 'spec/spec_helper_acceptance_local.rb' + - 'spec/unit/puppet/provider/apt_key_spec.rb' + +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +Layout/EmptyLineAfterGuardClause: + Exclude: + - 'lib/facter/apt_updates.rb' + - 'lib/puppet/provider/apt_key/apt_key.rb' + - 'lib/puppet/type/apt_key.rb' + - 'spec/spec_helper_acceptance_local.rb' + - 'tasks/init.rb' + +# Offense count: 57 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/HashAlignment: + Exclude: + - 'spec/classes/apt_spec.rb' + - 'spec/classes/apt_update_spec.rb' + - 'spec/defines/conf_spec.rb' + - 'spec/defines/pin_spec.rb' + - 'spec/defines/source_compat_spec.rb' + - 'spec/defines/source_spec.rb' + - 'spec/unit/puppet/provider/apt_key_spec.rb' + - 'spec/unit/puppet/type/apt_key_spec.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Layout/HeredocIndentation: + Exclude: + - 'spec/spec_helper_acceptance_local.rb' + - 'spec/unit/puppet/provider/apt_key_spec.rb' + +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). +Layout/SpaceAroundMethodCallOperator: + Exclude: + - 'spec/defines/key_compat_spec.rb' + - 'spec/defines/key_spec.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Lint/BooleanSymbol: + Exclude: + - 'spec/unit/puppet/type/apt_key_spec.rb' + +# Offense count: 3 +# Configuration parameters: AllowedMethods. +# AllowedMethods: enums +Lint/ConstantDefinitionInBlock: + Exclude: + - 'spec/defines/key_compat_spec.rb' + - 'spec/defines/source_compat_spec.rb' + - 'spec/defines/source_spec.rb' + +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: strict, consistent +Lint/SymbolConversion: + Exclude: + - 'spec/classes/apt_update_spec.rb' + +# Offense count: 6 +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. +Metrics/AbcSize: + Max: 40 + +# Offense count: 3 +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. +# AllowedMethods: refine +Metrics/BlockLength: + Max: 180 + +# Offense count: 3 +# Configuration parameters: AllowedMethods, AllowedPatterns. +Metrics/CyclomaticComplexity: + Max: 11 + +# Offense count: 8 +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. +Metrics/MethodLength: + Max: 39 + +# Offense count: 3 +# Configuration parameters: AllowedMethods, AllowedPatterns. +Metrics/PerceivedComplexity: + Max: 12 + +# Offense count: 1 +# Configuration parameters: MinSize. +Performance/CollectionLiteralInLoop: + Exclude: + - 'spec/classes/apt_update_spec.rb' + +# Offense count: 6 +# This cop supports unsafe autocorrection (--autocorrect-all). +RSpec/BeEq: + Exclude: + - 'spec/unit/facter/apt_reboot_required_spec.rb' + - 'spec/unit/puppet/type/apt_key_spec.rb' + +# Offense count: 8 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: be, be_nil +RSpec/BeNil: + Exclude: + - 'spec/unit/facter/apt_dist_package_security_updates_spec.rb' + - 'spec/unit/facter/apt_dist_package_updates_spec.rb' + - 'spec/unit/facter/apt_dist_security_updates_spec.rb' + - 'spec/unit/facter/apt_dist_updates_spec.rb' + - 'spec/unit/facter/apt_package_security_updates_spec.rb' + - 'spec/unit/facter/apt_package_updates_spec.rb' + - 'spec/unit/facter/apt_security_updates_spec.rb' + - 'spec/unit/facter/apt_updates_spec.rb' + +# Offense count: 6 +# Configuration parameters: Prefixes, AllowedPatterns. +# Prefixes: when, with, without +RSpec/ContextWording: + Exclude: + - 'spec/classes/apt_spec.rb' + - 'spec/classes/apt_update_spec.rb' + - 'spec/unit/puppet/provider/apt_key_spec.rb' + +# Offense count: 32 +# Configuration parameters: IgnoredMetadata. +RSpec/DescribeClass: + Enabled: false + +# Offense count: 23 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowConsecutiveOneLiners. +RSpec/EmptyLineAfterExample: + Exclude: + - 'spec/acceptance/apt_key_provider_spec.rb' + - 'spec/acceptance/apt_spec.rb' + - 'spec/classes/apt_spec.rb' + - 'spec/defines/key_compat_spec.rb' + - 'spec/defines/key_spec.rb' + - 'spec/defines/pin_spec.rb' + - 'spec/defines/ppa_spec.rb' + - 'spec/defines/source_spec.rb' + +# Offense count: 39 +# This cop supports safe autocorrection (--autocorrect). +RSpec/EmptyLineAfterExampleGroup: + Exclude: + - 'spec/acceptance/apt_key_provider_spec.rb' + - 'spec/acceptance/init_task_spec.rb' + - 'spec/classes/apt_backports_spec.rb' + - 'spec/classes/apt_spec.rb' + - 'spec/classes/apt_update_spec.rb' + - 'spec/defines/key_compat_spec.rb' + - 'spec/defines/key_spec.rb' + - 'spec/defines/source_spec.rb' + +# Offense count: 24 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowConsecutiveOneLiners. +RSpec/EmptyLineAfterHook: + Exclude: + - 'spec/acceptance/apt_key_provider_spec.rb' + - 'spec/unit/facter/apt_dist_has_updates_spec.rb' + - 'spec/unit/facter/apt_dist_package_security_updates_spec.rb' + - 'spec/unit/facter/apt_dist_package_updates_spec.rb' + - 'spec/unit/facter/apt_dist_security_updates_spec.rb' + - 'spec/unit/facter/apt_dist_updates_spec.rb' + - 'spec/unit/facter/apt_has_updates_spec.rb' + - 'spec/unit/facter/apt_package_security_updates_spec.rb' + - 'spec/unit/facter/apt_package_updates_spec.rb' + - 'spec/unit/facter/apt_reboot_required_spec.rb' + - 'spec/unit/facter/apt_security_updates_spec.rb' + - 'spec/unit/facter/apt_updates_spec.rb' + - 'spec/unit/puppet/provider/apt_key_spec.rb' + +# Offense count: 13 +# Configuration parameters: CountAsOne. +RSpec/ExampleLength: + Max: 15 + +# Offense count: 10 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples. +# DisallowedExamples: works +RSpec/ExampleWording: + Exclude: + - 'spec/acceptance/apt_key_provider_spec.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +RSpec/ExcessiveDocstringSpacing: + Exclude: + - 'spec/defines/key_compat_spec.rb' + - 'spec/defines/setting_spec.rb' + +# Offense count: 204 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: single_line_only, single_statement_only, disallow, require_implicit +RSpec/ImplicitSubject: + Exclude: + - 'spec/classes/apt_backports_spec.rb' + - 'spec/classes/apt_spec.rb' + - 'spec/classes/apt_update_spec.rb' + - 'spec/defines/conf_spec.rb' + - 'spec/defines/key_compat_spec.rb' + - 'spec/defines/key_spec.rb' + - 'spec/defines/mark_spec.rb' + - 'spec/defines/pin_spec.rb' + - 'spec/defines/ppa_spec.rb' + - 'spec/defines/setting_spec.rb' + - 'spec/defines/source_compat_spec.rb' + - 'spec/defines/source_spec.rb' + - 'spec/unit/facter/apt_update_last_success_spec.rb' + +# Offense count: 3 +RSpec/LeakyConstantDeclaration: + Exclude: + - 'spec/defines/key_compat_spec.rb' + - 'spec/defines/source_compat_spec.rb' + - 'spec/defines/source_spec.rb' + +# Offense count: 4 +RSpec/MultipleExpectations: + Max: 5 + +# Offense count: 3 +# Configuration parameters: AllowSubject. +RSpec/MultipleMemoizedHelpers: + Max: 6 + +# Offense count: 2 +# Configuration parameters: AllowedGroups. +RSpec/NestedGroups: + Max: 4 + +# Offense count: 24 +# Configuration parameters: AllowedPatterns. +# AllowedPatterns: ^expect_, ^assert_ +RSpec/NoExpectationExample: + Exclude: + - 'spec/acceptance/01_apt_class_spec.rb' + - 'spec/acceptance/apt_backports_spec.rb' + - 'spec/acceptance/apt_key_provider_spec.rb' + - 'spec/acceptance/apt_spec.rb' + +# Offense count: 4 +RSpec/RepeatedExampleGroupDescription: + Exclude: + - 'spec/acceptance/apt_spec.rb' + - 'spec/classes/apt_spec.rb' + +# Offense count: 3 +RSpec/StubbedMock: + Exclude: + - 'spec/unit/puppet/provider/apt_key_spec.rb' + +# Offense count: 2 +Security/Open: + Exclude: + - 'lib/puppet/provider/apt_key/apt_key.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: MinBranchesCount. +Style/CaseLikeIf: + Exclude: + - 'lib/puppet/provider/apt_key/apt_key.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/GlobalStdStream: + Exclude: + - 'tasks/init.rb' + +# Offense count: 10 +# This cop supports safe autocorrection (--autocorrect). +Style/IfUnlessModifier: + Exclude: + - 'lib/facter/apt_updates.rb' + - 'lib/puppet/provider/apt_key/apt_key.rb' + - 'lib/puppet/type/apt_key.rb' + +# Offense count: 1 +Style/MixinUsage: + Exclude: + - 'spec/spec_helper.rb' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: same_as_string_literals, single_quotes, double_quotes +Style/QuotedSymbols: + Exclude: + - 'spec/unit/puppet/provider/apt_key_spec.rb' + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantRegexpEscape: + Exclude: + - 'lib/puppet/type/apt_key.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: implicit, explicit +Style/RescueStandardError: + Exclude: + - 'spec/spec_helper.rb' + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/SlicingWithRange: + Exclude: + - 'lib/puppet/provider/apt_key/apt_key.rb' + +# Offense count: 338 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInHashLiteral: + Exclude: + - 'lib/puppet/provider/apt_key/apt_key.rb' + - 'spec/classes/apt_backports_spec.rb' + - 'spec/classes/apt_spec.rb' + - 'spec/classes/apt_update_spec.rb' + - 'spec/defines/conf_spec.rb' + - 'spec/defines/key_compat_spec.rb' + - 'spec/defines/key_spec.rb' + - 'spec/defines/mark_spec.rb' + - 'spec/defines/pin_spec.rb' + - 'spec/defines/ppa_spec.rb' + - 'spec/defines/setting_spec.rb' + - 'spec/defines/source_compat_spec.rb' + - 'spec/defines/source_spec.rb' + - 'spec/spec_helper.rb' + - 'spec/unit/puppet/provider/apt_key_spec.rb' diff --git a/Gemfile b/Gemfile index 8456bee1c3..3f6f5c7d55 100644 --- a/Gemfile +++ b/Gemfile @@ -30,9 +30,9 @@ group :development do gem "pry", '~> 0.10', require: false gem "simplecov-console", '~> 0.5', require: false gem "puppet-debugger", '~> 1.0', require: false - gem "rubocop", '= 1.6.1', require: false - gem "rubocop-performance", '= 1.9.1', require: false - gem "rubocop-rspec", '= 2.0.1', require: false + gem "rubocop", '= 1.48.1', require: false + gem "rubocop-performance", '= 1.16.0', require: false + gem "rubocop-rspec", '= 2.19.0', require: false gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] gem "github_changelog_generator", '= 1.15.2', require: false end From 5fede72d6c12749d2fcd8212e937e2cb2453345f Mon Sep 17 00:00:00 2001 From: david22swan Date: Fri, 21 Apr 2023 13:35:15 +0100 Subject: [PATCH 05/18] (CONT-773) Rubocop Manual Fix 1 - RSpec/MultipleExpectations --- .rubocop_todo.yml | 4 ---- spec/unit/puppet/provider/apt_key_spec.rb | 8 ++++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b938048e16..8aff4598c9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -240,10 +240,6 @@ RSpec/LeakyConstantDeclaration: - 'spec/defines/source_compat_spec.rb' - 'spec/defines/source_spec.rb' -# Offense count: 4 -RSpec/MultipleExpectations: - Max: 5 - # Offense count: 3 # Configuration parameters: AllowSubject. RSpec/MultipleMemoizedHelpers: diff --git a/spec/unit/puppet/provider/apt_key_spec.rb b/spec/unit/puppet/provider/apt_key_spec.rb index b895817014..970f7e148e 100644 --- a/spec/unit/puppet/provider/apt_key_spec.rb +++ b/spec/unit/puppet/provider/apt_key_spec.rb @@ -43,7 +43,7 @@ ['adv', '--no-tty', '--list-keys', '--with-colons', '--fingerprint', '--fixed-list-mode'], ).and_return(command_output) end - it 'returns 2 resources' do + it 'returns 2 resources' do # rubocop:disable RSpec/MultipleExpectations expect(described_class.instances.size).to eq(2) expect(described_class.instances[0].name).to eq('630239CC130E1A7FD81A27B140976EAF437D05B5') expect(described_class.instances[0].id).to eq('40976EAF437D05B5') @@ -88,7 +88,7 @@ expect(provider).to be_exist end - it 'apt_key with content set' do + it 'apt_key with content set' do # rubocop:disable RSpec/MultipleExpectations expect(described_class).to receive(:apt_key).with(array_including('add', kind_of(String))) resource = Puppet::Type::Apt_key.new(name: 'gsd', id: 'C105B9DE', @@ -102,7 +102,7 @@ expect(provider).to be_exist end - it 'apt_key with source set' do + it 'apt_key with source set' do # rubocop:disable RSpec/MultipleExpectations expect(described_class).to receive(:apt_key).with(array_including('add', kind_of(String))) resource = Puppet::Type::Apt_key.new(name: 'gsd', id: 'C105B9DE', @@ -116,7 +116,7 @@ expect(provider).to be_exist end - it 'apt_key with source and weak ssl verify set' do + it 'apt_key with source and weak ssl verify set' do # rubocop:disable RSpec/MultipleExpectations expect(described_class).to receive(:apt_key).with(array_including('add', kind_of(String))) resource = Puppet::Type::Apt_key.new(name: 'gsd', id: 'C105B9DE', From a4609826c3dc663c2ebb5402ffe7b8a1ea1ecd4f Mon Sep 17 00:00:00 2001 From: david22swan Date: Fri, 21 Apr 2023 13:42:23 +0100 Subject: [PATCH 06/18] (CONT-773) Rubocop Auto Fixes 1-5 - Layout/ClosingHeredocIndentation - Layout/EmptyLineAfterGuardClause - Layout/HashAlignment - Layout/HeredocIndentation - Layout/SpaceAroundMethodCallOperator --- .rubocop_todo.yml | 50 ------------------- lib/facter/apt_updates.rb | 1 + lib/puppet/provider/apt_key/apt_key.rb | 1 + lib/puppet/type/apt_key.rb | 1 + spec/acceptance/apt_key_provider_spec.rb | 58 +++++++++++------------ spec/acceptance/apt_spec.rb | 2 +- spec/classes/apt_spec.rb | 18 +++---- spec/classes/apt_update_spec.rb | 8 ++-- spec/defines/conf_spec.rb | 10 ++-- spec/defines/key_compat_spec.rb | 6 +-- spec/defines/key_spec.rb | 6 +-- spec/defines/pin_spec.rb | 30 ++++++------ spec/defines/source_compat_spec.rb | 28 +++++------ spec/defines/source_spec.rb | 4 +- spec/spec_helper_acceptance_local.rb | 11 +++-- spec/unit/puppet/provider/apt_key_spec.rb | 28 +++++------ spec/unit/puppet/type/apt_key_spec.rb | 8 ++-- tasks/init.rb | 1 + 18 files changed, 113 insertions(+), 158 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8aff4598c9..31aae81836 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,56 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 32 -# This cop supports safe autocorrection (--autocorrect). -Layout/ClosingHeredocIndentation: - Exclude: - - 'spec/acceptance/apt_key_provider_spec.rb' - - 'spec/acceptance/apt_spec.rb' - - 'spec/spec_helper_acceptance_local.rb' - - 'spec/unit/puppet/provider/apt_key_spec.rb' - -# Offense count: 5 -# This cop supports safe autocorrection (--autocorrect). -Layout/EmptyLineAfterGuardClause: - Exclude: - - 'lib/facter/apt_updates.rb' - - 'lib/puppet/provider/apt_key/apt_key.rb' - - 'lib/puppet/type/apt_key.rb' - - 'spec/spec_helper_acceptance_local.rb' - - 'tasks/init.rb' - -# Offense count: 57 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. -# SupportedHashRocketStyles: key, separator, table -# SupportedColonStyles: key, separator, table -# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit -Layout/HashAlignment: - Exclude: - - 'spec/classes/apt_spec.rb' - - 'spec/classes/apt_update_spec.rb' - - 'spec/defines/conf_spec.rb' - - 'spec/defines/pin_spec.rb' - - 'spec/defines/source_compat_spec.rb' - - 'spec/defines/source_spec.rb' - - 'spec/unit/puppet/provider/apt_key_spec.rb' - - 'spec/unit/puppet/type/apt_key_spec.rb' - -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -Layout/HeredocIndentation: - Exclude: - - 'spec/spec_helper_acceptance_local.rb' - - 'spec/unit/puppet/provider/apt_key_spec.rb' - -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -Layout/SpaceAroundMethodCallOperator: - Exclude: - - 'spec/defines/key_compat_spec.rb' - - 'spec/defines/key_spec.rb' - # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Lint/BooleanSymbol: diff --git a/lib/facter/apt_updates.rb b/lib/facter/apt_updates.rb index f261d2c165..3b46e2d63d 100644 --- a/lib/facter/apt_updates.rb +++ b/lib/facter/apt_updates.rb @@ -14,6 +14,7 @@ def get_updates(upgrade_option) apt_updates = [[], []] apt_get_result.each_line do |line| next unless %r{^Inst\s}.match?(line) + package = line.gsub(%r{^Inst\s([^\s]+)\s.*}, '\1').strip apt_updates[0].push(package) security_matches = [ diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index 115ed316de..9f461cc62c 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -120,6 +120,7 @@ def source_to_file(value) parsed_value = URI.parse(value) if parsed_value.scheme.nil? raise(_('The file %{_value} does not exist') % { _value: value }) unless File.exist?(value) + # Because the tempfile method has to return a live object to prevent GC # of the underlying file from occuring too early, we also have to return # a file object here. The caller can still call the #path method on the diff --git a/lib/puppet/type/apt_key.rb b/lib/puppet/type/apt_key.rb index c78ba8fb43..99be930e28 100644 --- a/lib/puppet/type/apt_key.rb +++ b/lib/puppet/type/apt_key.rb @@ -31,6 +31,7 @@ if self[:content] && self[:source] raise(_('The properties content and source are mutually exclusive.')) end + if self[:id].length < 40 warning(_('The id should be a full fingerprint (40 characters), see README.')) end diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb index ee4a4c8242..aa763405a3 100644 --- a/spec/acceptance/apt_key_provider_spec.rb +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -111,7 +111,7 @@ def apply_manifest_twice(manifest_pp) =cXcR -----END PGP PUBLIC KEY BLOCK-----' } - MANIFEST +MANIFEST gpg_key_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -170,7 +170,7 @@ def apply_manifest_twice(manifest_pp) =mMjt -----END PGP PUBLIC KEY BLOCK-----", } - MANIFEST +MANIFEST multiple_keys_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -423,7 +423,7 @@ def apply_manifest_twice(manifest_pp) =TREp -----END PGP PUBLIC KEY BLOCK----- ", } - MANIFEST +MANIFEST bogus_key_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -431,7 +431,7 @@ def apply_manifest_twice(manifest_pp) ensure => 'present', content => 'For posterity: such content, much bogus, wow', } - MANIFEST +MANIFEST hkp_pool_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -439,7 +439,7 @@ def apply_manifest_twice(manifest_pp) ensure => 'present', server => 'hkp://keyserver.ubuntu.com:80', } - MANIFEST +MANIFEST hkps_protocol_supported = host_inventory['facter']['os']['family'] =~ %r{Ubuntu}i && \ host_inventory['facter']['os']['release']['major'] =~ %r{^18\.04} @@ -451,7 +451,7 @@ def apply_manifest_twice(manifest_pp) ensure => 'present', server => 'hkps://keyserver.ubuntu.com', } - MANIFEST + MANIFEST end nonexistant_key_server_pp = <<-MANIFEST @@ -460,7 +460,7 @@ def apply_manifest_twice(manifest_pp) ensure => 'present', server => 'nonexistant.key.server', } - MANIFEST +MANIFEST dot_server_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -468,7 +468,7 @@ def apply_manifest_twice(manifest_pp) ensure => 'present', server => '.pgp.key.server', } - MANIFEST +MANIFEST http_works_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -476,7 +476,7 @@ def apply_manifest_twice(manifest_pp) ensure => 'present', source => 'http://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - MANIFEST +MANIFEST http_works_userinfo_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -484,7 +484,7 @@ def apply_manifest_twice(manifest_pp) ensure => 'present', source => 'http://dummyuser:dummypassword@#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - MANIFEST +MANIFEST four_oh_four_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -492,7 +492,7 @@ def apply_manifest_twice(manifest_pp) ensure => 'present', source => 'http://#{PUPPETLABS_APT_URL}/herpderp.gpg', } - MANIFEST +MANIFEST socket_error_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -500,7 +500,7 @@ def apply_manifest_twice(manifest_pp) ensure => 'present', source => 'http://apt.puppetlabss.com/herpderp.gpg', } - MANIFEST +MANIFEST ftp_works_pp = <<-MANIFEST apt_key { 'CentOS 6': @@ -508,7 +508,7 @@ def apply_manifest_twice(manifest_pp) ensure => 'present', source => 'ftp://#{CENTOS_REPO_URL}/#{CENTOS_GPG_KEY_FILE}', } - MANIFEST +MANIFEST ftp_550_pp = <<-MANIFEST apt_key { 'CentOS 6': @@ -516,7 +516,7 @@ def apply_manifest_twice(manifest_pp) ensure => 'present', source => 'ftp://#{CENTOS_REPO_URL}/herpderp.gpg', } - MANIFEST +MANIFEST ftp_socket_error_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -524,7 +524,7 @@ def apply_manifest_twice(manifest_pp) ensure => 'present', source => 'ftp://apt.puppetlabss.com/herpderp.gpg', } - MANIFEST +MANIFEST https_works_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -532,7 +532,7 @@ def apply_manifest_twice(manifest_pp) ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - MANIFEST +MANIFEST https_with_weak_ssl_works_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -541,7 +541,7 @@ def apply_manifest_twice(manifest_pp) source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', weak_ssl => true, } - MANIFEST +MANIFEST https_userinfo_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -549,7 +549,7 @@ def apply_manifest_twice(manifest_pp) ensure => 'present', source => 'https://dummyuser:dummypassword@#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - MANIFEST +MANIFEST https_404_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -557,7 +557,7 @@ def apply_manifest_twice(manifest_pp) ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/herpderp.gpg', } - MANIFEST +MANIFEST https_socket_error_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -565,7 +565,7 @@ def apply_manifest_twice(manifest_pp) ensure => 'present', source => 'https://apt.puppetlabss.com/herpderp.gpg', } - MANIFEST +MANIFEST path_exists_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -573,7 +573,7 @@ def apply_manifest_twice(manifest_pp) ensure => 'present', source => '/tmp/puppetlabs-pubkey.gpg', } - MANIFEST +MANIFEST path_does_not_exist_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -581,7 +581,7 @@ def apply_manifest_twice(manifest_pp) ensure => 'present', source => '/tmp/totally_bogus.file', } - MANIFEST +MANIFEST path_bogus_content_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -589,7 +589,7 @@ def apply_manifest_twice(manifest_pp) ensure => 'present', source => '/tmp/fake-key.gpg', } - MANIFEST +MANIFEST debug_works_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -597,7 +597,7 @@ def apply_manifest_twice(manifest_pp) ensure => 'present', options => 'debug', } - MANIFEST +MANIFEST fingerprint_match_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -605,7 +605,7 @@ def apply_manifest_twice(manifest_pp) ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - MANIFEST +MANIFEST fingerprint_does_not_match_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -613,7 +613,7 @@ def apply_manifest_twice(manifest_pp) ensure => 'present', source => 'https://#{PUPPETLABS_APT_URL}/#{PUPPETLABS_GPG_KEY_FILE}', } - MANIFEST +MANIFEST refresh_true_pp = <<-MANIFEST apt_key { '#{PUPPETLABS_EXP_KEY_LONG_ID}': @@ -621,7 +621,7 @@ def apply_manifest_twice(manifest_pp) ensure => 'present', refresh => true, } - MANIFEST +MANIFEST refresh_false_pp = <<-MANIFEST apt_key { '#{PUPPETLABS_EXP_KEY_LONG_ID}': @@ -657,14 +657,14 @@ def apply_manifest_twice(manifest_pp) id => '#{CENTOS_GPG_KEY_LONG_ID}', ensure => 'present', } - MANIFEST + MANIFEST ensure_absent_pp = <<-MANIFEST apt_key { 'centos': id => '#{CENTOS_GPG_KEY_LONG_ID}', ensure => 'absent', } - MANIFEST + MANIFEST it 'add an apt_key resource' do apply_manifest_twice(ensure_present_pp) diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb index 7e4fe3787b..35277bb591 100644 --- a/spec/acceptance/apt_spec.rb +++ b/spec/acceptance/apt_spec.rb @@ -29,7 +29,7 @@ class { 'apt': }, sources => $sources, } - MANIFEST +MANIFEST describe 'apt class' do context 'with reset' do diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 1a7513c44a..b7ef6b5d1c 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -482,17 +482,17 @@ let(:params) do { sources: { 'debian_unstable' => { - 'location' => 'http://debian.mirror.iweb.ca/debian/', - 'release' => 'unstable', - 'repos' => 'main contrib non-free', - 'key' => { 'id' => '150C8614919D8446E01E83AF9AA38DCD55BE302B', 'server' => 'subkeys.pgp.net' }, - 'pin' => '-10', - 'include' => { 'src' => true }, + 'location' => 'http://debian.mirror.iweb.ca/debian/', + 'release' => 'unstable', + 'repos' => 'main contrib non-free', + 'key' => { 'id' => '150C8614919D8446E01E83AF9AA38DCD55BE302B', 'server' => 'subkeys.pgp.net' }, + 'pin' => '-10', + 'include' => { 'src' => true }, }, 'puppetlabs' => { 'location' => 'http://apt.puppetlabs.com', - 'repos' => 'main', - 'key' => { 'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F', 'server' => 'pgp.mit.edu' }, + 'repos' => 'main', + 'key' => { 'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F', 'server' => 'pgp.mit.edu' }, }, } } end @@ -661,7 +661,7 @@ let(:params) do { pins: { 'stable' => { 'priority' => 600, 'order' => 50 }, - 'testing' => { 'priority' => 700, 'order' => 100 }, + 'testing' => { 'priority' => 700, 'order' => 100 }, } } end diff --git a/spec/classes/apt_update_spec.rb b/spec/classes/apt_update_spec.rb index 71774550f8..6ab9534c46 100644 --- a/spec/classes/apt_update_spec.rb +++ b/spec/classes/apt_update_spec.rb @@ -5,8 +5,8 @@ describe 'apt::update', type: :class do context "when apt::update['frequency']='always'" do { - 'a recent run' => Time.now.to_i, - 'we are due for a run' => 1_406_660_561, + 'a recent run' => Time.now.to_i, + 'we are due for a run' => 1_406_660_561, 'the update-success-stamp file does not exist' => -1, }.each_pair do |desc, factval| context "when $apt_update_last_success indicates #{desc}" do @@ -94,8 +94,8 @@ end context "when apt::update['frequency']='reluctantly'" do { - 'a recent run' => Time.now.to_i, - 'we are due for a run' => 1_406_660_561, + 'a recent run' => Time.now.to_i, + 'we are due for a run' => 1_406_660_561, 'the update-success-stamp file does not exist' => -1, }.each_pair do |desc, factval| context "when $apt_update_last_success indicates #{desc}" do diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index f1e42b5f67..04551b8e5d 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -42,9 +42,9 @@ it { is_expected.to contain_file(filename).with('ensure' => 'present', - 'content' => %r{Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;}, - 'owner' => 'root', - 'group' => 'root') + 'content' => %r{Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;}, + 'owner' => 'root', + 'group' => 'root') } context 'with notify_update = true (default)' do @@ -90,8 +90,8 @@ it { is_expected.to contain_file(filename).with('ensure' => 'absent', - 'owner' => 'root', - 'group' => 'root') + 'owner' => 'root', + 'group' => 'root') } end end diff --git a/spec/defines/key_compat_spec.rb b/spec/defines/key_compat_spec.rb index d477937552..2fb7e65638 100644 --- a/spec/defines/key_compat_spec.rb +++ b/spec/defines/key_compat_spec.rb @@ -170,7 +170,7 @@ def apt_key_example(title) end it 'fails' do - is_expected .to raise_error(%r{expects a match}) + is_expected.to raise_error(%r{expects a match}) end end @@ -182,7 +182,7 @@ def apt_key_example(title) end it 'fails' do - is_expected .to raise_error(%r{expects a match}) + is_expected.to raise_error(%r{expects a match}) end end @@ -194,7 +194,7 @@ def apt_key_example(title) end it 'fails' do - is_expected .to raise_error(%r{expects a match}) + is_expected.to raise_error(%r{expects a match}) end end context 'when url character limit is exceeded' do diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index fd63965f7b..8c8d503f6c 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -190,7 +190,7 @@ def absent_apt_key(title) end it 'fails' do - is_expected .to raise_error(%r{expects a match}) + is_expected.to raise_error(%r{expects a match}) end end @@ -202,7 +202,7 @@ def absent_apt_key(title) end it 'fails' do - is_expected .to raise_error(%r{expects a match}) + is_expected.to raise_error(%r{expects a match}) end end @@ -214,7 +214,7 @@ def absent_apt_key(title) end it 'fails' do - is_expected .to raise_error(%r{expects a match}) + is_expected.to raise_error(%r{expects a match}) end end context 'when character url exceeded' do diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index 5edc79cc6d..f22d92ac5a 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -31,7 +31,7 @@ let :params do { 'packages' => 'vim', - 'version' => '1', + 'version' => '1', } end @@ -42,7 +42,7 @@ let :params do { 'packages' => 'vim', - 'origin' => 'test', + 'origin' => 'test', } end @@ -52,15 +52,15 @@ context 'without defaults' do let :params do { - 'explanation' => 'foo', - 'order' => 99, - 'release' => '1', - 'codename' => 'bar', + 'explanation' => 'foo', + 'order' => 99, + 'release' => '1', + 'codename' => 'bar', 'release_version' => '2', - 'component' => 'baz', - 'originator' => 'foobar', - 'label' => 'foobaz', - 'priority' => 10, + 'component' => 'baz', + 'originator' => 'foobar', + 'label' => 'foobaz', + 'priority' => 10, } end @@ -116,7 +116,7 @@ context 'with packages == * and release and origin' do let :params do { - 'origin' => 'test', + 'origin' => 'test', 'release' => 'foo', } end @@ -129,8 +129,8 @@ context 'with specific release and origin' do let :params do { - 'release' => 'foo', - 'origin' => 'test', + 'release' => 'foo', + 'origin' => 'test', 'packages' => 'vim', } end @@ -143,8 +143,8 @@ context 'with specific version and origin' do let :params do { - 'version' => '1', - 'origin' => 'test', + 'version' => '1', + 'origin' => 'test', 'packages' => 'vim', } end diff --git a/spec/defines/source_compat_spec.rb b/spec/defines/source_compat_spec.rb index d7dfb78695..7eef4fd23e 100644 --- a/spec/defines/source_compat_spec.rb +++ b/spec/defines/source_compat_spec.rb @@ -42,14 +42,14 @@ context 'with no defaults' do let :params do { - 'comment' => 'foo', - 'location' => 'http://debian.mirror.iweb.ca/debian/', - 'release' => 'sid', - 'repos' => 'testing', - 'include' => { 'src' => false }, - 'key' => GPG_KEY_ID, - 'pin' => '10', - 'architecture' => 'x86_64', + 'comment' => 'foo', + 'location' => 'http://debian.mirror.iweb.ca/debian/', + 'release' => 'sid', + 'repos' => 'testing', + 'include' => { 'src' => false }, + 'key' => GPG_KEY_ID, + 'pin' => '10', + 'architecture' => 'x86_64', 'allow_unsigned' => true, } end @@ -62,7 +62,7 @@ it { is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present', 'priority' => '10', - 'origin' => 'debian.mirror.iweb.ca') + 'origin' => 'debian.mirror.iweb.ca') } it { @@ -74,8 +74,8 @@ context 'when allow_insecure true' do let :params do { - 'include' => { 'src' => false }, - 'location' => 'http://debian.mirror.iweb.ca/debian/', + 'include' => { 'src' => false }, + 'location' => 'http://debian.mirror.iweb.ca/debian/', 'allow_insecure' => true, } end @@ -86,8 +86,8 @@ context 'when allow_unsigned true' do let :params do { - 'include' => { 'src' => false }, - 'location' => 'http://debian.mirror.iweb.ca/debian/', + 'include' => { 'src' => false }, + 'location' => 'http://debian.mirror.iweb.ca/debian/', 'allow_unsigned' => true, } end @@ -98,7 +98,7 @@ context 'with architecture equals x86_64' do let :params do { - 'location' => 'http://debian.mirror.iweb.ca/debian/', + 'location' => 'http://debian.mirror.iweb.ca/debian/', 'architecture' => 'x86_64', } end diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 641089568e..e5df79febc 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -53,7 +53,7 @@ location: 'hello.there', pin: { 'release' => 'wishwash', 'explanation' => 'wishwash', - 'priority' => 1001 }, + 'priority' => 1001 }, } end @@ -114,7 +114,7 @@ 'id' => GPG_KEY_ID, 'server' => 'pgp.mit.edu', 'content' => 'GPG key content', - 'source' => 'http://apt.puppetlabs.com/pubkey.gpg', + 'source' => 'http://apt.puppetlabs.com/pubkey.gpg', 'weak_ssl' => true, }, pin: '10', diff --git a/spec/spec_helper_acceptance_local.rb b/spec/spec_helper_acceptance_local.rb index 9f0cd18b7b..b0e6728217 100644 --- a/spec/spec_helper_acceptance_local.rb +++ b/spec/spec_helper_acceptance_local.rb @@ -9,11 +9,11 @@ c.before :suite do # lsb-release is needed for facter 3 (puppet 6) to resolve os.distro facts. Not needed with facter # 4 (puppet 7). - lsb_package = <<-MANIFEST -package { 'lsb-release': - ensure => installed, -} -MANIFEST + lsb_package = <<~MANIFEST + package { 'lsb-release': + ensure => installed, + } + MANIFEST include PuppetLitmus extend PuppetLitmus apply_manifest(lsb_package) @@ -40,6 +40,7 @@ def retry_on_error_matching(max_retry_count = MAX_RETRY_COUNT, retry_wait_interv yield rescue StandardError => e raise('Attempted this %{value0} times. Raising %{value1}' % { value0: max_retry_count, value1: e }) unless try < max_retry_count && (error_matcher.nil? || e.message =~ error_matcher) + sleep retry_wait_interval_secs retry end diff --git a/spec/unit/puppet/provider/apt_key_spec.rb b/spec/unit/puppet/provider/apt_key_spec.rb index 970f7e148e..d2fa8b2644 100644 --- a/spec/unit/puppet/provider/apt_key_spec.rb +++ b/spec/unit/puppet/provider/apt_key_spec.rb @@ -29,16 +29,16 @@ context 'self.instances multiple keys' do before :each do - command_output = <<-OUTPUT -Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.DU0GdRxjmE --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyring /etc/apt/trusted.gpg.d/puppetlabs-pc1-keyring.gpg --no-tty --list-keys --with-colons --fingerprint --fixed-list-mode -tru:t:1:1549900774:0:3:1:5 -pub:-:1024:17:40976EAF437D05B5:1095016255:::-:::scESC: -fpr:::::::::630239CC130E1A7FD81A27B140976EAF437D05B5: -uid:-::::1095016255::B84AE656F4F5A826C273A458512EF8E282754CE1::Ubuntu Archive Automatic Signing Key : -sub:-:2048:16:251BEFF479164387:1095016263::::::e: -pub:-:1024:17:46181433FBB75451:1104433784:::-:::scSC: -fpr:::::::::C5986B4F1257FFA86632CBA746181433FBB75451: -OUTPUT + command_output = <<~OUTPUT + Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.DU0GdRxjmE --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyring /etc/apt/trusted.gpg.d/puppetlabs-pc1-keyring.gpg --no-tty --list-keys --with-colons --fingerprint --fixed-list-mode + tru:t:1:1549900774:0:3:1:5 + pub:-:1024:17:40976EAF437D05B5:1095016255:::-:::scESC: + fpr:::::::::630239CC130E1A7FD81A27B140976EAF437D05B5: + uid:-::::1095016255::B84AE656F4F5A826C273A458512EF8E282754CE1::Ubuntu Archive Automatic Signing Key : + sub:-:2048:16:251BEFF479164387:1095016263::::::e: + pub:-:1024:17:46181433FBB75451:1104433784:::-:::scSC: + fpr:::::::::C5986B4F1257FFA86632CBA746181433FBB75451: + OUTPUT allow(described_class).to receive(:apt_key).with( ['adv', '--no-tty', '--list-keys', '--with-colons', '--fingerprint', '--fixed-list-mode'], ).and_return(command_output) @@ -136,11 +136,11 @@ '32bit key id' => 'EF8D349F', '64bit key id' => '7F438280EF8D349F', '160bit key fingerprint' => '6F6B15509CF8E59E6E469F327F438280EF8D349F', - '32bit key id lowercase' => 'EF8D349F'.downcase, - '64bit key id lowercase' => '7F438280EF8D349F'.downcase, + '32bit key id lowercase' => 'EF8D349F'.downcase, + '64bit key id lowercase' => '7F438280EF8D349F'.downcase, '160bit key fingerprint lowercase' => '6F6B15509CF8E59E6E469F327F438280EF8D349F'.downcase, - '32bit key id 0x formatted' => '0xEF8D349F', - '64bit key id 0x formatted' => '0x7F438280EF8D349F', + '32bit key id 0x formatted' => '0xEF8D349F', + '64bit key id 0x formatted' => '0x7F438280EF8D349F', '160bit key fingerprint 0x formatted' => '0x6F6B15509CF8E59E6E469F327F438280EF8D349F', } hash_of_keys.each do |key_type, value| diff --git a/spec/unit/puppet/type/apt_key_spec.rb b/spec/unit/puppet/type/apt_key_spec.rb index b20a09a101..a23aa90c4c 100644 --- a/spec/unit/puppet/type/apt_key_spec.rb +++ b/spec/unit/puppet/type/apt_key_spec.rb @@ -164,10 +164,10 @@ it 'raises an error if refresh => true and ensure => absent' do expect { - Puppet::Type.type(:apt_key).new(id: 'EF8D349F', - source: 'http://apt.puppetlabs.com/pubkey.gpg', - ensure: :absent, - refresh: :true) + Puppet::Type.type(:apt_key).new(id: 'EF8D349F', + source: 'http://apt.puppetlabs.com/pubkey.gpg', + ensure: :absent, + refresh: :true) }.to raise_error(%r{ensure => absent and refresh => true are mutually exclusive}) end diff --git a/tasks/init.rb b/tasks/init.rb index 86367d9396..132699ad01 100755 --- a/tasks/init.rb +++ b/tasks/init.rb @@ -17,6 +17,7 @@ def apt_get(action) end stdout, stderr, status = Open3.capture3(*cmd) raise Puppet::Error, stderr if status != 0 + { status: stdout.strip } end From ec7f4e29c6f57ee9250c65432ee0051282367760 Mon Sep 17 00:00:00 2001 From: david22swan Date: Fri, 21 Apr 2023 13:44:09 +0100 Subject: [PATCH 07/18] (CONT-773) Rubocop Auto Fixes 6-10 - Lint/SymbolConversion - RSpec/BeNil - RSpec/EmptyLineAfterExample - RSpec/EmptyLineAfterExampleGroup - RSpec/EmptyLineAfterHook --- .rubocop_todo.yml | 69 ------------------- spec/acceptance/apt_key_provider_spec.rb | 4 ++ spec/acceptance/apt_spec.rb | 1 + spec/acceptance/init_task_spec.rb | 3 + spec/classes/apt_backports_spec.rb | 13 ++++ spec/classes/apt_spec.rb | 2 + spec/classes/apt_update_spec.rb | 16 +++-- spec/defines/key_compat_spec.rb | 12 ++++ spec/defines/key_spec.rb | 14 ++++ spec/defines/pin_spec.rb | 1 + spec/defines/ppa_spec.rb | 7 ++ spec/defines/source_spec.rb | 3 + spec/unit/facter/apt_dist_has_updates_spec.rb | 3 + .../apt_dist_package_security_updates_spec.rb | 3 +- .../facter/apt_dist_package_updates_spec.rb | 4 +- .../facter/apt_dist_security_updates_spec.rb | 3 +- spec/unit/facter/apt_dist_updates_spec.rb | 4 +- spec/unit/facter/apt_has_updates_spec.rb | 3 + .../apt_package_security_updates_spec.rb | 3 +- spec/unit/facter/apt_package_updates_spec.rb | 4 +- spec/unit/facter/apt_reboot_required_spec.rb | 2 + spec/unit/facter/apt_security_updates_spec.rb | 3 +- spec/unit/facter/apt_updates_spec.rb | 4 +- spec/unit/puppet/provider/apt_key_spec.rb | 2 + 24 files changed, 100 insertions(+), 83 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 31aae81836..5ae1290b5a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -21,14 +21,6 @@ Lint/ConstantDefinitionInBlock: - 'spec/defines/source_compat_spec.rb' - 'spec/defines/source_spec.rb' -# Offense count: 6 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: strict, consistent -Lint/SymbolConversion: - Exclude: - - 'spec/classes/apt_update_spec.rb' - # Offense count: 6 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: @@ -68,21 +60,6 @@ RSpec/BeEq: - 'spec/unit/facter/apt_reboot_required_spec.rb' - 'spec/unit/puppet/type/apt_key_spec.rb' -# Offense count: 8 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: be, be_nil -RSpec/BeNil: - Exclude: - - 'spec/unit/facter/apt_dist_package_security_updates_spec.rb' - - 'spec/unit/facter/apt_dist_package_updates_spec.rb' - - 'spec/unit/facter/apt_dist_security_updates_spec.rb' - - 'spec/unit/facter/apt_dist_updates_spec.rb' - - 'spec/unit/facter/apt_package_security_updates_spec.rb' - - 'spec/unit/facter/apt_package_updates_spec.rb' - - 'spec/unit/facter/apt_security_updates_spec.rb' - - 'spec/unit/facter/apt_updates_spec.rb' - # Offense count: 6 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without @@ -97,52 +74,6 @@ RSpec/ContextWording: RSpec/DescribeClass: Enabled: false -# Offense count: 23 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowConsecutiveOneLiners. -RSpec/EmptyLineAfterExample: - Exclude: - - 'spec/acceptance/apt_key_provider_spec.rb' - - 'spec/acceptance/apt_spec.rb' - - 'spec/classes/apt_spec.rb' - - 'spec/defines/key_compat_spec.rb' - - 'spec/defines/key_spec.rb' - - 'spec/defines/pin_spec.rb' - - 'spec/defines/ppa_spec.rb' - - 'spec/defines/source_spec.rb' - -# Offense count: 39 -# This cop supports safe autocorrection (--autocorrect). -RSpec/EmptyLineAfterExampleGroup: - Exclude: - - 'spec/acceptance/apt_key_provider_spec.rb' - - 'spec/acceptance/init_task_spec.rb' - - 'spec/classes/apt_backports_spec.rb' - - 'spec/classes/apt_spec.rb' - - 'spec/classes/apt_update_spec.rb' - - 'spec/defines/key_compat_spec.rb' - - 'spec/defines/key_spec.rb' - - 'spec/defines/source_spec.rb' - -# Offense count: 24 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowConsecutiveOneLiners. -RSpec/EmptyLineAfterHook: - Exclude: - - 'spec/acceptance/apt_key_provider_spec.rb' - - 'spec/unit/facter/apt_dist_has_updates_spec.rb' - - 'spec/unit/facter/apt_dist_package_security_updates_spec.rb' - - 'spec/unit/facter/apt_dist_package_updates_spec.rb' - - 'spec/unit/facter/apt_dist_security_updates_spec.rb' - - 'spec/unit/facter/apt_dist_updates_spec.rb' - - 'spec/unit/facter/apt_has_updates_spec.rb' - - 'spec/unit/facter/apt_package_security_updates_spec.rb' - - 'spec/unit/facter/apt_package_updates_spec.rb' - - 'spec/unit/facter/apt_reboot_required_spec.rb' - - 'spec/unit/facter/apt_security_updates_spec.rb' - - 'spec/unit/facter/apt_updates_spec.rb' - - 'spec/unit/puppet/provider/apt_key_spec.rb' - # Offense count: 13 # Configuration parameters: CountAsOne. RSpec/ExampleLength: diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb index aa763405a3..4ca9dba219 100644 --- a/spec/acceptance/apt_key_provider_spec.rb +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -669,6 +669,7 @@ def apply_manifest_twice(manifest_pp) it 'add an apt_key resource' do apply_manifest_twice(ensure_present_pp) end + it 'remove the apt_key resource' do apply_manifest_twice(ensure_absent_pp) end @@ -855,6 +856,7 @@ def apply_manifest_twice(manifest_pp) after(:each) do run_shell('rm /tmp/fake-key.gpg') end + it 'fails' do apply_manifest(path_bogus_content_pp, expect_failures: true) do |r| expect(r.stderr).to match(%r{no valid OpenPGP data found}) @@ -897,6 +899,7 @@ def apply_manifest_twice(manifest_pp) apply_manifest(refresh_del_key_pp) apply_manifest(refresh_pp, catch_failures: true) end + context 'when refresh => true' do it 'updates an expired key' do apply_manifest(refresh_true_pp) @@ -904,6 +907,7 @@ def apply_manifest_twice(manifest_pp) run_shell(PUPPETLABS_EXP_CHECK_COMMAND.to_s) end end + context 'when refresh => false' do it 'does not replace an expired key' do apply_manifest(refresh_false_pp) diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb index 35277bb591..d726c342a2 100644 --- a/spec/acceptance/apt_spec.rb +++ b/spec/acceptance/apt_spec.rb @@ -45,6 +45,7 @@ class { 'apt': apply_manifest(everything_everything_pp, catch_failures: true) end end + it 'stills work' do run_shell('apt-get update') run_shell('apt-get -y --force-yes upgrade') diff --git a/spec/acceptance/init_task_spec.rb b/spec/acceptance/init_task_spec.rb index 02b3f34dfd..7a21a43854 100644 --- a/spec/acceptance/init_task_spec.rb +++ b/spec/acceptance/init_task_spec.rb @@ -10,18 +10,21 @@ expect(result.stdout).to contain(%r{Reading package lists}) end end + describe 'upgrade' do it 'upgrades packages' do result = run_bolt_task('apt', 'action' => 'upgrade') expect(result.stdout).to contain(%r{\d+ upgraded, \d+ newly installed, \d+ to remove and \d+ not upgraded}) end end + describe 'dist-upgrade' do it 'dist-upgrades packages' do result = run_bolt_task('apt', 'action' => 'dist-upgrade') expect(result.stdout).to contain(%r{\d+ upgraded, \d+ newly installed, \d+ to remove and \d+ not upgraded}) end end + describe 'autoremove' do it 'autoremoves obsolete packages' do result = run_bolt_task('apt', 'action' => 'autoremove') diff --git a/spec/classes/apt_backports_spec.rb b/spec/classes/apt_backports_spec.rb index 6f6d530921..2ae8429478 100644 --- a/spec/classes/apt_backports_spec.rb +++ b/spec/classes/apt_backports_spec.rb @@ -31,6 +31,7 @@ pin: { 'priority' => 200, 'release' => 'stretch-backports' }) } end + context 'with defaults on ubuntu' do let(:facts) do { @@ -57,6 +58,7 @@ pin: { 'priority' => 200, 'release' => 'bionac-backports' }) } end + context 'with everything set' do let(:facts) do { @@ -92,6 +94,7 @@ pin: { 'priority' => 90, 'release' => 'vivid' }) } end + context 'when set things with hashes' do let(:facts) do { @@ -126,6 +129,7 @@ } end end + describe 'mint tests' do let(:facts) do { @@ -162,6 +166,7 @@ pin: { 'priority' => 200, 'release' => 'trusty-backports' }) } end + context 'with missing location' do let(:params) do { @@ -175,6 +180,7 @@ is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key}) end end + context 'with missing release' do let(:params) do { @@ -188,6 +194,7 @@ is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key}) end end + context 'with missing repos' do let(:params) do { @@ -201,6 +208,7 @@ is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key}) end end + context 'with missing key' do let(:params) do { @@ -215,6 +223,7 @@ end end end + describe 'validation' do let(:facts) do { @@ -244,6 +253,7 @@ is_expected.to raise_error(Puppet::Error, %r{expects a}) end end + context 'with invalid release' do let(:params) do { @@ -255,6 +265,7 @@ is_expected.to raise_error(Puppet::Error, %r{expects a}) end end + context 'with invalid repos' do let(:params) do { @@ -266,6 +277,7 @@ is_expected.to raise_error(Puppet::Error, %r{expects a}) end end + context 'with invalid key' do let(:params) do { @@ -277,6 +289,7 @@ is_expected.to raise_error(Puppet::Error, %r{expects a}) end end + context 'with invalid pin' do let(:params) do { diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index b7ef6b5d1c..afd7797049 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -214,6 +214,7 @@ %r{Acquire::https::proxy "https://localhost:8080/";}, ) } + it { is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content( %r{Acquire::http::proxy "http://localhost:8080/";}, @@ -232,6 +233,7 @@ } end end + context 'with lots of non-defaults' do let :params do { diff --git a/spec/classes/apt_update_spec.rb b/spec/classes/apt_update_spec.rb index 6ab9534c46..5a73eb45ec 100644 --- a/spec/classes/apt_update_spec.rb +++ b/spec/classes/apt_update_spec.rb @@ -24,7 +24,7 @@ id: 'Debian', }, }, - 'apt_update_last_success': factval, + apt_update_last_success: factval, } end let(:pre_condition) do @@ -61,6 +61,7 @@ is_expected.to contain_exec('apt_update').with('refreshonly' => false) end end + context 'and Exec[apt_update] refreshonly is overridden to true and has recent run' do let(:facts) do { @@ -76,7 +77,7 @@ id: 'Debian', }, }, - 'apt_update_last_success': Time.now.to_i, + apt_update_last_success: Time.now.to_i, } end let(:pre_condition) do @@ -92,6 +93,7 @@ end end end + context "when apt::update['frequency']='reluctantly'" do { 'a recent run' => Time.now.to_i, @@ -113,7 +115,7 @@ id: 'Debian', }, }, - 'apt_update_last_success': factval, + apt_update_last_success: factval, } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" } @@ -149,6 +151,7 @@ end end end + ['daily', 'weekly'].each do |update_frequency| context "when apt::update['frequency'] has the value of #{update_frequency}" do { 'we are due for a run' => 1_406_660_561, 'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| @@ -167,7 +170,7 @@ id: 'Debian', }, }, - 'apt_update_last_success': factval, + apt_update_last_success: factval, } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } @@ -193,7 +196,7 @@ id: 'Debian', }, }, - 'apt_update_last_success': Time.now.to_i, + apt_update_last_success: Time.now.to_i, } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } @@ -203,6 +206,7 @@ is_expected.to contain_exec('apt_update').with('refreshonly' => true) end end + context 'when $apt_update_last_success is nil' do let(:facts) do { @@ -218,7 +222,7 @@ id: 'Debian', }, }, - 'apt_update_last_success': nil, + apt_update_last_success: nil, } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } diff --git a/spec/defines/key_compat_spec.rb b/spec/defines/key_compat_spec.rb index 2fb7e65638..ab305a99d3 100644 --- a/spec/defines/key_compat_spec.rb +++ b/spec/defines/key_compat_spec.rb @@ -57,6 +57,7 @@ def apt_key_example(title) server: 'keyserver.ubuntu.com', content: nil) } + it 'contains the apt_key present anchor' do is_expected.to contain_anchor("apt_key #{title} present") end @@ -80,6 +81,7 @@ def apt_key_example(title) server: 'keyserver.ubuntu.com', content: nil) end + it 'contains the apt_key present anchor' do is_expected.to contain_anchor("apt_key #{GPG_KEY_ID} present") end @@ -99,6 +101,7 @@ def apt_key_example(title) server: 'keyserver.ubuntu.com', content: nil) end + it 'contains the apt_key absent anchor' do is_expected.to contain_anchor("apt_key #{title} absent") end @@ -117,6 +120,7 @@ def apt_key_example(title) it 'contains the apt_key' do is_expected.to contain_apt_key(title).with(contains_apt_key_example(title)) end + it 'contains the apt_key present anchor' do is_expected.to contain_anchor("apt_key #{title} present") end @@ -147,6 +151,7 @@ def apt_key_example(title) server: 'hkp://pgp.mit.edu') end end + context 'with url and port number' do let :params do { @@ -197,6 +202,7 @@ def apt_key_example(title) is_expected.to raise_error(%r{expects a match}) end end + context 'when url character limit is exceeded' do let :params do { @@ -208,6 +214,7 @@ def apt_key_example(title) is_expected.to raise_error(%r{expects a match}) end end + context 'with incorrect port number url' do let :params do { @@ -219,6 +226,7 @@ def apt_key_example(title) is_expected.to raise_error(%r{expects a match}) end end + context 'with incorrect protocol for url' do let :params do { @@ -230,6 +238,7 @@ def apt_key_example(title) is_expected.to raise_error(%r{expects a match}) end end + context 'with missing port number url' do let :params do { @@ -241,6 +250,7 @@ def apt_key_example(title) is_expected.to raise_error(%r{expects a match}) end end + context 'with url ending with a dot' do let :params do { @@ -252,6 +262,7 @@ def apt_key_example(title) is_expected.to raise_error(%r{expects a match}) end end + context 'with url begin with a dash' do let(:params) do { @@ -263,6 +274,7 @@ def apt_key_example(title) is_expected.to raise_error(%r{expects a match}) end end + context 'with invalid key' do let :title do 'Out of rum. Why? Why are we out of rum?' diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index 8c8d503f6c..956c9b68dd 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -70,6 +70,7 @@ def absent_apt_key(title) it 'contains the apt_key' do is_expected.to contain_apt_key(title).with(default_apt_key_example(title)) end + it 'contains the apt_key present anchor' do is_expected.to contain_anchor("apt_key #{title} present") end @@ -89,6 +90,7 @@ def absent_apt_key(title) it 'contains the apt_key' do is_expected.to contain_apt_key(title).with(title_key_example) end + it 'contains the apt_key present anchor' do is_expected.to contain_anchor("apt_key #{GPG_KEY_ID} present") end @@ -104,6 +106,7 @@ def absent_apt_key(title) it 'contains the apt_key' do is_expected.to contain_apt_key(title).with(absent_apt_key(title)) end + it 'contains the apt_key absent anchor' do is_expected.to contain_anchor("apt_key #{title} absent") end @@ -137,6 +140,7 @@ def absent_apt_key(title) it 'contains the apt_key' do is_expected.to contain_apt_key(title).with(bunch_things_apt_key_example(title, params)) end + it 'contains the apt_key present anchor' do is_expected.to contain_anchor("apt_key #{title} present") end @@ -167,6 +171,7 @@ def absent_apt_key(title) server: 'hkp://pgp.mit.edu') end end + context 'when url with port number' do let :params do { @@ -217,6 +222,7 @@ def absent_apt_key(title) is_expected.to raise_error(%r{expects a match}) end end + context 'when character url exceeded' do let :params do { @@ -228,6 +234,7 @@ def absent_apt_key(title) is_expected.to raise_error(%r{expects a match}) end end + context 'with incorrect port number url' do let :params do { @@ -239,6 +246,7 @@ def absent_apt_key(title) is_expected.to raise_error(%r{expects a match}) end end + context 'with incorrect protocol for url' do let :params do { @@ -250,6 +258,7 @@ def absent_apt_key(title) is_expected.to raise_error(%r{expects a match}) end end + context 'with missing port number url' do let :params do { @@ -261,6 +270,7 @@ def absent_apt_key(title) is_expected.to raise_error(%r{expects a match}) end end + context 'with url ending with a dot' do let :params do { @@ -272,6 +282,7 @@ def absent_apt_key(title) is_expected.to raise_error(%r{expects a match}) end end + context 'when url begins with a dash' do let(:params) do { @@ -283,6 +294,7 @@ def absent_apt_key(title) is_expected.to raise_error(%r{expects a match}) end end + context 'with invalid key' do let :title do 'Out of rum. Why? Why are we out of rum?' @@ -365,6 +377,7 @@ def absent_apt_key(title) is_expected.to contain_apt__key('duplicate').with(id: title, ensure: 'present') end + it 'contains two apt::key resource - title' do is_expected.to contain_apt__key(title).with(id: title, ensure: 'present') @@ -373,6 +386,7 @@ def absent_apt_key(title) it 'contains only a single apt_key - duplicate' do is_expected.to contain_apt_key('duplicate').with(default_apt_key_example(title)) end + it 'contains only a single apt_key - no title' do is_expected.not_to contain_apt_key(title) end diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index f22d92ac5a..8b30a4c770 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -65,6 +65,7 @@ end it { is_expected.to contain_apt__setting('pref-my_pin').with_content(%r{Explanation: foo\nPackage: \*\nPin: release a=1, n=bar, v=2, c=baz, o=foobar, l=foobaz\nPin-Priority: 10\n}) } + it { is_expected.to contain_apt__setting('pref-my_pin').with('priority' => 99) } diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 00424dccb7..4732350e84 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -37,6 +37,7 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) let(:title) { 'ppa:needs/substitution' } it { is_expected.not_to contain_package('python-software-properties') } + it { is_expected.to contain_exec('add-apt-repository-ppa:needs/substitution') .that_notifies('Class[Apt::Update]') @@ -168,6 +169,7 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) let(:title) { 'ppa:needs/substitution' } it { is_expected.to contain_package('software-properties-common') } + it { is_expected.to contain_exec('add-apt-repository-ppa:needs/substitution') .that_notifies('Class[Apt::Update]') @@ -207,6 +209,7 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) let(:title) { 'ppa:needs/substitution' } it { is_expected.not_to contain_package('python-software-properties') } + it { is_expected.to contain_exec('add-apt-repository-ppa:needs/substitution') .that_notifies('Class[Apt::Update]') @@ -250,6 +253,7 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) it { is_expected.to compile.with_all_deps } it { is_expected.to contain_package('software-properties-common') } + it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo') .that_notifies('Class[Apt::Update]') @@ -291,6 +295,7 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) let(:title) { 'ppa:user/foo' } it { is_expected.to contain_package('software-properties-common') } + it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo') .that_notifies('Class[Apt::Update]') @@ -332,6 +337,7 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) let(:title) { 'ppa:user/foo' } it { is_expected.to contain_package('software-properties-common') } + it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo') .that_notifies('Class[Apt::Update]') @@ -373,6 +379,7 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) let(:title) { 'ppa:user/foo' } it { is_expected.to contain_package('software-properties-common') } + it { is_expected.to contain_exec('add-apt-repository-ppa:user/foo') .that_notifies('Class[Apt::Update]') diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index e5df79febc..b2c09891c1 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -36,6 +36,7 @@ is_expected.to raise_error(Puppet::Error, %r{source entry without specifying a location}) end end + context 'with location' do let(:params) { { location: 'hello.there' } } @@ -372,6 +373,7 @@ it { is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{deb-src hello.there wheezy main\n}) } + it { is_expected.to contain_apt__setting('list-my_source').without_content(%r{deb hello.there wheezy main\n}) } end @@ -386,6 +388,7 @@ it { is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{deb-src hello.there stretch main\n}) } + it { is_expected.to contain_apt__setting('list-my_source').without_content(%r{deb hello.there stretch main\n}) } end diff --git a/spec/unit/facter/apt_dist_has_updates_spec.rb b/spec/unit/facter/apt_dist_has_updates_spec.rb index 3ed4f3b213..b5b05b6f05 100644 --- a/spec/unit/facter/apt_dist_has_updates_spec.rb +++ b/spec/unit/facter/apt_dist_has_updates_spec.rb @@ -11,6 +11,7 @@ before(:each) do allow(Facter.fact(:osfamily)).to receive(:value).once.and_return('Redhat') end + it { is_expected.to be_nil } end @@ -20,6 +21,7 @@ allow(File).to receive(:executable?) # Stub all other calls allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(false) end + it { is_expected.to be_nil } end @@ -36,6 +38,7 @@ "Conf planet.rb (22-2~bpo8+1 Debian Backports:stretch-backports [all])\n" allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').and_return(apt_output) end + it { is_expected.to be true } end end diff --git a/spec/unit/facter/apt_dist_package_security_updates_spec.rb b/spec/unit/facter/apt_dist_package_security_updates_spec.rb index f16ff52657..1e8aeb8a58 100644 --- a/spec/unit/facter/apt_dist_package_security_updates_spec.rb +++ b/spec/unit/facter/apt_dist_package_security_updates_spec.rb @@ -11,7 +11,8 @@ before(:each) do allow(Facter.fact(:apt_has_dist_updates)).to receive(:value).and_return(false) end - it { is_expected.to be nil } + + it { is_expected.to be_nil } end describe 'when apt has updates' do diff --git a/spec/unit/facter/apt_dist_package_updates_spec.rb b/spec/unit/facter/apt_dist_package_updates_spec.rb index a27d607bab..43e2d7e7d9 100644 --- a/spec/unit/facter/apt_dist_package_updates_spec.rb +++ b/spec/unit/facter/apt_dist_package_updates_spec.rb @@ -11,7 +11,8 @@ before(:each) do allow(Facter.fact(:apt_has_dist_updates)).to receive(:value).and_return(false) end - it { is_expected.to be nil } + + it { is_expected.to be_nil } end describe 'when apt has updates' do @@ -28,6 +29,7 @@ "Conf planet.rb (22-2~bpo8+1 Debian Backports:-backports [all])\n" allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').and_return(apt_output) end + it { is_expected.to eq(['extremetuxracer', 'planet.rb']) } end end diff --git a/spec/unit/facter/apt_dist_security_updates_spec.rb b/spec/unit/facter/apt_dist_security_updates_spec.rb index aa21e649c6..baaf0484e9 100644 --- a/spec/unit/facter/apt_dist_security_updates_spec.rb +++ b/spec/unit/facter/apt_dist_security_updates_spec.rb @@ -11,7 +11,8 @@ before(:each) do allow(Facter.fact(:apt_has_dist_updates)).to receive(:value).and_return(false) end - it { is_expected.to be nil } + + it { is_expected.to be_nil } end describe 'when apt has security updates' do diff --git a/spec/unit/facter/apt_dist_updates_spec.rb b/spec/unit/facter/apt_dist_updates_spec.rb index 21352b5567..ac87f666a1 100644 --- a/spec/unit/facter/apt_dist_updates_spec.rb +++ b/spec/unit/facter/apt_dist_updates_spec.rb @@ -11,7 +11,8 @@ before(:each) do allow(Facter.fact(:apt_has_dist_updates)).to receive(:value).and_return(false) end - it { is_expected.to be nil } + + it { is_expected.to be_nil } end describe 'when apt has updates' do @@ -28,6 +29,7 @@ "Conf planet.rb (22-2~bpo8+1 Debian Backports:-backports [all])\n" allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true dist-upgrade 2>&1').and_return(apt_output) end + it { is_expected.to eq(2) } end end diff --git a/spec/unit/facter/apt_has_updates_spec.rb b/spec/unit/facter/apt_has_updates_spec.rb index 0f0a74094c..77a95b4391 100644 --- a/spec/unit/facter/apt_has_updates_spec.rb +++ b/spec/unit/facter/apt_has_updates_spec.rb @@ -11,6 +11,7 @@ before(:each) do allow(Facter.fact(:osfamily)).to receive(:value).once.and_return('Redhat') end + it { is_expected.to be_nil } end @@ -20,6 +21,7 @@ allow(File).to receive(:executable?) # Stub all other calls allow(File).to receive(:executable?).with('/usr/bin/apt-get').and_return(false) end + it { is_expected.to be_nil } end @@ -35,6 +37,7 @@ "Conf unhide.rb (22-2~bpo8+1 Debian Backports:-backports [all])\n" allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return(apt_output) end + it { is_expected.to be true } end end diff --git a/spec/unit/facter/apt_package_security_updates_spec.rb b/spec/unit/facter/apt_package_security_updates_spec.rb index 28516cac48..d546715426 100644 --- a/spec/unit/facter/apt_package_security_updates_spec.rb +++ b/spec/unit/facter/apt_package_security_updates_spec.rb @@ -11,7 +11,8 @@ before(:each) do allow(Facter.fact(:apt_has_updates)).to receive(:value).and_return(false) end - it { is_expected.to be nil } + + it { is_expected.to be_nil } end describe 'when apt has updates' do diff --git a/spec/unit/facter/apt_package_updates_spec.rb b/spec/unit/facter/apt_package_updates_spec.rb index 69db490dd6..7960306e00 100644 --- a/spec/unit/facter/apt_package_updates_spec.rb +++ b/spec/unit/facter/apt_package_updates_spec.rb @@ -11,7 +11,8 @@ before(:each) do allow(Facter.fact(:apt_has_updates)).to receive(:value).and_return(false) end - it { is_expected.to be nil } + + it { is_expected.to be_nil } end describe 'when apt has updates' do @@ -26,6 +27,7 @@ "Conf unhide.rb (22-2~bpo8+1 Debian Backports:-backports [all])\n" allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return(apt_output) end + it { is_expected.to eq(['tzdata', 'unhide.rb']) } end end diff --git a/spec/unit/facter/apt_reboot_required_spec.rb b/spec/unit/facter/apt_reboot_required_spec.rb index 7621872d08..f922822784 100644 --- a/spec/unit/facter/apt_reboot_required_spec.rb +++ b/spec/unit/facter/apt_reboot_required_spec.rb @@ -13,6 +13,7 @@ allow(File).to receive(:file?).and_return(true) allow(File).to receive(:file?).once.with('/var/run/reboot-required').and_return(true) end + it { is_expected.to eq true } end @@ -22,6 +23,7 @@ allow(File).to receive(:file?).and_return(true) allow(File).to receive(:file?).once.with('/var/run/reboot-required').and_return(false) end + it { is_expected.to eq false } end end diff --git a/spec/unit/facter/apt_security_updates_spec.rb b/spec/unit/facter/apt_security_updates_spec.rb index 9d3e587a89..25ba3114ed 100644 --- a/spec/unit/facter/apt_security_updates_spec.rb +++ b/spec/unit/facter/apt_security_updates_spec.rb @@ -11,7 +11,8 @@ before(:each) do allow(Facter.fact(:apt_has_updates)).to receive(:value).and_return(false) end - it { is_expected.to be nil } + + it { is_expected.to be_nil } end describe 'when apt has security updates' do diff --git a/spec/unit/facter/apt_updates_spec.rb b/spec/unit/facter/apt_updates_spec.rb index a8eacbf20b..4397f766bb 100644 --- a/spec/unit/facter/apt_updates_spec.rb +++ b/spec/unit/facter/apt_updates_spec.rb @@ -11,7 +11,8 @@ before(:each) do allow(Facter.fact(:apt_has_updates)).to receive(:value).and_return(false) end - it { is_expected.to be nil } + + it { is_expected.to be_nil } end describe 'when apt has updates' do @@ -26,6 +27,7 @@ "Conf unhide.rb (22-2~bpo8+1 Debian Backports:-backports [all])\n" allow(Facter::Core::Execution).to receive(:execute).with('/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade 2>&1').and_return(apt_output) end + it { is_expected.to eq(2) } end end diff --git a/spec/unit/puppet/provider/apt_key_spec.rb b/spec/unit/puppet/provider/apt_key_spec.rb index d2fa8b2644..668a953bff 100644 --- a/spec/unit/puppet/provider/apt_key_spec.rb +++ b/spec/unit/puppet/provider/apt_key_spec.rb @@ -22,6 +22,7 @@ ['adv', '--no-tty', '--list-keys', '--with-colons', '--fingerprint', '--fixed-list-mode'], ).and_return('uid:-::::1284991450::07BEBE04F4AE4A8E885A761325717D8509D9C1DC::Ubuntu Extras Archive Automatic Signing Key ::::::::::0:') end + it 'returns no resources' do expect(described_class.instances.size).to eq(0) end @@ -43,6 +44,7 @@ ['adv', '--no-tty', '--list-keys', '--with-colons', '--fingerprint', '--fixed-list-mode'], ).and_return(command_output) end + it 'returns 2 resources' do # rubocop:disable RSpec/MultipleExpectations expect(described_class.instances.size).to eq(2) expect(described_class.instances[0].name).to eq('630239CC130E1A7FD81A27B140976EAF437D05B5') From 4513a5845c2a18aece7e17ad82612ec4da3efaa0 Mon Sep 17 00:00:00 2001 From: david22swan Date: Fri, 21 Apr 2023 13:48:27 +0100 Subject: [PATCH 08/18] (CONT-773) Rubocop Auto Fixes 11-15 - RSpec/ExampleWording - RSpec/ImplicitSubject - Style/IfUnlessModifier - Style/QuotedSymbols - Style/RedundantRegexpEscape --- .rubocop_todo.yml | 56 ++------ lib/facter/apt_updates.rb | 12 +- lib/puppet/provider/apt_key/apt_key.rb | 12 +- lib/puppet/type/apt_key.rb | 18 +-- spec/classes/apt_backports_spec.rb | 60 ++++---- spec/classes/apt_spec.rb | 132 +++++++++--------- spec/classes/apt_update_spec.rb | 16 +-- spec/defines/conf_spec.rb | 16 +-- spec/defines/key_compat_spec.rb | 98 ++++++------- spec/defines/key_spec.rb | 78 +++++------ spec/defines/mark_spec.rb | 8 +- spec/defines/pin_spec.rb | 14 +- spec/defines/ppa_spec.rb | 24 ++-- spec/defines/setting_spec.rb | 28 ++-- spec/defines/source_compat_spec.rb | 22 +-- spec/defines/source_spec.rb | 86 ++++++------ .../facter/apt_update_last_success_spec.rb | 4 +- spec/unit/puppet/provider/apt_key_spec.rb | 6 +- 18 files changed, 320 insertions(+), 370 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5ae1290b5a..a088dced4b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2023-04-21 09:13:34 UTC using RuboCop version 1.48.1. +# on 2023-04-21 12:46:34 UTC using RuboCop version 1.48.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 @@ -87,18 +87,22 @@ RSpec/ExampleWording: Exclude: - 'spec/acceptance/apt_key_provider_spec.rb' -# Offense count: 2 -# This cop supports safe autocorrection (--autocorrect). -RSpec/ExcessiveDocstringSpacing: +# Offense count: 3 +RSpec/LeakyConstantDeclaration: Exclude: - 'spec/defines/key_compat_spec.rb' - - 'spec/defines/setting_spec.rb' + - 'spec/defines/source_compat_spec.rb' + - 'spec/defines/source_spec.rb' + +# Offense count: 3 +# Configuration parameters: AllowSubject. +RSpec/MultipleMemoizedHelpers: + Max: 6 # Offense count: 204 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: single_line_only, single_statement_only, disallow, require_implicit -RSpec/ImplicitSubject: +# Configuration parameters: EnforcedStyle, IgnoreSharedExamples. +# SupportedStyles: always, named_only +RSpec/NamedSubject: Exclude: - 'spec/classes/apt_backports_spec.rb' - 'spec/classes/apt_spec.rb' @@ -114,18 +118,6 @@ RSpec/ImplicitSubject: - 'spec/defines/source_spec.rb' - 'spec/unit/facter/apt_update_last_success_spec.rb' -# Offense count: 3 -RSpec/LeakyConstantDeclaration: - Exclude: - - 'spec/defines/key_compat_spec.rb' - - 'spec/defines/source_compat_spec.rb' - - 'spec/defines/source_spec.rb' - -# Offense count: 3 -# Configuration parameters: AllowSubject. -RSpec/MultipleMemoizedHelpers: - Max: 6 - # Offense count: 2 # Configuration parameters: AllowedGroups. RSpec/NestedGroups: @@ -170,33 +162,11 @@ Style/GlobalStdStream: Exclude: - 'tasks/init.rb' -# Offense count: 10 -# This cop supports safe autocorrection (--autocorrect). -Style/IfUnlessModifier: - Exclude: - - 'lib/facter/apt_updates.rb' - - 'lib/puppet/provider/apt_key/apt_key.rb' - - 'lib/puppet/type/apt_key.rb' - # Offense count: 1 Style/MixinUsage: Exclude: - 'spec/spec_helper.rb' -# Offense count: 3 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: same_as_string_literals, single_quotes, double_quotes -Style/QuotedSymbols: - Exclude: - - 'spec/unit/puppet/provider/apt_key_spec.rb' - -# Offense count: 4 -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantRegexpEscape: - Exclude: - - 'lib/puppet/type/apt_key.rb' - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. diff --git a/lib/facter/apt_updates.rb b/lib/facter/apt_updates.rb index 3b46e2d63d..66c6a89286 100644 --- a/lib/facter/apt_updates.rb +++ b/lib/facter/apt_updates.rb @@ -23,9 +23,7 @@ def get_updates(upgrade_option) %r{ gNewSense[^\s]+-security[, ]}, ] re = Regexp.union(security_matches) - if line.match(re) - apt_updates[1].push(package) - end + apt_updates[1].push(package) if line.match(re) end end end @@ -36,9 +34,7 @@ def get_updates(upgrade_option) confine osfamily: 'Debian' setcode do apt_package_updates = get_updates('upgrade') - if !apt_package_updates.nil? && apt_package_updates.length == 2 - apt_package_updates != [[], []] - end + apt_package_updates != [[], []] if !apt_package_updates.nil? && apt_package_updates.length == 2 end end @@ -46,9 +42,7 @@ def get_updates(upgrade_option) confine osfamily: 'Debian' setcode do apt_dist_updates = get_updates('dist-upgrade') - if !apt_dist_updates.nil? && apt_dist_updates.length == 2 - apt_dist_updates != [[], []] - end + apt_dist_updates != [[], []] if !apt_dist_updates.nil? && apt_dist_updates.length == 2 end end diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index 9f461cc62c..c91e26ecb6 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -49,9 +49,7 @@ def self.instances expired = false - if line_hash[:key_expiry] - expired = Time.now >= line_hash[:key_expiry] - end + expired = Time.now >= line_hash[:key_expiry] if line_hash[:key_expiry] new( name: line_hash[:key_fingerprint], @@ -171,9 +169,7 @@ def tempfile(content) found_match = false extracted_key.each_line do |line| - if line.chomp == name - found_match = true - end + found_match = true if line.chomp == name end unless found_match raise(_('The id in your manifest %{_resource} and the fingerprint from content/source don\'t match. Check for an error in the id and content/source is legitimate.') % { _resource: resource[:name] }) # rubocop:disable Layout/LineLength @@ -196,9 +192,7 @@ def create # Breaking up the command like this is needed because it blows up # if --recv-keys isn't the last argument. command.push('adv', '--no-tty', '--keyserver', resource[:server]) - unless resource[:options].nil? - command.push('--keyserver-options', resource[:options]) - end + command.push('--keyserver-options', resource[:options]) unless resource[:options].nil? command.push('--recv-keys', resource[:id]) elsif resource[:content] key_file = tempfile(resource[:content]) diff --git a/lib/puppet/type/apt_key.rb b/lib/puppet/type/apt_key.rb index 99be930e28..faa430be42 100644 --- a/lib/puppet/type/apt_key.rb +++ b/lib/puppet/type/apt_key.rb @@ -25,16 +25,10 @@ ensurable validate do - if self[:refresh] == true && self[:ensure] == :absent - raise(_('ensure => absent and refresh => true are mutually exclusive')) - end - if self[:content] && self[:source] - raise(_('The properties content and source are mutually exclusive.')) - end + raise(_('ensure => absent and refresh => true are mutually exclusive')) if self[:refresh] == true && self[:ensure] == :absent + raise(_('The properties content and source are mutually exclusive.')) if self[:content] && self[:source] - if self[:id].length < 40 - warning(_('The id should be a full fingerprint (40 characters), see README.')) - end + warning(_('The id should be a full fingerprint (40 characters), see README.')) if self[:id].length < 40 end newparam(:id, namevar: true) do @@ -62,16 +56,14 @@ end autorequire(:file) do - if self[:source] && Pathname.new(self[:source]).absolute? - self[:source] - end + self[:source] if self[:source] && Pathname.new(self[:source]).absolute? end newparam(:server) do desc 'The key server to fetch the key from based on the ID. It can either be a domain name or url.' defaultto :'keyserver.ubuntu.com' - newvalues(%r{\A((hkp|hkps|http|https):\/\/)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?(\/[a-zA-Z\d\-_.]+)*\/?$}) + newvalues(%r{\A((hkp|hkps|http|https)://)?([a-z\d])([a-z\d-]{0,61}\.)+[a-z\d]+(:\d{2,5})?(/[a-zA-Z\d\-_.]+)*/?$}) end newparam(:options) do diff --git a/spec/classes/apt_backports_spec.rb b/spec/classes/apt_backports_spec.rb index 2ae8429478..bfe4a252df 100644 --- a/spec/classes/apt_backports_spec.rb +++ b/spec/classes/apt_backports_spec.rb @@ -25,10 +25,10 @@ end it { - is_expected.to contain_apt__source('backports').with(location: 'http://deb.debian.org/debian', - repos: 'main contrib non-free', - release: 'stretch-backports', - pin: { 'priority' => 200, 'release' => 'stretch-backports' }) + expect(subject).to contain_apt__source('backports').with(location: 'http://deb.debian.org/debian', + repos: 'main contrib non-free', + release: 'stretch-backports', + pin: { 'priority' => 200, 'release' => 'stretch-backports' }) } end @@ -51,11 +51,11 @@ end it { - is_expected.to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu', - key: '630239CC130E1A7FD81A27B140976EAF437D05B5', - repos: 'main universe multiverse restricted', - release: 'bionac-backports', - pin: { 'priority' => 200, 'release' => 'bionac-backports' }) + expect(subject).to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu', + key: '630239CC130E1A7FD81A27B140976EAF437D05B5', + repos: 'main universe multiverse restricted', + release: 'bionac-backports', + pin: { 'priority' => 200, 'release' => 'bionac-backports' }) } end @@ -87,11 +87,11 @@ end it { - is_expected.to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu-test', - key: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', - repos: 'main', - release: 'vivid', - pin: { 'priority' => 90, 'release' => 'vivid' }) + expect(subject).to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu-test', + key: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', + repos: 'main', + release: 'vivid', + pin: { 'priority' => 90, 'release' => 'vivid' }) } end @@ -124,8 +124,8 @@ end it { - is_expected.to contain_apt__source('backports').with(key: { 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' }, - pin: { 'priority' => '90' }) + expect(subject).to contain_apt__source('backports').with(key: { 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' }, + pin: { 'priority' => '90' }) } end end @@ -159,11 +159,11 @@ end it { - is_expected.to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu', - key: '630239CC130E1A7FD81A27B140976EAF437D05B5', - repos: 'main universe multiverse restricted', - release: 'trusty-backports', - pin: { 'priority' => 200, 'release' => 'trusty-backports' }) + expect(subject).to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu', + key: '630239CC130E1A7FD81A27B140976EAF437D05B5', + repos: 'main universe multiverse restricted', + release: 'trusty-backports', + pin: { 'priority' => 200, 'release' => 'trusty-backports' }) } end @@ -177,7 +177,7 @@ end it do - is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key}) + expect(subject).to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key}) end end @@ -191,7 +191,7 @@ end it do - is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key}) + expect(subject).to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key}) end end @@ -205,7 +205,7 @@ end it do - is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key}) + expect(subject).to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key}) end end @@ -219,7 +219,7 @@ end it do - is_expected.to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key}) + expect(subject).to raise_error(Puppet::Error, %r{If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key}) end end end @@ -250,7 +250,7 @@ end it do - is_expected.to raise_error(Puppet::Error, %r{expects a}) + expect(subject).to raise_error(Puppet::Error, %r{expects a}) end end @@ -262,7 +262,7 @@ end it do - is_expected.to raise_error(Puppet::Error, %r{expects a}) + expect(subject).to raise_error(Puppet::Error, %r{expects a}) end end @@ -274,7 +274,7 @@ end it do - is_expected.to raise_error(Puppet::Error, %r{expects a}) + expect(subject).to raise_error(Puppet::Error, %r{expects a}) end end @@ -286,7 +286,7 @@ end it do - is_expected.to raise_error(Puppet::Error, %r{expects a}) + expect(subject).to raise_error(Puppet::Error, %r{expects a}) end end @@ -298,7 +298,7 @@ end it do - is_expected.to raise_error(Puppet::Error, %r{expects a}) + expect(subject).to raise_error(Puppet::Error, %r{expects a}) end end end diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index afd7797049..65ae50b2aa 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -58,36 +58,36 @@ context 'with defaults' do it { - is_expected.to contain_file('sources.list').that_notifies('Class[Apt::Update]').only_with(sources_list) + expect(subject).to contain_file('sources.list').that_notifies('Class[Apt::Update]').only_with(sources_list) } it { - is_expected.to contain_file('sources.list.d').that_notifies('Class[Apt::Update]').only_with(sources_list_d) + expect(subject).to contain_file('sources.list.d').that_notifies('Class[Apt::Update]').only_with(sources_list_d) } it { - is_expected.to contain_file('preferences').that_notifies('Class[Apt::Update]').only_with(preferences) + expect(subject).to contain_file('preferences').that_notifies('Class[Apt::Update]').only_with(preferences) } it { - is_expected.to contain_file('preferences.d').that_notifies('Class[Apt::Update]').only_with(preferences_d) + expect(subject).to contain_file('preferences.d').that_notifies('Class[Apt::Update]').only_with(preferences_d) } it { - is_expected.to contain_file('apt.conf.d').that_notifies('Class[Apt::Update]').only_with(apt_conf_d) + expect(subject).to contain_file('apt.conf.d').that_notifies('Class[Apt::Update]').only_with(apt_conf_d) } it { is_expected.to contain_file('/etc/apt/auth.conf').with_ensure('absent') } it 'lays down /etc/apt/apt.conf.d/15update-stamp' do - is_expected.to contain_file('/etc/apt/apt.conf.d/15update-stamp').with(group: 'root', - owner: 'root').with_content( - %r{APT::Update::Post-Invoke-Success {"touch /var/lib/apt/periodic/update-success-stamp 2>/dev/null || true";};}, - ) + expect(subject).to contain_file('/etc/apt/apt.conf.d/15update-stamp').with(group: 'root', + owner: 'root').with_content( + %r{APT::Update::Post-Invoke-Success {"touch /var/lib/apt/periodic/update-success-stamp 2>/dev/null || true";};}, + ) end it { - is_expected.to contain_exec('apt_update').with(refreshonly: 'true') + expect(subject).to contain_exec('apt_update').with(refreshonly: 'true') } it { is_expected.not_to contain_apt__setting('conf-proxy') } @@ -98,7 +98,7 @@ let(:params) { { proxy: { 'host' => 'localhost' } } } it { - is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content( + expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content( %r{Acquire::http::proxy "http://localhost:8080/";}, ).without_content( %r{Acquire::https::proxy }, @@ -110,7 +110,7 @@ let(:params) { { proxy: { 'host' => 'localhost', 'perhost' => [{ 'scope' => 'proxyscope', 'host' => 'proxyhost' }] } } } it { - is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content( + expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content( %r{Acquire::http::proxy::proxyscope "http://proxyhost:8080/";}, ) } @@ -120,7 +120,7 @@ let(:params) { { proxy: { 'host' => 'localhost', 'perhost' => [{ 'scope' => 'proxyscope', 'host' => 'proxyhost', 'port' => 8081 }] } } } it { - is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content( + expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content( %r{Acquire::http::proxy::proxyscope "http://proxyhost:8081/";}, ) } @@ -130,7 +130,7 @@ let(:params) { { proxy: { 'host' => 'localhost', 'perhost' => [{ 'scope' => 'proxyscope', 'host' => 'proxyhost', 'https' => true }] } } } it { - is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content( + expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content( %r{Acquire::https::proxy::proxyscope "https://proxyhost:8080/";}, ) } @@ -140,7 +140,7 @@ let(:params) { { proxy: { 'host' => 'localhost', 'perhost' => [{ 'scope' => 'proxyscope', 'direct' => true }] } } } it { - is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content( + expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content( %r{Acquire::http::proxy::proxyscope "DIRECT";}, ) } @@ -150,7 +150,7 @@ let(:params) { { proxy: { 'host' => 'localhost', 'perhost' => [{ 'scope' => 'proxyscope', 'https' => true, 'direct' => true }] } } } it { - is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content( + expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content( %r{Acquire::https::proxy::proxyscope "DIRECT";}, ) } @@ -160,7 +160,7 @@ let(:params) { { proxy: { 'host' => 'localhost', 'perhost' => [{ 'scope' => 'proxyscope', 'host' => 'proxyhost' }, { 'scope' => 'proxyscope2', 'host' => 'proxyhost2' }] } } } it { - is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content( + expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content( %r{Acquire::http::proxy::proxyscope "http://proxyhost:8080/";}, ).with_content( %r{Acquire::http::proxy::proxyscope2 "http://proxyhost2:8080/";}, @@ -172,7 +172,7 @@ let(:params) { { proxy: { 'host' => 'localhost', 'port' => 8180 } } } it { - is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content( + expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content( %r{Acquire::http::proxy "http://localhost:8180/";}, ).without_content( %r{Acquire::https::proxy }, @@ -184,7 +184,7 @@ let(:params) { { proxy: { 'host' => 'localhost', 'https' => true } } } it { - is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content( + expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content( %r{Acquire::http::proxy "http://localhost:8080/";}, ).with_content( %r{Acquire::https::proxy "https://localhost:8080/";}, @@ -196,7 +196,7 @@ let(:params) { { proxy: { 'host' => 'localhost', 'direct' => true } } } it { - is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content( + expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content( %r{Acquire::http::proxy "http://localhost:8080/";}, ).with_content( %r{Acquire::https::proxy "DIRECT";}, @@ -208,7 +208,7 @@ let(:params) { { proxy: { 'host' => 'localhost', 'https' => true, 'direct' => true } } } it { - is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content( + expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content( %r{Acquire::http::proxy "http://localhost:8080/";}, ).with_content( %r{Acquire::https::proxy "https://localhost:8080/";}, @@ -216,7 +216,7 @@ } it { - is_expected.to contain_apt__setting('conf-proxy').with(priority: '01').with_content( + expect(subject).to contain_apt__setting('conf-proxy').with(priority: '01').with_content( %r{Acquire::http::proxy "http://localhost:8080/";}, ).without_content( %r{Acquire::https::proxy "DIRECT";}, @@ -228,8 +228,8 @@ let(:params) { { proxy: { 'ensure' => 'absent' } } } it { - is_expected.to contain_apt__setting('conf-proxy').with(ensure: 'absent', - priority: '01') + expect(subject).to contain_apt__setting('conf-proxy').with(ensure: 'absent', + priority: '01') } end end @@ -245,32 +245,32 @@ end it { - is_expected.to contain_file('sources.list').with(content: nil) + expect(subject).to contain_file('sources.list').with(content: nil) } it { - is_expected.to contain_file('sources.list.d').with(purge: false, - recurse: false) + expect(subject).to contain_file('sources.list.d').with(purge: false, + recurse: false) } it { - is_expected.to contain_file('preferences').with(ensure: 'file') + expect(subject).to contain_file('preferences').with(ensure: 'file') } it { - is_expected.to contain_file('preferences.d').with(purge: false, - recurse: false) + expect(subject).to contain_file('preferences.d').with(purge: false, + recurse: false) } it { - is_expected.to contain_file('apt.conf.d').with(purge: false, - recurse: false) + expect(subject).to contain_file('apt.conf.d').with(purge: false, + recurse: false) } it { - is_expected.to contain_exec('apt_update').with(refreshonly: false, - timeout: 1, - tries: 3) + expect(subject).to contain_exec('apt_update').with(refreshonly: false, + timeout: 1, + tries: 3) } end @@ -285,32 +285,32 @@ end it { - is_expected.to contain_file('sources.list').with(content: "# Repos managed by puppet.\n") + expect(subject).to contain_file('sources.list').with(content: "# Repos managed by puppet.\n") } it { - is_expected.to contain_file('sources.list.d').with(purge: true, - recurse: true) + expect(subject).to contain_file('sources.list.d').with(purge: true, + recurse: true) } it { - is_expected.to contain_file('preferences').with(ensure: 'absent') + expect(subject).to contain_file('preferences').with(ensure: 'absent') } it { - is_expected.to contain_file('preferences.d').with(purge: true, - recurse: true) + expect(subject).to contain_file('preferences.d').with(purge: true, + recurse: true) } it { - is_expected.to contain_file('apt.conf.d').with(purge: true, - recurse: true) + expect(subject).to contain_file('apt.conf.d').with(purge: true, + recurse: true) } it { - is_expected.to contain_exec('apt_update').with(refreshonly: false, - timeout: 1, - tries: 3) + expect(subject).to contain_exec('apt_update').with(refreshonly: false, + timeout: 1, + tries: 3) } end @@ -324,7 +324,7 @@ end it { - is_expected.to contain_file('sources.list').with(content: "# Repos managed by puppet.\n") + expect(subject).to contain_file('sources.list').with(content: "# Repos managed by puppet.\n") } end @@ -338,7 +338,7 @@ end it { - is_expected.to contain_file('sources.list').with(ensure: 'absent') + expect(subject).to contain_file('sources.list').with(ensure: 'absent') } end @@ -421,12 +421,12 @@ " it { - is_expected.to contain_file('/etc/apt/auth.conf').with(ensure: 'present', - owner: '_apt', - group: 'root', - mode: '0600', - notify: 'Class[Apt::Update]', - content: sensitive(auth_conf_content)) + expect(subject).to contain_file('/etc/apt/auth.conf').with(ensure: 'present', + owner: '_apt', + group: 'root', + mode: '0600', + notify: 'Class[Apt::Update]', + content: sensitive(auth_conf_content)) } end @@ -436,7 +436,7 @@ end it { - is_expected.not_to contain_file('/etc/apt/auth.conf') + expect(subject).not_to contain_file('/etc/apt/auth.conf') } end end @@ -500,14 +500,14 @@ end it { - is_expected.to contain_apt__setting('list-debian_unstable').with(ensure: 'present') + expect(subject).to contain_apt__setting('list-debian_unstable').with(ensure: 'present') } it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(%r{^deb http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free$}) } it { is_expected.to contain_file('/etc/apt/sources.list.d/debian_unstable.list').with_content(%r{^deb-src http://debian.mirror.iweb.ca/debian/ unstable main contrib non-free$}) } it { - is_expected.to contain_apt__setting('list-puppetlabs').with(ensure: 'present') + expect(subject).to contain_apt__setting('list-puppetlabs').with(ensure: 'present') } it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(%r{^deb http://apt.puppetlabs.com bionic main$}) } @@ -542,11 +542,11 @@ end it { - is_expected.to contain_apt__conf('foo').with(content: 'foo') + expect(subject).to contain_apt__conf('foo').with(content: 'foo') } it { - is_expected.to contain_apt__conf('bar').with(content: 'bar') + expect(subject).to contain_apt__conf('bar').with(content: 'bar') } end @@ -579,11 +579,11 @@ end it { - is_expected.to contain_apt__key('55BE302B').with(server: 'subkeys.pgp.net') + expect(subject).to contain_apt__key('55BE302B').with(server: 'subkeys.pgp.net') } it { - is_expected.to contain_apt__key('EF8D349F').with(server: 'pgp.mit.edu') + expect(subject).to contain_apt__key('EF8D349F').with(server: 'pgp.mit.edu') } end @@ -676,7 +676,7 @@ let(:params) { { purge: { 'sources.list' => 'banana' } } } it do - is_expected.to raise_error(Puppet::Error) + expect(subject).to raise_error(Puppet::Error) end end @@ -684,7 +684,7 @@ let(:params) { { purge: { 'sources.list.d' => 'banana' } } } it do - is_expected.to raise_error(Puppet::Error) + expect(subject).to raise_error(Puppet::Error) end end @@ -692,7 +692,7 @@ let(:params) { { purge: { 'preferences' => 'banana' } } } it do - is_expected.to raise_error(Puppet::Error) + expect(subject).to raise_error(Puppet::Error) end end @@ -700,7 +700,7 @@ let(:params) { { purge: { 'preferences.d' => 'banana' } } } it do - is_expected.to raise_error(Puppet::Error) + expect(subject).to raise_error(Puppet::Error) end end @@ -708,7 +708,7 @@ let(:params) { { purge: { 'apt.conf.d' => 'banana' } } } it do - is_expected.to raise_error(Puppet::Error) + expect(subject).to raise_error(Puppet::Error) end end end diff --git a/spec/classes/apt_update_spec.rb b/spec/classes/apt_update_spec.rb index 5a73eb45ec..61335fda20 100644 --- a/spec/classes/apt_update_spec.rb +++ b/spec/classes/apt_update_spec.rb @@ -33,7 +33,7 @@ it 'triggers an apt-get update run' do # set the apt_update exec's refreshonly attribute to false - is_expected.to contain_exec('apt_update').with('refreshonly' => false) + expect(subject).to contain_exec('apt_update').with('refreshonly' => false) end end end @@ -58,7 +58,7 @@ it 'triggers an apt-get update run' do # set the apt_update exec\'s refreshonly attribute to false - is_expected.to contain_exec('apt_update').with('refreshonly' => false) + expect(subject).to contain_exec('apt_update').with('refreshonly' => false) end end @@ -89,7 +89,7 @@ it 'skips an apt-get update run' do # set the apt_update exec's refreshonly attribute to false - is_expected.to contain_exec('apt_update').with('refreshonly' => true) + expect(subject).to contain_exec('apt_update').with('refreshonly' => true) end end end @@ -122,7 +122,7 @@ it 'does not trigger an apt-get update run' do # don't change the apt_update exec's refreshonly attribute. (it should be true) - is_expected.to contain_exec('apt_update').with('refreshonly' => true) + expect(subject).to contain_exec('apt_update').with('refreshonly' => true) end end end @@ -147,7 +147,7 @@ it 'does not trigger an apt-get update run' do # don't change the apt_update exec's refreshonly attribute. (it should be true) - is_expected.to contain_exec('apt_update').with('refreshonly' => true) + expect(subject).to contain_exec('apt_update').with('refreshonly' => true) end end end @@ -177,7 +177,7 @@ it 'triggers an apt-get update run' do # set the apt_update exec\'s refreshonly attribute to false - is_expected.to contain_exec('apt_update').with('refreshonly' => false) + expect(subject).to contain_exec('apt_update').with('refreshonly' => false) end end end @@ -203,7 +203,7 @@ it 'does not trigger an apt-get update run' do # don't change the apt_update exec\'s refreshonly attribute. (it should be true) - is_expected.to contain_exec('apt_update').with('refreshonly' => true) + expect(subject).to contain_exec('apt_update').with('refreshonly' => true) end end @@ -229,7 +229,7 @@ it 'triggers an apt-get update run' do # set the apt_update exec\'s refreshonly attribute to false - is_expected.to contain_exec('apt_update').with('refreshonly' => false) + expect(subject).to contain_exec('apt_update').with('refreshonly' => false) end end end diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index 04551b8e5d..b08cc0f395 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -41,10 +41,10 @@ end it { - is_expected.to contain_file(filename).with('ensure' => 'present', - 'content' => %r{Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;}, - 'owner' => 'root', - 'group' => 'root') + expect(subject).to contain_file(filename).with('ensure' => 'present', + 'content' => %r{Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;}, + 'owner' => 'root', + 'group' => 'root') } context 'with notify_update = true (default)' do @@ -72,7 +72,7 @@ end it 'fails' do - is_expected.to raise_error(%r{pass in content}) + expect(subject).to raise_error(%r{pass in content}) end end @@ -89,9 +89,9 @@ end it { - is_expected.to contain_file(filename).with('ensure' => 'absent', - 'owner' => 'root', - 'group' => 'root') + expect(subject).to contain_file(filename).with('ensure' => 'absent', + 'owner' => 'root', + 'group' => 'root') } end end diff --git a/spec/defines/key_compat_spec.rb b/spec/defines/key_compat_spec.rb index ab305a99d3..f414503ac3 100644 --- a/spec/defines/key_compat_spec.rb +++ b/spec/defines/key_compat_spec.rb @@ -51,15 +51,15 @@ def apt_key_example(title) describe 'normal operation' do describe 'default options' do it { - is_expected.to contain_apt_key(title).with(id: title, - ensure: 'present', - source: nil, - server: 'keyserver.ubuntu.com', - content: nil) + expect(subject).to contain_apt_key(title).with(id: title, + ensure: 'present', + source: nil, + server: 'keyserver.ubuntu.com', + content: nil) } it 'contains the apt_key present anchor' do - is_expected.to contain_anchor("apt_key #{title} present") + expect(subject).to contain_anchor("apt_key #{title} present") end end @@ -75,15 +75,15 @@ def apt_key_example(title) end it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with(id: GPG_KEY_ID, - ensure: 'present', - source: nil, - server: 'keyserver.ubuntu.com', - content: nil) + expect(subject).to contain_apt_key(title).with(id: GPG_KEY_ID, + ensure: 'present', + source: nil, + server: 'keyserver.ubuntu.com', + content: nil) end it 'contains the apt_key present anchor' do - is_expected.to contain_anchor("apt_key #{GPG_KEY_ID} present") + expect(subject).to contain_anchor("apt_key #{GPG_KEY_ID} present") end end @@ -95,15 +95,15 @@ def apt_key_example(title) end it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with(id: title, - ensure: 'absent', - source: nil, - server: 'keyserver.ubuntu.com', - content: nil) + expect(subject).to contain_apt_key(title).with(id: title, + ensure: 'absent', + source: nil, + server: 'keyserver.ubuntu.com', + content: nil) end it 'contains the apt_key absent anchor' do - is_expected.to contain_anchor("apt_key #{title} absent") + expect(subject).to contain_anchor("apt_key #{title} absent") end end @@ -118,11 +118,11 @@ def apt_key_example(title) end it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with(contains_apt_key_example(title)) + expect(subject).to contain_apt_key(title).with(contains_apt_key_example(title)) end it 'contains the apt_key present anchor' do - is_expected.to contain_anchor("apt_key #{title} present") + expect(subject).to contain_anchor("apt_key #{title} present") end end @@ -134,8 +134,8 @@ def apt_key_example(title) end it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with(id: title, - server: 'p-gp.m-it.edu') + expect(subject).to contain_apt_key(title).with(id: title, + server: 'p-gp.m-it.edu') end end @@ -147,8 +147,8 @@ def apt_key_example(title) end it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with(id: title, - server: 'hkp://pgp.mit.edu') + expect(subject).to contain_apt_key(title).with(id: title, + server: 'hkp://pgp.mit.edu') end end @@ -160,8 +160,8 @@ def apt_key_example(title) end it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with(id: title, - server: 'hkp://pgp.mit.edu:80') + expect(subject).to contain_apt_key(title).with(id: title, + server: 'hkp://pgp.mit.edu:80') end end end @@ -175,7 +175,7 @@ def apt_key_example(title) end it 'fails' do - is_expected.to raise_error(%r{expects a match}) + expect(subject).to raise_error(%r{expects a match}) end end @@ -187,7 +187,7 @@ def apt_key_example(title) end it 'fails' do - is_expected.to raise_error(%r{expects a match}) + expect(subject).to raise_error(%r{expects a match}) end end @@ -199,7 +199,7 @@ def apt_key_example(title) end it 'fails' do - is_expected.to raise_error(%r{expects a match}) + expect(subject).to raise_error(%r{expects a match}) end end @@ -211,7 +211,7 @@ def apt_key_example(title) end it 'fails' do - is_expected.to raise_error(%r{expects a match}) + expect(subject).to raise_error(%r{expects a match}) end end @@ -223,11 +223,11 @@ def apt_key_example(title) end it 'fails' do - is_expected.to raise_error(%r{expects a match}) + expect(subject).to raise_error(%r{expects a match}) end end - context 'with incorrect protocol for url' do + context 'with incorrect protocol for url' do let :params do { server: 'abc://pgp.mit.edu:80', @@ -235,7 +235,7 @@ def apt_key_example(title) end it 'fails' do - is_expected.to raise_error(%r{expects a match}) + expect(subject).to raise_error(%r{expects a match}) end end @@ -247,7 +247,7 @@ def apt_key_example(title) end it 'fails' do - is_expected.to raise_error(%r{expects a match}) + expect(subject).to raise_error(%r{expects a match}) end end @@ -259,7 +259,7 @@ def apt_key_example(title) end it 'fails' do - is_expected.to raise_error(%r{expects a match}) + expect(subject).to raise_error(%r{expects a match}) end end @@ -271,7 +271,7 @@ def apt_key_example(title) end it 'fails' do - is_expected.to raise_error(%r{expects a match}) + expect(subject).to raise_error(%r{expects a match}) end end @@ -281,7 +281,7 @@ def apt_key_example(title) end it 'fails' do - is_expected.to raise_error(%r{expects a match}) + expect(subject).to raise_error(%r{expects a match}) end end @@ -293,7 +293,7 @@ def apt_key_example(title) end it 'fails' do - is_expected.to raise_error(%r{evaluating a Resource}) + expect(subject).to raise_error(%r{evaluating a Resource}) end end @@ -305,7 +305,7 @@ def apt_key_example(title) end it 'fails' do - is_expected.to raise_error(%r{expects a}) + expect(subject).to raise_error(%r{expects a}) end end @@ -317,7 +317,7 @@ def apt_key_example(title) end it 'fails' do - is_expected.to raise_error(%r{expects a match}) + expect(subject).to raise_error(%r{expects a match}) end end @@ -329,7 +329,7 @@ def apt_key_example(title) end it 'fails' do - is_expected.to raise_error(%r{expects a}) + expect(subject).to raise_error(%r{expects a}) end end @@ -341,7 +341,7 @@ def apt_key_example(title) end it 'fails' do - is_expected.to raise_error(%r{Enum\['absent', 'present', 'refreshed'\]}) + expect(subject).to raise_error(%r{Enum\['absent', 'present', 'refreshed'\]}) end end @@ -351,21 +351,21 @@ def apt_key_example(title) end it 'contains the duplicate apt::key resource' do - is_expected.to contain_apt__key('duplicate').with(id: title, - ensure: 'present') + expect(subject).to contain_apt__key('duplicate').with(id: title, + ensure: 'present') end it 'contains the original apt::key resource' do - is_expected.to contain_apt__key(title).with(id: title, - ensure: 'present') + expect(subject).to contain_apt__key(title).with(id: title, + ensure: 'present') end it 'contains the native apt_key' do - is_expected.to contain_apt_key('duplicate').with(apt_key_example(title)) + expect(subject).to contain_apt_key('duplicate').with(apt_key_example(title)) end it 'does not contain the original apt_key' do - is_expected.not_to contain_apt_key(title) + expect(subject).not_to contain_apt_key(title) end end @@ -375,7 +375,7 @@ def apt_key_example(title) end it 'informs the user of the impossibility' do - is_expected.to raise_error(%r{already ensured as absent}) + expect(subject).to raise_error(%r{already ensured as absent}) end end end diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index 956c9b68dd..948833a3fd 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -68,11 +68,11 @@ def absent_apt_key(title) describe 'normal operation' do describe 'default options' do it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with(default_apt_key_example(title)) + expect(subject).to contain_apt_key(title).with(default_apt_key_example(title)) end it 'contains the apt_key present anchor' do - is_expected.to contain_anchor("apt_key #{title} present") + expect(subject).to contain_anchor("apt_key #{title} present") end end @@ -88,11 +88,11 @@ def absent_apt_key(title) end it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with(title_key_example) + expect(subject).to contain_apt_key(title).with(title_key_example) end it 'contains the apt_key present anchor' do - is_expected.to contain_anchor("apt_key #{GPG_KEY_ID} present") + expect(subject).to contain_anchor("apt_key #{GPG_KEY_ID} present") end end @@ -104,11 +104,11 @@ def absent_apt_key(title) end it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with(absent_apt_key(title)) + expect(subject).to contain_apt_key(title).with(absent_apt_key(title)) end it 'contains the apt_key absent anchor' do - is_expected.to contain_anchor("apt_key #{title} absent") + expect(subject).to contain_anchor("apt_key #{title} absent") end end @@ -120,7 +120,7 @@ def absent_apt_key(title) end it 'contains the apt_key with refresh => true' do - is_expected.to contain_apt_key(title).with( + expect(subject).to contain_apt_key(title).with( ensure: 'present', refresh: true, ) @@ -138,11 +138,11 @@ def absent_apt_key(title) end it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with(bunch_things_apt_key_example(title, params)) + expect(subject).to contain_apt_key(title).with(bunch_things_apt_key_example(title, params)) end it 'contains the apt_key present anchor' do - is_expected.to contain_anchor("apt_key #{title} present") + expect(subject).to contain_anchor("apt_key #{title} present") end end @@ -154,8 +154,8 @@ def absent_apt_key(title) end it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with(id: title, - server: 'p-gp.m-it.edu') + expect(subject).to contain_apt_key(title).with(id: title, + server: 'p-gp.m-it.edu') end end @@ -167,8 +167,8 @@ def absent_apt_key(title) end it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with(id: title, - server: 'hkp://pgp.mit.edu') + expect(subject).to contain_apt_key(title).with(id: title, + server: 'hkp://pgp.mit.edu') end end @@ -180,8 +180,8 @@ def absent_apt_key(title) end it 'contains the apt_key' do - is_expected.to contain_apt_key(title).with(id: title, - server: 'hkp://pgp.mit.edu:80') + expect(subject).to contain_apt_key(title).with(id: title, + server: 'hkp://pgp.mit.edu:80') end end end @@ -195,7 +195,7 @@ def absent_apt_key(title) end it 'fails' do - is_expected.to raise_error(%r{expects a match}) + expect(subject).to raise_error(%r{expects a match}) end end @@ -207,7 +207,7 @@ def absent_apt_key(title) end it 'fails' do - is_expected.to raise_error(%r{expects a match}) + expect(subject).to raise_error(%r{expects a match}) end end @@ -219,7 +219,7 @@ def absent_apt_key(title) end it 'fails' do - is_expected.to raise_error(%r{expects a match}) + expect(subject).to raise_error(%r{expects a match}) end end @@ -231,7 +231,7 @@ def absent_apt_key(title) end it 'fails' do - is_expected.to raise_error(%r{expects a match}) + expect(subject).to raise_error(%r{expects a match}) end end @@ -243,7 +243,7 @@ def absent_apt_key(title) end it 'fails' do - is_expected.to raise_error(%r{expects a match}) + expect(subject).to raise_error(%r{expects a match}) end end @@ -255,7 +255,7 @@ def absent_apt_key(title) end it 'fails' do - is_expected.to raise_error(%r{expects a match}) + expect(subject).to raise_error(%r{expects a match}) end end @@ -267,7 +267,7 @@ def absent_apt_key(title) end it 'fails' do - is_expected.to raise_error(%r{expects a match}) + expect(subject).to raise_error(%r{expects a match}) end end @@ -279,7 +279,7 @@ def absent_apt_key(title) end it 'fails' do - is_expected.to raise_error(%r{expects a match}) + expect(subject).to raise_error(%r{expects a match}) end end @@ -291,7 +291,7 @@ def absent_apt_key(title) end it 'fails' do - is_expected.to raise_error(%r{expects a match}) + expect(subject).to raise_error(%r{expects a match}) end end @@ -301,7 +301,7 @@ def absent_apt_key(title) end it 'fails' do - is_expected.to raise_error(%r{expects a match}) + expect(subject).to raise_error(%r{expects a match}) end end @@ -313,7 +313,7 @@ def absent_apt_key(title) end it 'fails' do - is_expected.to raise_error(%r{evaluating a Resource}) + expect(subject).to raise_error(%r{evaluating a Resource}) end end @@ -325,7 +325,7 @@ def absent_apt_key(title) end it 'fails' do - is_expected.to raise_error(%r{expects a}) + expect(subject).to raise_error(%r{expects a}) end end @@ -337,7 +337,7 @@ def absent_apt_key(title) end it 'fails' do - is_expected.to raise_error(%r{expects a match}) + expect(subject).to raise_error(%r{expects a match}) end end @@ -349,7 +349,7 @@ def absent_apt_key(title) end it 'fails' do - is_expected.to raise_error(%r{expects a}) + expect(subject).to raise_error(%r{expects a}) end end @@ -362,7 +362,7 @@ def absent_apt_key(title) end it 'fails' do - is_expected.to raise_error(%r{for Enum\['absent', 'present', 'refreshed'\], got}) + expect(subject).to raise_error(%r{for Enum\['absent', 'present', 'refreshed'\], got}) end end end @@ -374,21 +374,21 @@ def absent_apt_key(title) end it 'contains two apt::key resource - duplicate' do - is_expected.to contain_apt__key('duplicate').with(id: title, - ensure: 'present') + expect(subject).to contain_apt__key('duplicate').with(id: title, + ensure: 'present') end it 'contains two apt::key resource - title' do - is_expected.to contain_apt__key(title).with(id: title, - ensure: 'present') + expect(subject).to contain_apt__key(title).with(id: title, + ensure: 'present') end it 'contains only a single apt_key - duplicate' do - is_expected.to contain_apt_key('duplicate').with(default_apt_key_example(title)) + expect(subject).to contain_apt_key('duplicate').with(default_apt_key_example(title)) end it 'contains only a single apt_key - no title' do - is_expected.not_to contain_apt_key(title) + expect(subject).not_to contain_apt_key(title) end end @@ -399,7 +399,7 @@ def absent_apt_key(title) end it 'informs the user of the impossibility' do - is_expected.to raise_error(%r{already ensured as absent}) + expect(subject).to raise_error(%r{already ensured as absent}) end end end @@ -413,7 +413,7 @@ def absent_apt_key(title) end it 'uses default keyserver' do - is_expected.to contain_apt_key(title).with_server('keyserver.example.com') + expect(subject).to contain_apt_key(title).with_server('keyserver.example.com') end end @@ -425,7 +425,7 @@ def absent_apt_key(title) end it 'uses default keyserver' do - is_expected.to contain_apt_key(title).with_options('http-proxy=http://proxy.example.com:8080') + expect(subject).to contain_apt_key(title).with_options('http-proxy=http://proxy.example.com:8080') end end end diff --git a/spec/defines/mark_spec.rb b/spec/defines/mark_spec.rb index 5375fe236f..cdff673a9e 100644 --- a/spec/defines/mark_spec.rb +++ b/spec/defines/mark_spec.rb @@ -32,7 +32,7 @@ end it { - is_expected.to contain_exec('apt-mark manual mysource') + expect(subject).to contain_exec('apt-mark manual mysource') } end @@ -44,7 +44,7 @@ end it do - is_expected.to raise_error(Puppet::PreformattedError, %r{expects a match for Enum\['auto', 'hold', 'manual', 'unhold'\], got 'foobar'}) + expect(subject).to raise_error(Puppet::PreformattedError, %r{expects a match for Enum\['auto', 'hold', 'manual', 'unhold'\], got 'foobar'}) end end @@ -70,7 +70,7 @@ end it do - is_expected.to contain_exec("apt-mark manual #{title}") + expect(subject).to contain_exec("apt-mark manual #{title}") end end end @@ -99,7 +99,7 @@ end it do - is_expected.to raise_error(Puppet::PreformattedError, %r{Invalid package name: #{title}}) + expect(subject).to raise_error(Puppet::PreformattedError, %r{Invalid package name: #{title}}) end end end diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index 8b30a4c770..bd2c26287b 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -67,7 +67,7 @@ it { is_expected.to contain_apt__setting('pref-my_pin').with_content(%r{Explanation: foo\nPackage: \*\nPin: release a=1, n=bar, v=2, c=baz, o=foobar, l=foobaz\nPin-Priority: 10\n}) } it { - is_expected.to contain_apt__setting('pref-my_pin').with('priority' => 99) + expect(subject).to contain_apt__setting('pref-my_pin').with('priority' => 99) } end @@ -79,7 +79,7 @@ end it { - is_expected.to contain_apt__setting('pref-my_pin').with('ensure' => 'absent') + expect(subject).to contain_apt__setting('pref-my_pin').with('ensure' => 'absent') } end @@ -98,7 +98,7 @@ end it do - is_expected.to raise_error(Puppet::Error, %r{expects an Integer value, got String}) + expect(subject).to raise_error(Puppet::Error, %r{expects an Integer value, got String}) end end @@ -110,7 +110,7 @@ end it do - is_expected.to raise_error(Puppet::Error, %r{parameter version cannot be used in general form}) + expect(subject).to raise_error(Puppet::Error, %r{parameter version cannot be used in general form}) end end @@ -123,7 +123,7 @@ end it do - is_expected.to raise_error(Puppet::Error, %r{parameters release and origin are mutually exclusive}) + expect(subject).to raise_error(Puppet::Error, %r{parameters release and origin are mutually exclusive}) end end @@ -137,7 +137,7 @@ end it do - is_expected.to raise_error(Puppet::Error, %r{parameters release, origin, and version are mutually exclusive}) + expect(subject).to raise_error(Puppet::Error, %r{parameters release, origin, and version are mutually exclusive}) end end @@ -151,7 +151,7 @@ end it do - is_expected.to raise_error(Puppet::Error, %r{parameters release, origin, and version are mutually exclusive}) + expect(subject).to raise_error(Puppet::Error, %r{parameters release, origin, and version are mutually exclusive}) end end end diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 4732350e84..3d109aed75 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -39,7 +39,7 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) it { is_expected.not_to contain_package('python-software-properties') } it { - is_expected.to contain_exec('add-apt-repository-ppa:needs/substitution') + expect(subject).to contain_exec('add-apt-repository-ppa:needs/substitution') .that_notifies('Class[Apt::Update]') .with(*ppa_exec_params('needs', 'substitution')) } @@ -130,7 +130,7 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) let(:title) { 'ppa:user/foo' } it { - is_expected.to contain_exec('add-apt-repository-ppa:user/foo') + expect(subject).to contain_exec('add-apt-repository-ppa:user/foo') .that_notifies('Class[Apt::Update]') .with(*ppa_exec_params('user', 'foo', 'wily')) } @@ -171,7 +171,7 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) it { is_expected.to contain_package('software-properties-common') } it { - is_expected.to contain_exec('add-apt-repository-ppa:needs/substitution') + expect(subject).to contain_exec('add-apt-repository-ppa:needs/substitution') .that_notifies('Class[Apt::Update]') .with(*ppa_exec_params('needs', 'substitution')) } @@ -211,7 +211,7 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) it { is_expected.not_to contain_package('python-software-properties') } it { - is_expected.to contain_exec('add-apt-repository-ppa:needs/substitution') + expect(subject).to contain_exec('add-apt-repository-ppa:needs/substitution') .that_notifies('Class[Apt::Update]') .with(*ppa_exec_params('needs', 'substitution')) } @@ -255,7 +255,7 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) it { is_expected.to contain_package('software-properties-common') } it { - is_expected.to contain_exec('add-apt-repository-ppa:user/foo') + expect(subject).to contain_exec('add-apt-repository-ppa:user/foo') .that_notifies('Class[Apt::Update]') .with(*ppa_exec_params('user', 'foo')) } @@ -297,7 +297,7 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) it { is_expected.to contain_package('software-properties-common') } it { - is_expected.to contain_exec('add-apt-repository-ppa:user/foo') + expect(subject).to contain_exec('add-apt-repository-ppa:user/foo') .that_notifies('Class[Apt::Update]') .with(*ppa_exec_params('user', 'foo', 'trusty', ['http_proxy=http://localhost:8080'])) } @@ -339,7 +339,7 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) it { is_expected.to contain_package('software-properties-common') } it { - is_expected.to contain_exec('add-apt-repository-ppa:user/foo') + expect(subject).to contain_exec('add-apt-repository-ppa:user/foo') .that_notifies('Class[Apt::Update]') .with(*ppa_exec_params('user', 'foo', 'trusty', ['http_proxy=http://localhost:8180'])) } @@ -381,7 +381,7 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) it { is_expected.to contain_package('software-properties-common') } it { - is_expected.to contain_exec('add-apt-repository-ppa:user/foo') + expect(subject).to contain_exec('add-apt-repository-ppa:user/foo') .that_notifies('Class[Apt::Update]') .with(*ppa_exec_params('user', 'foo', 'trusty', ['http_proxy=http://localhost:8180', 'https_proxy=https://localhost:8180'])) } @@ -419,10 +419,10 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) end it { - is_expected.to contain_tidy("remove-apt-repository-script-#{title}") + expect(subject).to contain_tidy("remove-apt-repository-script-#{title}") .with('path' => '/opt/puppetlabs/puppet/cache/add-apt-repository-user-ubuntu-foo-trusty.sh') - is_expected.to contain_tidy("remove-apt-repository-#{title}") + expect(subject).to contain_tidy("remove-apt-repository-#{title}") .with('path' => '/etc/apt/sources.list.d/user-ubuntu-foo-trusty.list') .that_notifies('Class[Apt::Update]') } @@ -450,7 +450,7 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) let(:title) { 'ppa:user/foo' } it do - is_expected.to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required}) + expect(subject).to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required}) end end @@ -475,7 +475,7 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) let(:title) { 'ppa:user/foo' } it do - is_expected.to raise_error(Puppet::Error, %r{not currently supported on Debian}) + expect(subject).to raise_error(Puppet::Error, %r{not currently supported on Debian}) end end end diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb index 97ebdc4658..a142667d55 100644 --- a/spec/defines/setting_spec.rb +++ b/spec/defines/setting_spec.rb @@ -27,11 +27,11 @@ describe 'when using the defaults' do context 'without source or content' do it do - is_expected.to raise_error(Puppet::Error, %r{needs either of }) + expect(subject).to raise_error(Puppet::Error, %r{needs either of }) end end - context 'with title=conf-teddybear ' do + context 'with title=conf-teddybear' do let(:params) { default_params } it { is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]') } @@ -55,10 +55,10 @@ let(:params) { { source: 'puppet:///la/die/dah' } } it { - is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'file', - owner: 'root', - group: 'root', - source: params[:source].to_s) + expect(subject).to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'file', + owner: 'root', + group: 'root', + source: params[:source].to_s) } end @@ -66,10 +66,10 @@ let(:params) { default_params } it { - is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'file', - owner: 'root', - group: 'root', - content: params[:content].to_s) + expect(subject).to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'file', + owner: 'root', + group: 'root', + content: params[:content].to_s) } end end @@ -109,7 +109,7 @@ let(:params) { default_params.merge(source: 'la') } it do - is_expected.to raise_error(Puppet::Error, %r{cannot have both }) + expect(subject).to raise_error(Puppet::Error, %r{cannot have both }) end end @@ -118,7 +118,7 @@ let(:params) { default_params } it do - is_expected.to raise_error(Puppet::Error, %r{must start with either}) + expect(subject).to raise_error(Puppet::Error, %r{must start with either}) end end @@ -126,7 +126,7 @@ let(:params) { default_params.merge(ensure: 'banana') } it do - is_expected.to raise_error(Puppet::Error, %r{Enum\['absent', 'file', 'present'\]}) + expect(subject).to raise_error(Puppet::Error, %r{Enum\['absent', 'file', 'present'\]}) end end @@ -147,7 +147,7 @@ let(:params) { default_params.merge(ensure: 'absent') } it { - is_expected.to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'absent') + expect(subject).to contain_file('/etc/apt/apt.conf.d/50teddybear').that_notifies('Class[Apt::Update]').with(ensure: 'absent') } end end diff --git a/spec/defines/source_compat_spec.rb b/spec/defines/source_compat_spec.rb index 7eef4fd23e..dc261fbb88 100644 --- a/spec/defines/source_compat_spec.rb +++ b/spec/defines/source_compat_spec.rb @@ -35,7 +35,7 @@ end it { - is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb-src http://debian.mirror.iweb.ca/debian/ stretch main\n}) + expect(subject).to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb-src http://debian.mirror.iweb.ca/debian/ stretch main\n}) } end @@ -55,19 +55,19 @@ end it { - is_expected.to contain_apt__setting('list-my_source').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n}) - .without_content(%r{deb-src}) + expect(subject).to contain_apt__setting('list-my_source').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n}) + .without_content(%r{deb-src}) } it { - is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present', - 'priority' => '10', - 'origin' => 'debian.mirror.iweb.ca') + expect(subject).to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present', + 'priority' => '10', + 'origin' => 'debian.mirror.iweb.ca') } it { - is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present', - 'id' => GPG_KEY_ID) + expect(subject).to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present', + 'id' => GPG_KEY_ID) } end @@ -104,7 +104,7 @@ end it { - is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb \[arch=x86_64\] http://debian.mirror.iweb.ca/debian/ stretch main\n}) + expect(subject).to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb \[arch=x86_64\] http://debian.mirror.iweb.ca/debian/ stretch main\n}) } end @@ -116,7 +116,7 @@ end it { - is_expected.to contain_apt__setting('list-my_source').with('ensure' => 'absent') + expect(subject).to contain_apt__setting('list-my_source').with('ensure' => 'absent') } end @@ -139,7 +139,7 @@ end it do - is_expected.to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required}) + expect(subject).to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required}) end end end diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index b2c09891c1..798279e6b2 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -33,7 +33,7 @@ context 'with defaults' do context 'without location' do it do - is_expected.to raise_error(Puppet::Error, %r{source entry without specifying a location}) + expect(subject).to raise_error(Puppet::Error, %r{source entry without specifying a location}) end end @@ -41,8 +41,8 @@ let(:params) { { location: 'hello.there' } } it { - is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{# my_source\ndeb-src hello.there wheezy main\n}) - is_expected.not_to contain_package('apt-transport-https') + expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{# my_source\ndeb-src hello.there wheezy main\n}) + expect(subject).not_to contain_package('apt-transport-https') } end end @@ -59,16 +59,16 @@ end it { - is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{hello.there stretch main\n}) + expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{hello.there stretch main\n}) } it { is_expected.to contain_file('/etc/apt/sources.list.d/my_source.list').that_notifies('Class[Apt::Update]') } it { - is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present', - priority: 1001, - explanation: 'wishwash', - release: 'wishwash') + expect(subject).to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present', + priority: 1001, + explanation: 'wishwash', + release: 'wishwash') } end @@ -87,19 +87,19 @@ end it { - is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n}) - .without_content(%r{deb-src}) + expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n}) + .without_content(%r{deb-src}) } it { - is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present', - priority: '10', - origin: 'debian.mirror.iweb.ca') + expect(subject).to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present', + priority: '10', + origin: 'debian.mirror.iweb.ca') } it { - is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present', - id: GPG_KEY_ID) + expect(subject).to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present', + id: GPG_KEY_ID) } end @@ -125,23 +125,23 @@ end it { - is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n}) - .without_content(%r{deb-src}) + expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# foo\ndeb \[arch=x86_64 trusted=yes\] http://debian.mirror.iweb.ca/debian/ sid testing\n}) + .without_content(%r{deb-src}) } it { - is_expected.to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present', - priority: '10', - origin: 'debian.mirror.iweb.ca') + expect(subject).to contain_apt__pin('my_source').that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present', + priority: '10', + origin: 'debian.mirror.iweb.ca') } it { - is_expected.to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'refreshed', - id: GPG_KEY_ID, - server: 'pgp.mit.edu', - content: 'GPG key content', - source: 'http://apt.puppetlabs.com/pubkey.gpg', - weak_ssl: true) + expect(subject).to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'refreshed', + id: GPG_KEY_ID, + server: 'pgp.mit.edu', + content: 'GPG key content', + source: 'http://apt.puppetlabs.com/pubkey.gpg', + weak_ssl: true) } end end @@ -155,7 +155,7 @@ end it { - is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[allow-insecure=yes\] hello.there stretch main\n}) + expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[allow-insecure=yes\] hello.there stretch main\n}) } end @@ -168,7 +168,7 @@ end it { - is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[trusted=yes\] hello.there stretch main\n}) + expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[trusted=yes\] hello.there stretch main\n}) } end @@ -181,7 +181,7 @@ end it { - is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[check-valid-until=false\] hello.there stretch main\n}) + expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[check-valid-until=false\] hello.there stretch main\n}) } end @@ -194,7 +194,7 @@ end it { - is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb hello.there stretch main\n}) + expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb hello.there stretch main\n}) } end @@ -207,7 +207,7 @@ end it { - is_expected.to contain_apt__setting('list-my_source') + expect(subject).to contain_apt__setting('list-my_source') .with(ensure: 'present') .with_content(%r{# my_source\ndeb \[signed-by=/usr/share/keyrings/foo-archive-keyring.gpg\] hello.there stretch main\n}) } @@ -224,7 +224,7 @@ end it { - is_expected.to contain_apt__setting('list-my_source') + expect(subject).to contain_apt__setting('list-my_source') .with(ensure: 'present') .with_content(%r{# my_source\ndeb \[arch=amd64 trusted=yes signed-by=/usr/share/keyrings/foo-archive-keyring.gpg\] hello.there stretch main\n}) } @@ -239,7 +239,7 @@ end it { - is_expected.to contain_package('apt-transport-https') + expect(subject).to contain_package('apt-transport-https') } end @@ -270,7 +270,7 @@ end it { - is_expected.to contain_package('apt-transport-https') + expect(subject).to contain_package('apt-transport-https') } end @@ -299,7 +299,7 @@ end it { - is_expected.not_to contain_package('apt-transport-https') + expect(subject).not_to contain_package('apt-transport-https') } end @@ -329,7 +329,7 @@ end it { - is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb-src \[arch=x86_64\] hello.there wheezy main\n}) + expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb-src \[arch=x86_64\] hello.there wheezy main\n}) } end @@ -345,7 +345,7 @@ end it { - is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb-src hello.there stretch main\n}) + expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb-src hello.there stretch main\n}) } end @@ -358,7 +358,7 @@ end it { - is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb hello.there stretch main\ndeb-src hello.there stretch main\n}) + expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb hello.there stretch main\ndeb-src hello.there stretch main\n}) } end @@ -371,7 +371,7 @@ end it { - is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{deb-src hello.there wheezy main\n}) + expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').without_content(%r{deb-src hello.there wheezy main\n}) } it { is_expected.to contain_apt__setting('list-my_source').without_content(%r{deb hello.there wheezy main\n}) } @@ -386,7 +386,7 @@ end it { - is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{deb-src hello.there stretch main\n}) + expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{deb-src hello.there stretch main\n}) } it { is_expected.to contain_apt__setting('list-my_source').without_content(%r{deb hello.there stretch main\n}) } @@ -400,7 +400,7 @@ end it { - is_expected.to contain_apt__setting('list-my_source').with(ensure: 'absent') + expect(subject).to contain_apt__setting('list-my_source').with(ensure: 'absent') } end @@ -424,7 +424,7 @@ let(:params) { { location: 'hello.there' } } it do - is_expected.to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required}) + expect(subject).to raise_error(Puppet::Error, %r{os.distro.codename fact not available: release parameter required}) end end @@ -443,7 +443,7 @@ end it do - is_expected.to raise_error(Puppet::Error, %r{expects a value}) + expect(subject).to raise_error(Puppet::Error, %r{expects a value}) end end diff --git a/spec/unit/facter/apt_update_last_success_spec.rb b/spec/unit/facter/apt_update_last_success_spec.rb index c0b028aac9..05a12240aa 100644 --- a/spec/unit/facter/apt_update_last_success_spec.rb +++ b/spec/unit/facter/apt_update_last_success_spec.rb @@ -11,7 +11,7 @@ it 'has a value of -1' do allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian') allow(File).to receive(:exist?).with('/var/lib/apt/periodic/update-success-stamp').and_return(false) - is_expected.to eq(-1) + expect(subject).to eq(-1) end end @@ -20,7 +20,7 @@ allow(Facter.fact(:osfamily)).to receive(:value).and_return('Debian') allow(File).to receive(:exist?).and_return(true) allow(File).to receive(:mtime).and_return(1_407_660_561) - is_expected.to eq(1_407_660_561) + expect(subject).to eq(1_407_660_561) end end end diff --git a/spec/unit/puppet/provider/apt_key_spec.rb b/spec/unit/puppet/provider/apt_key_spec.rb index 668a953bff..6da7016dbd 100644 --- a/spec/unit/puppet/provider/apt_key_spec.rb +++ b/spec/unit/puppet/provider/apt_key_spec.rb @@ -58,7 +58,7 @@ it 'apt_key with content set and source nil' do expect(described_class).to receive(:apt_key).with(['adv', '--no-tty', '--keyserver', - :"keyserver.ubuntu.com", + :'keyserver.ubuntu.com', '--recv-keys', 'C105B9DE']) resource = Puppet::Type::Apt_key.new(name: 'source and content nil', @@ -74,7 +74,7 @@ it 'apt_key content and source nil, options set' do expect(described_class).to receive(:apt_key).with(['adv', '--no-tty', '--keyserver', - :"keyserver.ubuntu.com", + :'keyserver.ubuntu.com', '--keyserver-options', 'jimno', '--recv-keys', @@ -149,7 +149,7 @@ it "#{key_type} #{value} is valid" do expect(described_class).to receive(:apt_key).with(array_including('adv', '--no-tty', '--keyserver', - :"keyserver.ubuntu.com", + :'keyserver.ubuntu.com', '--recv-keys')) resource = Puppet::Type::Apt_key.new(name: 'source and content nil', id: value, From 3cff22c493a803b407f7dfd4277d33624877c69f Mon Sep 17 00:00:00 2001 From: david22swan Date: Fri, 21 Apr 2023 13:49:22 +0100 Subject: [PATCH 09/18] (CONT-773) Rubocop Auto Fixes 16-17 - Style/RescueStandardError - Style/TrailingCommaInHashLiteral --- .rubocop_todo.yml | 30 ------ lib/puppet/provider/apt_key/apt_key.rb | 2 +- spec/classes/apt_backports_spec.rb | 76 ++++++------- spec/classes/apt_spec.rb | 126 +++++++++++----------- spec/classes/apt_update_spec.rb | 68 ++++++------ spec/defines/conf_spec.rb | 14 +-- spec/defines/key_compat_spec.rb | 48 ++++----- spec/defines/key_spec.rb | 50 ++++----- spec/defines/mark_spec.rb | 16 +-- spec/defines/pin_spec.rb | 26 ++--- spec/defines/ppa_spec.rb | 116 ++++++++++---------- spec/defines/setting_spec.rb | 16 +-- spec/defines/source_compat_spec.rb | 28 ++--- spec/defines/source_spec.rb | 86 +++++++-------- spec/spec_helper.rb | 4 +- spec/unit/puppet/provider/apt_key_spec.rb | 2 +- 16 files changed, 339 insertions(+), 369 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a088dced4b..6da30678d8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -167,38 +167,8 @@ Style/MixinUsage: Exclude: - 'spec/spec_helper.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyle. -# SupportedStyles: implicit, explicit -Style/RescueStandardError: - Exclude: - - 'spec/spec_helper.rb' - # Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). Style/SlicingWithRange: Exclude: - 'lib/puppet/provider/apt_key/apt_key.rb' - -# Offense count: 338 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: EnforcedStyleForMultiline. -# SupportedStylesForMultiline: comma, consistent_comma, no_comma -Style/TrailingCommaInHashLiteral: - Exclude: - - 'lib/puppet/provider/apt_key/apt_key.rb' - - 'spec/classes/apt_backports_spec.rb' - - 'spec/classes/apt_spec.rb' - - 'spec/classes/apt_update_spec.rb' - - 'spec/defines/conf_spec.rb' - - 'spec/defines/key_compat_spec.rb' - - 'spec/defines/key_spec.rb' - - 'spec/defines/mark_spec.rb' - - 'spec/defines/pin_spec.rb' - - 'spec/defines/ppa_spec.rb' - - 'spec/defines/setting_spec.rb' - - 'spec/defines/source_compat_spec.rb' - - 'spec/defines/source_spec.rb' - - 'spec/spec_helper.rb' - - 'spec/unit/puppet/provider/apt_key_spec.rb' diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index c91e26ecb6..c15d826bb9 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -96,7 +96,7 @@ def self.key_line_hash(pub_line, fpr_line) key_size: pub_split[2], key_type: nil, key_created: Time.at(pub_split[5].to_i), - key_expiry: pub_split[6].empty? ? nil : Time.at(pub_split[6].to_i), + key_expiry: pub_split[6].empty? ? nil : Time.at(pub_split[6].to_i) } # set key type based on types defined in /usr/share/doc/gnupg/DETAILS.gz diff --git a/spec/classes/apt_backports_spec.rb b/spec/classes/apt_backports_spec.rb index bfe4a252df..e7a951a758 100644 --- a/spec/classes/apt_backports_spec.rb +++ b/spec/classes/apt_backports_spec.rb @@ -14,13 +14,13 @@ name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, - }, + id: 'Debian' + } + } } end @@ -40,13 +40,13 @@ name: 'Ubuntu', release: { major: '18', - full: '18.04', + full: '18.04' }, distro: { codename: 'bionac', - id: 'Ubuntu', - }, - }, + id: 'Ubuntu' + } + } } end @@ -67,13 +67,13 @@ name: 'Ubuntu', release: { major: '18', - full: '18.04', + full: '18.04' }, distro: { codename: 'bionac', - id: 'Ubuntu', - }, - }, + id: 'Ubuntu' + } + } } end let(:params) do @@ -82,7 +82,7 @@ release: 'vivid', repos: 'main', key: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', - pin: '90', + pin: '90' } end @@ -103,23 +103,23 @@ name: 'Ubuntu', release: { major: '18', - full: '18.04', + full: '18.04' }, distro: { codename: 'bionac', - id: 'Ubuntu', - }, - }, + id: 'Ubuntu' + } + } } end let(:params) do { key: { - 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', + 'id' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553' }, pin: { - 'priority' => '90', - }, + 'priority' => '90' + } } end @@ -138,13 +138,13 @@ name: 'LinuxMint', release: { major: '17', - full: '17', + full: '17' }, distro: { codename: 'qiana', - id: 'LinuxMint', - }, - }, + id: 'LinuxMint' + } + } } end @@ -154,7 +154,7 @@ location: 'http://archive.ubuntu.com/ubuntu', release: 'trusty-backports', repos: 'main universe multiverse restricted', - key: '630239CC130E1A7FD81A27B140976EAF437D05B5', + key: '630239CC130E1A7FD81A27B140976EAF437D05B5' } end @@ -172,7 +172,7 @@ { release: 'trusty-backports', repos: 'main universe multiverse restricted', - key: '630239CC130E1A7FD81A27B140976EAF437D05B5', + key: '630239CC130E1A7FD81A27B140976EAF437D05B5' } end @@ -186,7 +186,7 @@ { location: 'http://archive.ubuntu.com/ubuntu', repos: 'main universe multiverse restricted', - key: '630239CC130E1A7FD81A27B140976EAF437D05B5', + key: '630239CC130E1A7FD81A27B140976EAF437D05B5' } end @@ -200,7 +200,7 @@ { location: 'http://archive.ubuntu.com/ubuntu', release: 'trusty-backports', - key: '630239CC130E1A7FD81A27B140976EAF437D05B5', + key: '630239CC130E1A7FD81A27B140976EAF437D05B5' } end @@ -214,7 +214,7 @@ { location: 'http://archive.ubuntu.com/ubuntu', release: 'trusty-backports', - repos: 'main universe multiverse restricted', + repos: 'main universe multiverse restricted' } end @@ -232,20 +232,20 @@ name: 'Ubuntu', release: { major: '18', - full: '18.04', + full: '18.04' }, distro: { codename: 'bionac', - id: 'Ubuntu', - }, - }, + id: 'Ubuntu' + } + } } end context 'with invalid location' do let(:params) do { - location: true, + location: true } end @@ -257,7 +257,7 @@ context 'with invalid release' do let(:params) do { - release: true, + release: true } end @@ -269,7 +269,7 @@ context 'with invalid repos' do let(:params) do { - repos: true, + repos: true } end @@ -281,7 +281,7 @@ context 'with invalid key' do let(:params) do { - key: true, + key: true } end @@ -293,7 +293,7 @@ context 'with invalid pin' do let(:params) do { - pin: true, + pin: true } end diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 65ae50b2aa..0e6b6b07da 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -46,13 +46,13 @@ name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, - }, + id: 'Debian' + } + } } end @@ -240,7 +240,7 @@ update: { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 }, purge: { 'sources.list' => false, 'sources.list.d' => false, 'preferences' => false, 'preferences.d' => false, - 'apt.conf.d' => false }, + 'apt.conf.d' => false } } end @@ -280,7 +280,7 @@ update: { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 }, purge: { 'sources.list' => true, 'sources.list.d' => true, 'preferences' => true, 'preferences.d' => true, - 'apt.conf.d' => true }, + 'apt.conf.d' => true } } end @@ -319,7 +319,7 @@ { update: { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 }, purge: { 'sources.list' => true }, - sources_list_force: false, + sources_list_force: false } end @@ -333,7 +333,7 @@ { update: { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 }, purge: { 'sources.list' => true }, - sources_list_force: true, + sources_list_force: true } end @@ -350,13 +350,13 @@ name: 'Ubuntu', release: { major: '18', - full: '18.04', + full: '18.04' }, distro: { codename: 'bionic', - id: 'Ubuntu', - }, - }, + id: 'Ubuntu' + } + } }, 'Debian 9.0' => { os: { @@ -364,13 +364,13 @@ name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, - }, + id: 'Debian' + } + } }, 'Debian 10.0' => { os: { @@ -378,14 +378,14 @@ name: 'Debian', release: { major: '10', - full: '10.0', + full: '10.0' }, distro: { codename: 'buster', - id: 'Debian', - }, - }, - }, + id: 'Debian' + } + } + } } facts_hash.each do |os, facts| @@ -399,14 +399,14 @@ { machine: 'deb.example.net', login: 'foologin', - password: 'secret', + password: 'secret' }, { machine: 'apt.example.com', login: 'aptlogin', - password: 'supersecret', + password: 'supersecret' }, - ], + ] } end @@ -448,14 +448,14 @@ { machinn: 'deb.example.net', username: 'foologin', - password: 'secret', + password: 'secret' }, { machine: 'apt.example.com', login: 'aptlogin', - password: 'supersecret', + password: 'supersecret' }, - ], + ] } end @@ -472,13 +472,13 @@ name: 'Ubuntu', release: { major: '18', - full: '18.04', + full: '18.04' }, distro: { codename: 'bionic', - id: 'Ubuntu', - }, - }, + id: 'Ubuntu' + } + } } end let(:params) do @@ -489,13 +489,13 @@ 'repos' => 'main contrib non-free', 'key' => { 'id' => '150C8614919D8446E01E83AF9AA38DCD55BE302B', 'server' => 'subkeys.pgp.net' }, 'pin' => '-10', - 'include' => { 'src' => true }, + 'include' => { 'src' => true } }, 'puppetlabs' => { 'location' => 'http://apt.puppetlabs.com', 'repos' => 'main', - 'key' => { 'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F', 'server' => 'pgp.mit.edu' }, - }, + 'key' => { 'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F', 'server' => 'pgp.mit.edu' } + } } } end @@ -521,23 +521,23 @@ name: 'Ubuntu', release: { major: '18', - full: '18.04', + full: '18.04' }, distro: { codename: 'bionic', - id: 'Ubuntu', - }, - }, + id: 'Ubuntu' + } + } } end let(:params) do { confs: { 'foo' => { - 'content' => 'foo', + 'content' => 'foo' }, 'bar' => { - 'content' => 'bar', - }, + 'content' => 'bar' + } } } end @@ -558,23 +558,23 @@ name: 'Ubuntu', release: { major: '18', - full: '18.04', + full: '18.04' }, distro: { codename: 'bionic', - id: 'Ubuntu', - }, - }, + id: 'Ubuntu' + } + } } end let(:params) do { keys: { '55BE302B' => { - 'server' => 'subkeys.pgp.net', + 'server' => 'subkeys.pgp.net' }, 'EF8D349F' => { - 'server' => 'pgp.mit.edu', - }, + 'server' => 'pgp.mit.edu' + } } } end @@ -595,19 +595,19 @@ name: 'Ubuntu', release: { major: '18', - full: '18.04', + full: '18.04' }, distro: { codename: 'bionic', - id: 'Ubuntu', - }, - }, + id: 'Ubuntu' + } + } } end let(:params) do { ppas: { 'ppa:drizzle-developers/ppa' => {}, - 'ppa:nginx/stable' => {}, + 'ppa:nginx/stable' => {} } } end @@ -623,19 +623,19 @@ name: 'Ubuntu', release: { major: '18', - full: '18.04', + full: '18.04' }, distro: { codename: 'bionic', - id: 'Ubuntu', - }, - }, + id: 'Ubuntu' + } + } } end let(:params) do { settings: { 'conf-banana' => { 'content' => 'banana' }, - 'pref-banana' => { 'content' => 'banana' }, + 'pref-banana' => { 'content' => 'banana' } } } end @@ -651,19 +651,19 @@ name: 'Ubuntu', release: { major: '18', - full: '18.04', + full: '18.04' }, distro: { codename: 'bionic', - id: 'Ubuntu', - }, - }, + id: 'Ubuntu' + } + } } end let(:params) do { pins: { 'stable' => { 'priority' => 600, 'order' => 50 }, - 'testing' => { 'priority' => 700, 'order' => 100 }, + 'testing' => { 'priority' => 700, 'order' => 100 } } } end diff --git a/spec/classes/apt_update_spec.rb b/spec/classes/apt_update_spec.rb index 61335fda20..ada31b1600 100644 --- a/spec/classes/apt_update_spec.rb +++ b/spec/classes/apt_update_spec.rb @@ -7,7 +7,7 @@ { 'a recent run' => Time.now.to_i, 'we are due for a run' => 1_406_660_561, - 'the update-success-stamp file does not exist' => -1, + 'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| context "when $apt_update_last_success indicates #{desc}" do let(:facts) do @@ -17,14 +17,14 @@ name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, + id: 'Debian' + } }, - apt_update_last_success: factval, + apt_update_last_success: factval } end let(:pre_condition) do @@ -45,13 +45,13 @@ name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, - }, + id: 'Debian' + } + } } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'always' },}" } @@ -70,14 +70,14 @@ name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, + id: 'Debian' + } }, - apt_update_last_success: Time.now.to_i, + apt_update_last_success: Time.now.to_i } end let(:pre_condition) do @@ -98,7 +98,7 @@ { 'a recent run' => Time.now.to_i, 'we are due for a run' => 1_406_660_561, - 'the update-success-stamp file does not exist' => -1, + 'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| context "when $apt_update_last_success indicates #{desc}" do let(:facts) do @@ -108,14 +108,14 @@ name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, + id: 'Debian' + } }, - apt_update_last_success: factval, + apt_update_last_success: factval } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" } @@ -134,13 +134,13 @@ name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, - }, + id: 'Debian' + } + } } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => 'reluctantly' },}" } @@ -163,14 +163,14 @@ name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, + id: 'Debian' + } }, - apt_update_last_success: factval, + apt_update_last_success: factval } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } @@ -189,14 +189,14 @@ name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, + id: 'Debian' + } }, - apt_update_last_success: Time.now.to_i, + apt_update_last_success: Time.now.to_i } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } @@ -215,14 +215,14 @@ name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, + id: 'Debian' + } }, - apt_update_last_success: nil, + apt_update_last_success: nil } end let(:pre_condition) { "class{ '::apt': update => {'frequency' => '#{update_frequency}',} }" } diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index b08cc0f395..26638e338a 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -12,13 +12,13 @@ name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, - }, + id: 'Debian' + } + } } end let :title do @@ -29,7 +29,7 @@ let :default_params do { priority: '00', - content: "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n", + content: "Apt::Install-Recommends 0;\nApt::AutoRemove::InstallRecommends 1;\n" } end let :params do @@ -67,7 +67,7 @@ describe 'when creating a preference without content' do let :params do { - priority: '00', + priority: '00' } end @@ -80,7 +80,7 @@ let :params do { ensure: 'absent', - priority: '00', + priority: '00' } end diff --git a/spec/defines/key_compat_spec.rb b/spec/defines/key_compat_spec.rb index f414503ac3..4420337d19 100644 --- a/spec/defines/key_compat_spec.rb +++ b/spec/defines/key_compat_spec.rb @@ -30,13 +30,13 @@ def apt_key_example(title) name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, - }, + id: 'Debian' + } + } } end @@ -70,7 +70,7 @@ def apt_key_example(title) let :params do { - id: GPG_KEY_ID, + id: GPG_KEY_ID } end @@ -90,7 +90,7 @@ def apt_key_example(title) describe 'ensure => absent' do let :params do { - ensure: 'absent', + ensure: 'absent' } end @@ -113,7 +113,7 @@ def apt_key_example(title) content: 'GPG key content', source: 'http://apt.puppetlabs.com/pubkey.gpg', server: 'pgp.mit.edu', - options: 'debug', + options: 'debug' } end @@ -129,7 +129,7 @@ def apt_key_example(title) context 'when domain has dash' do let(:params) do { - server: 'p-gp.m-it.edu', + server: 'p-gp.m-it.edu' } end @@ -142,7 +142,7 @@ def apt_key_example(title) context 'with url' do let :params do { - server: 'hkp://pgp.mit.edu', + server: 'hkp://pgp.mit.edu' } end @@ -155,7 +155,7 @@ def apt_key_example(title) context 'with url and port number' do let :params do { - server: 'hkp://pgp.mit.edu:80', + server: 'hkp://pgp.mit.edu:80' } end @@ -170,7 +170,7 @@ def apt_key_example(title) context 'when domain begins with a dash' do let(:params) do { - server: '-pgp.mit.edu', + server: '-pgp.mit.edu' } end @@ -182,7 +182,7 @@ def apt_key_example(title) context 'when domain begins with dot' do let(:params) do { - server: '.pgp.mit.edu', + server: '.pgp.mit.edu' } end @@ -194,7 +194,7 @@ def apt_key_example(title) context 'when domain ends with dot' do let(:params) do { - server: 'pgp.mit.edu.', + server: 'pgp.mit.edu.' } end @@ -206,7 +206,7 @@ def apt_key_example(title) context 'when url character limit is exceeded' do let :params do { - server: 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu', + server: 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu' } end @@ -218,7 +218,7 @@ def apt_key_example(title) context 'with incorrect port number url' do let :params do { - server: 'hkp://pgp.mit.edu:8008080', + server: 'hkp://pgp.mit.edu:8008080' } end @@ -230,7 +230,7 @@ def apt_key_example(title) context 'with incorrect protocol for url' do let :params do { - server: 'abc://pgp.mit.edu:80', + server: 'abc://pgp.mit.edu:80' } end @@ -242,7 +242,7 @@ def apt_key_example(title) context 'with missing port number url' do let :params do { - server: 'hkp://pgp.mit.edu:', + server: 'hkp://pgp.mit.edu:' } end @@ -254,7 +254,7 @@ def apt_key_example(title) context 'with url ending with a dot' do let :params do { - server: 'hkp://pgp.mit.edu.', + server: 'hkp://pgp.mit.edu.' } end @@ -266,7 +266,7 @@ def apt_key_example(title) context 'with url begin with a dash' do let(:params) do { - server: 'hkp://-pgp.mit.edu', + server: 'hkp://-pgp.mit.edu' } end @@ -288,7 +288,7 @@ def apt_key_example(title) context 'with invalid source' do let :params do { - source: 'afp://puppetlabs.com/key.gpg', + source: 'afp://puppetlabs.com/key.gpg' } end @@ -300,7 +300,7 @@ def apt_key_example(title) context 'with invalid content' do let :params do { - content: [], + content: [] } end @@ -312,7 +312,7 @@ def apt_key_example(title) context 'with invalid server' do let :params do { - server: 'two bottles of rum', + server: 'two bottles of rum' } end @@ -324,7 +324,7 @@ def apt_key_example(title) context 'with invalid keyserver_options' do let :params do { - options: {}, + options: {} } end @@ -336,7 +336,7 @@ def apt_key_example(title) context 'with invalid ensure' do let :params do { - ensure: 'foo', + ensure: 'foo' } end diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index 948833a3fd..59695006c2 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -51,13 +51,13 @@ def absent_apt_key(title) name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, - }, + id: 'Debian' + } + } } end @@ -83,7 +83,7 @@ def absent_apt_key(title) let :params do { - id: GPG_KEY_ID, + id: GPG_KEY_ID } end @@ -99,7 +99,7 @@ def absent_apt_key(title) describe 'ensure => absent' do let :params do { - ensure: 'absent', + ensure: 'absent' } end @@ -115,7 +115,7 @@ def absent_apt_key(title) describe 'ensure => refreshed' do let :params do { - ensure: 'refreshed', + ensure: 'refreshed' } end @@ -133,7 +133,7 @@ def absent_apt_key(title) content: 'GPG key content', source: 'http://apt.puppetlabs.com/pubkey.gpg', server: 'pgp.mit.edu', - options: 'debug', + options: 'debug' } end @@ -149,7 +149,7 @@ def absent_apt_key(title) context 'when domain with dash' do let(:params) do { - server: 'p-gp.m-it.edu', + server: 'p-gp.m-it.edu' } end @@ -162,7 +162,7 @@ def absent_apt_key(title) context 'with url' do let :params do { - server: 'hkp://pgp.mit.edu', + server: 'hkp://pgp.mit.edu' } end @@ -175,7 +175,7 @@ def absent_apt_key(title) context 'when url with port number' do let :params do { - server: 'hkp://pgp.mit.edu:80', + server: 'hkp://pgp.mit.edu:80' } end @@ -190,7 +190,7 @@ def absent_apt_key(title) context 'when domain begin with dash' do let(:params) do { - server: '-pgp.mit.edu', + server: '-pgp.mit.edu' } end @@ -202,7 +202,7 @@ def absent_apt_key(title) context 'when domain begin with dot' do let(:params) do { - server: '.pgp.mit.edu', + server: '.pgp.mit.edu' } end @@ -214,7 +214,7 @@ def absent_apt_key(title) context 'when domain end with dot' do let(:params) do { - server: 'pgp.mit.edu.', + server: 'pgp.mit.edu.' } end @@ -226,7 +226,7 @@ def absent_apt_key(title) context 'when character url exceeded' do let :params do { - server: 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu', + server: 'hkp://pgpiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.mit.edu' } end @@ -238,7 +238,7 @@ def absent_apt_key(title) context 'with incorrect port number url' do let :params do { - server: 'hkp://pgp.mit.edu:8008080', + server: 'hkp://pgp.mit.edu:8008080' } end @@ -250,7 +250,7 @@ def absent_apt_key(title) context 'with incorrect protocol for url' do let :params do { - server: 'abc://pgp.mit.edu:80', + server: 'abc://pgp.mit.edu:80' } end @@ -262,7 +262,7 @@ def absent_apt_key(title) context 'with missing port number url' do let :params do { - server: 'hkp://pgp.mit.edu:', + server: 'hkp://pgp.mit.edu:' } end @@ -274,7 +274,7 @@ def absent_apt_key(title) context 'with url ending with a dot' do let :params do { - server: 'hkp://pgp.mit.edu.', + server: 'hkp://pgp.mit.edu.' } end @@ -286,7 +286,7 @@ def absent_apt_key(title) context 'when url begins with a dash' do let(:params) do { - server: 'hkp://-pgp.mit.edu', + server: 'hkp://-pgp.mit.edu' } end @@ -308,7 +308,7 @@ def absent_apt_key(title) context 'with invalid source' do let :params do { - source: 'afp://puppetlabs.com/key.gpg', + source: 'afp://puppetlabs.com/key.gpg' } end @@ -320,7 +320,7 @@ def absent_apt_key(title) context 'with invalid content' do let :params do { - content: [], + content: [] } end @@ -332,7 +332,7 @@ def absent_apt_key(title) context 'with invalid server' do let :params do { - server: 'two bottles of rum', + server: 'two bottles of rum' } end @@ -344,7 +344,7 @@ def absent_apt_key(title) context 'with invalid options' do let :params do { - options: {}, + options: {} } end @@ -357,7 +357,7 @@ def absent_apt_key(title) ['foo', 'aabsent', 'absenta', 'apresent', 'presenta', 'refresh', 'arefreshed', 'refresheda'].each do |param| let :params do { - ensure: param, + ensure: param } end diff --git a/spec/defines/mark_spec.rb b/spec/defines/mark_spec.rb index cdff673a9e..e73901e95a 100644 --- a/spec/defines/mark_spec.rb +++ b/spec/defines/mark_spec.rb @@ -14,20 +14,20 @@ name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, - }, + id: 'Debian' + } + } } end context 'with correct seting' do let :params do { - 'setting' => 'manual', + 'setting' => 'manual' } end @@ -39,7 +39,7 @@ describe 'with wrong setting' do let :params do { - 'setting' => 'foobar', + 'setting' => 'foobar' } end @@ -65,7 +65,7 @@ let :params do { - 'setting' => 'manual', + 'setting' => 'manual' } end @@ -94,7 +94,7 @@ let :params do { - 'setting' => 'manual', + 'setting' => 'manual' } end diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index bd2c26287b..1dd02980af 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -12,13 +12,13 @@ name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, - }, + id: 'Debian' + } + } } end let(:title) { 'my_pin' } @@ -31,7 +31,7 @@ let :params do { 'packages' => 'vim', - 'version' => '1', + 'version' => '1' } end @@ -42,7 +42,7 @@ let :params do { 'packages' => 'vim', - 'origin' => 'test', + 'origin' => 'test' } end @@ -60,7 +60,7 @@ 'component' => 'baz', 'originator' => 'foobar', 'label' => 'foobaz', - 'priority' => 10, + 'priority' => 10 } end @@ -74,7 +74,7 @@ context 'with ensure absent' do let :params do { - 'ensure' => 'absent', + 'ensure' => 'absent' } end @@ -93,7 +93,7 @@ context 'with invalid order' do let :params do { - 'order' => 'foo', + 'order' => 'foo' } end @@ -105,7 +105,7 @@ context 'with packages == * and version' do let :params do { - 'version' => '1', + 'version' => '1' } end @@ -118,7 +118,7 @@ let :params do { 'origin' => 'test', - 'release' => 'foo', + 'release' => 'foo' } end @@ -132,7 +132,7 @@ { 'release' => 'foo', 'origin' => 'test', - 'packages' => 'vim', + 'packages' => 'vim' } end @@ -146,7 +146,7 @@ { 'version' => '1', 'origin' => 'test', - 'packages' => 'vim', + 'packages' => 'vim' } end diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index 3d109aed75..05718ebc34 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -23,12 +23,12 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) name: 'Ubuntu', release: { major: '18', - full: '18.04', + full: '18.04' }, distro: { codename: 'trusty', - id: 'Ubuntu', - }, + id: 'Ubuntu' + } }, puppet_vardir: '/opt/puppetlabs/puppet/cache' } @@ -59,13 +59,13 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) name: 'Ubuntu', release: { major: '18', - full: '18.04', + full: '18.04' }, distro: { codename: 'trusty', - id: 'Ubuntu', - }, - }, + id: 'Ubuntu' + } + } } end @@ -92,13 +92,13 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) name: 'Ubuntu', release: { major: '18', - full: '18.04', + full: '18.04' }, distro: { codename: 'trusty', - id: 'Ubuntu', - }, - }, + id: 'Ubuntu' + } + } } end @@ -116,14 +116,14 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) name: 'Ubuntu', release: { major: '15', - full: '15.10', + full: '15.10' }, distro: { codename: 'wily', - id: 'Ubuntu', - }, + id: 'Ubuntu' + } }, - puppet_vardir: '/opt/puppetlabs/puppet/cache', + puppet_vardir: '/opt/puppetlabs/puppet/cache' } end @@ -144,7 +144,7 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) let :params do { package_name: 'software-properties-common', - package_manage: true, + package_manage: true } end @@ -155,14 +155,14 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) name: 'Ubuntu', release: { major: '18', - full: '18.04', + full: '18.04' }, distro: { codename: 'trusty', - id: 'Ubuntu', - }, + id: 'Ubuntu' + } }, - puppet_vardir: '/opt/puppetlabs/puppet/cache', + puppet_vardir: '/opt/puppetlabs/puppet/cache' } end @@ -189,20 +189,20 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) name: 'Ubuntu', release: { major: '18', - full: '18.04', + full: '18.04' }, distro: { codename: 'trusty', - id: 'Ubuntu', - }, + id: 'Ubuntu' + } }, - puppet_vardir: '/opt/puppetlabs/puppet/cache', + puppet_vardir: '/opt/puppetlabs/puppet/cache' } end let :params do { - package_manage: false, + package_manage: false } end @@ -231,21 +231,21 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) name: 'Ubuntu', release: { major: '18', - full: '18.04', + full: '18.04' }, distro: { codename: 'trusty', - id: 'Ubuntu', - }, + id: 'Ubuntu' + } }, - puppet_vardir: '/opt/puppetlabs/puppet/cache', + puppet_vardir: '/opt/puppetlabs/puppet/cache' } end let :params do { package_manage: true, - require: 'Apt::Ppa[ppa:user/foo2]', + require: 'Apt::Ppa[ppa:user/foo2]' } end @@ -275,20 +275,20 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) name: 'Ubuntu', release: { major: '18', - full: '18.04', + full: '18.04' }, distro: { codename: 'trusty', - id: 'Ubuntu', - }, + id: 'Ubuntu' + } }, - puppet_vardir: '/opt/puppetlabs/puppet/cache', + puppet_vardir: '/opt/puppetlabs/puppet/cache' } end let :params do { - 'package_manage' => true, + 'package_manage' => true } end @@ -317,20 +317,20 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) name: 'Ubuntu', release: { major: '18', - full: '18.04', + full: '18.04' }, distro: { codename: 'trusty', - id: 'Ubuntu', - }, + id: 'Ubuntu' + } }, - puppet_vardir: '/opt/puppetlabs/puppet/cache', + puppet_vardir: '/opt/puppetlabs/puppet/cache' } end let :params do { - package_manage: true, + package_manage: true } end @@ -359,20 +359,20 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) name: 'Ubuntu', release: { major: '18', - full: '18.04', + full: '18.04' }, distro: { codename: 'trusty', - id: 'Ubuntu', - }, + id: 'Ubuntu' + } }, - puppet_vardir: '/opt/puppetlabs/puppet/cache', + puppet_vardir: '/opt/puppetlabs/puppet/cache' } end let :params do { - package_manage: true, + package_manage: true } end @@ -399,14 +399,14 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) name: 'Ubuntu', release: { major: '18', - full: '18.04', + full: '18.04' }, distro: { codename: 'trusty', - id: 'Ubuntu', - }, + id: 'Ubuntu' + } }, - puppet_vardir: '/opt/puppetlabs/puppet/cache', + puppet_vardir: '/opt/puppetlabs/puppet/cache' } end @@ -414,7 +414,7 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) let :params do { - ensure: 'absent', + ensure: 'absent' } end @@ -437,13 +437,13 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) name: 'Ubuntu', release: { major: '18', - full: '18.04', + full: '18.04' }, distro: { codename: nil, - id: 'Ubuntu', - }, - }, + id: 'Ubuntu' + } + } } end @@ -462,13 +462,13 @@ def ppa_exec_params(user, repo, distro = 'trusty', environment = []) name: 'Debian', release: { major: '6', - full: '6.0.7', + full: '6.0.7' }, distro: { codename: 'wheezy', - id: 'Debian', - }, - }, + id: 'Debian' + } + } } end diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb index a142667d55..7a71896053 100644 --- a/spec/defines/setting_spec.rb +++ b/spec/defines/setting_spec.rb @@ -11,13 +11,13 @@ name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, - }, + id: 'Debian' + } + } } end let(:title) { 'conf-teddybear' } @@ -87,13 +87,13 @@ name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, - }, + id: 'Debian' + } + } } end let(:title) { 'conf-teddybear' } diff --git a/spec/defines/source_compat_spec.rb b/spec/defines/source_compat_spec.rb index dc261fbb88..a414c49386 100644 --- a/spec/defines/source_compat_spec.rb +++ b/spec/defines/source_compat_spec.rb @@ -16,13 +16,13 @@ name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, - }, + id: 'Debian' + } + } } end @@ -30,7 +30,7 @@ let :params do { 'include' => { 'deb' => false, 'src' => true }, - 'location' => 'http://debian.mirror.iweb.ca/debian/', + 'location' => 'http://debian.mirror.iweb.ca/debian/' } end @@ -50,7 +50,7 @@ 'key' => GPG_KEY_ID, 'pin' => '10', 'architecture' => 'x86_64', - 'allow_unsigned' => true, + 'allow_unsigned' => true } end @@ -76,7 +76,7 @@ { 'include' => { 'src' => false }, 'location' => 'http://debian.mirror.iweb.ca/debian/', - 'allow_insecure' => true, + 'allow_insecure' => true } end @@ -88,7 +88,7 @@ { 'include' => { 'src' => false }, 'location' => 'http://debian.mirror.iweb.ca/debian/', - 'allow_unsigned' => true, + 'allow_unsigned' => true } end @@ -99,7 +99,7 @@ let :params do { 'location' => 'http://debian.mirror.iweb.ca/debian/', - 'architecture' => 'x86_64', + 'architecture' => 'x86_64' } end @@ -111,7 +111,7 @@ context 'with ensure => absent' do let :params do { - 'ensure' => 'absent', + 'ensure' => 'absent' } end @@ -129,12 +129,12 @@ name: 'Debian', release: { major: '8', - full: '8.0', + full: '8.0' }, distro: { - id: 'Debian', - }, - }, + id: 'Debian' + } + } } end diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 798279e6b2..8cf9a453aa 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -20,13 +20,13 @@ name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, - }, + id: 'Debian' + } + } } end @@ -54,7 +54,7 @@ location: 'hello.there', pin: { 'release' => 'wishwash', 'explanation' => 'wishwash', - 'priority' => 1001 }, + 'priority' => 1001 } } end @@ -82,7 +82,7 @@ key: GPG_KEY_ID, pin: '10', architecture: 'x86_64', - allow_unsigned: true, + allow_unsigned: true } end @@ -116,11 +116,11 @@ 'server' => 'pgp.mit.edu', 'content' => 'GPG key content', 'source' => 'http://apt.puppetlabs.com/pubkey.gpg', - 'weak_ssl' => true, + 'weak_ssl' => true }, pin: '10', architecture: 'x86_64', - allow_unsigned: true, + allow_unsigned: true } end @@ -150,7 +150,7 @@ let :params do { location: 'hello.there', - allow_insecure: true, + allow_insecure: true } end @@ -163,7 +163,7 @@ let :params do { location: 'hello.there', - allow_unsigned: true, + allow_unsigned: true } end @@ -176,7 +176,7 @@ let :params do { location: 'hello.there', - check_valid_until: false, + check_valid_until: false } end @@ -189,7 +189,7 @@ let :params do { location: 'hello.there', - check_valid_until: true, + check_valid_until: true } end @@ -202,7 +202,7 @@ let :params do { location: 'hello.there', - keyring: '/usr/share/keyrings/foo-archive-keyring.gpg', + keyring: '/usr/share/keyrings/foo-archive-keyring.gpg' } end @@ -219,7 +219,7 @@ location: 'hello.there', architecture: 'amd64', allow_unsigned: true, - keyring: '/usr/share/keyrings/foo-archive-keyring.gpg', + keyring: '/usr/share/keyrings/foo-archive-keyring.gpg' } end @@ -234,7 +234,7 @@ let :params do { location: 'HTTPS://foo.bar', - allow_unsigned: false, + allow_unsigned: false } end @@ -251,21 +251,21 @@ name: 'Debian', release: { major: '9', - full: '9.0', + full: '9.0' }, distro: { codename: 'stretch', - id: 'Debian', - }, + id: 'Debian' + } }, - puppetversion: Puppet.version, + puppetversion: Puppet.version } end let :params do { location: 'HTTPS://foo.bar', allow_unsigned: false, - release: 'customrelease', + release: 'customrelease' } end @@ -282,19 +282,19 @@ name: 'Debian', release: { major: '10', - full: '10.0', + full: '10.0' }, distro: { codename: 'buster', - id: 'Debian', - }, - }, + id: 'Debian' + } + } } end let :params do { location: 'https://foo.bar', - allow_unsigned: false, + allow_unsigned: false } end @@ -311,20 +311,20 @@ name: 'Debian', release: { major: '7', - full: '7.0', + full: '7.0' }, distro: { codename: 'wheezy', - id: 'Debian', - }, - }, + id: 'Debian' + } + } } end let :params do { location: 'hello.there', include: { 'deb' => false, 'src' => true }, - architecture: 'x86_64', + architecture: 'x86_64' } end @@ -340,7 +340,7 @@ let :params do { location: 'hello.there', - include: { 'deb' => false, 'src' => true }, + include: { 'deb' => false, 'src' => true } } end @@ -353,7 +353,7 @@ let :params do { location: 'hello.there', - include: { 'src' => true }, + include: { 'src' => true } } end @@ -366,7 +366,7 @@ let :params do { include: { 'deb' => false }, - location: 'hello.there', + location: 'hello.there' } end @@ -381,7 +381,7 @@ let :params do { include: { 'deb' => false, 'src' => true }, - location: 'hello.there', + location: 'hello.there' } end @@ -395,7 +395,7 @@ context 'with ensure => absent' do let :params do { - ensure: 'absent', + ensure: 'absent' } end @@ -413,12 +413,12 @@ name: 'Debian', release: { major: '8', - full: '8.0', + full: '8.0' }, distro: { - id: 'Debian', - }, - }, + id: 'Debian' + } + } } end let(:params) { { location: 'hello.there' } } @@ -438,7 +438,7 @@ let :params do { location: 'hello.there', - pin: true, + pin: true } end @@ -450,7 +450,7 @@ context 'with notify_update = undef (default)' do let :params do { - location: 'hello.there', + location: 'hello.there' } end @@ -461,7 +461,7 @@ let :params do { location: 'hello.there', - notify_update: true, + notify_update: true } end @@ -472,7 +472,7 @@ let :params do { location: 'hello.there', - notify_update: false, + notify_update: false } end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 07db73426e..c6e5525752 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -13,7 +13,7 @@ default_facts = { puppetversion: Puppet.version, - facterversion: Facter.version, + facterversion: Facter.version } default_fact_files = [ @@ -26,7 +26,7 @@ begin default_facts.merge!(YAML.safe_load(File.read(f), [], [], true)) - rescue => e + rescue StandardError => e RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" end end diff --git a/spec/unit/puppet/provider/apt_key_spec.rb b/spec/unit/puppet/provider/apt_key_spec.rb index 6da7016dbd..7cab6ceb49 100644 --- a/spec/unit/puppet/provider/apt_key_spec.rb +++ b/spec/unit/puppet/provider/apt_key_spec.rb @@ -143,7 +143,7 @@ '160bit key fingerprint lowercase' => '6F6B15509CF8E59E6E469F327F438280EF8D349F'.downcase, '32bit key id 0x formatted' => '0xEF8D349F', '64bit key id 0x formatted' => '0x7F438280EF8D349F', - '160bit key fingerprint 0x formatted' => '0x6F6B15509CF8E59E6E469F327F438280EF8D349F', + '160bit key fingerprint 0x formatted' => '0x6F6B15509CF8E59E6E469F327F438280EF8D349F' } hash_of_keys.each do |key_type, value| it "#{key_type} #{value} is valid" do From bae1dc74229caf0559650421e43ee2fba88496cf Mon Sep 17 00:00:00 2001 From: david22swan Date: Wed, 26 Apr 2023 15:09:12 +0100 Subject: [PATCH 10/18] (CONT-773) Set toapt_key `open` calls to `URI.open` Calls to `open` have previously been left vague, which has caused issues upon implementing Ruby 3 --- lib/puppet/provider/apt_key/apt_key.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index c15d826bb9..8cdf78bb71 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -135,14 +135,14 @@ def source_to_file(value) # Some webservers (e.g. Amazon S3) return code 400 if empty basic auth is sent if parsed_value.userinfo.nil? key = if parsed_value.scheme == 'https' && resource[:weak_ssl] == true - open(parsed_value, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE).read + URI.open(parsed_value, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE).read else parsed_value.read end else user_pass = parsed_value.userinfo.split(':') parsed_value.userinfo = '' - key = open(parsed_value, http_basic_authentication: user_pass).read + key = URI.open(parsed_value, http_basic_authentication: user_pass).read end rescue *exceptions => e raise(_('%{_e} for %{_resource}') % { _e: e.message, _resource: resource[:source] }) From 8b630e0976e1d22f36661c1b6c18fdbffb3c7eba Mon Sep 17 00:00:00 2001 From: david22swan Date: Wed, 26 Apr 2023 15:32:25 +0100 Subject: [PATCH 11/18] (CONT-773) Rubocop Manual Fix 2 - RSpec/ExampleWording --- .rubocop_todo.yml | 8 -------- spec/acceptance/apt_key_provider_spec.rb | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6da30678d8..bed1ce7985 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -79,14 +79,6 @@ RSpec/DescribeClass: RSpec/ExampleLength: Max: 15 -# Offense count: 10 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples. -# DisallowedExamples: works -RSpec/ExampleWording: - Exclude: - - 'spec/acceptance/apt_key_provider_spec.rb' - # Offense count: 3 RSpec/LeakyConstantDeclaration: Exclude: diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb index 4ca9dba219..2c99343070 100644 --- a/spec/acceptance/apt_key_provider_spec.rb +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -677,7 +677,7 @@ def apply_manifest_twice(manifest_pp) describe 'content =>' do context 'with puppetlabs gpg key' do - it 'works' do + it 'applies without error' do # Apply the manifest (Retry if timeout error is received from key pool) retry_on_error_matching do apply_manifest(gpg_key_pp, catch_failures: true) @@ -706,7 +706,7 @@ def apply_manifest_twice(manifest_pp) describe 'server =>' do context 'with hkp://pgp.mit.edu:80' do - it 'works' do + it 'applies without error' do retry_on_error_matching do apply_manifest(hkp_pool_pp, catch_failures: true) end @@ -718,7 +718,7 @@ def apply_manifest_twice(manifest_pp) if hkps_protocol_supported context 'with hkps://keyserver.ubuntu.com' do - it 'works' do + it 'applies without error' do retry_on_error_matching do apply_manifest(hkps_ubuntu_pp, catch_failures: true) end @@ -748,7 +748,7 @@ def apply_manifest_twice(manifest_pp) describe 'source =>' do context 'with http://' do - it 'works' do + it 'applies without error' do apply_manifest_twice(http_works_pp) run_shell(PUPPETLABS_KEY_CHECK_COMMAND) end @@ -777,7 +777,7 @@ def apply_manifest_twice(manifest_pp) run_shell("apt-key del #{CENTOS_GPG_KEY_LONG_ID}", expect_failures: true) end - it 'works' do + it 'applies without error' do apply_manifest_twice(ftp_works_pp) run_shell(CENTOS_KEY_CHECK_COMMAND) end @@ -796,7 +796,7 @@ def apply_manifest_twice(manifest_pp) end context 'with https://' do - it 'works' do + it 'applies without error' do apply_manifest_twice(https_works_pp) run_shell(PUPPETLABS_KEY_CHECK_COMMAND) end @@ -834,7 +834,7 @@ def apply_manifest_twice(manifest_pp) run_shell('rm /tmp/puppetlabs-pubkey.gpg') end - it 'works' do + it 'applies without error' do apply_manifest_twice(path_exists_pp) run_shell(PUPPETLABS_KEY_CHECK_COMMAND) end @@ -867,7 +867,7 @@ def apply_manifest_twice(manifest_pp) describe 'options =>' do context 'with debug' do - it 'works' do + it 'applies without error' do apply_manifest_twice(debug_works_pp) run_shell(PUPPETLABS_KEY_CHECK_COMMAND) end @@ -876,13 +876,13 @@ def apply_manifest_twice(manifest_pp) describe 'fingerprint validation against source/content' do context 'with fingerprint in id matches fingerprint from remote key' do - it 'works' do + it 'applies without error' do apply_manifest_twice(fingerprint_match_pp) end end context 'with fingerprint in id does NOT match fingerprint from remote key' do - it 'works' do + it 'applies without error' do apply_manifest(fingerprint_does_not_match_pp, expect_failures: true) do |r| expect(r.stderr).to match(%r{don't match}) end From 3d5e23644f0fc557464409d98415872b2e7ba81d Mon Sep 17 00:00:00 2001 From: david22swan Date: Wed, 26 Apr 2023 15:37:01 +0100 Subject: [PATCH 12/18] (CONT-773) Rubocop Unsafe Auto Fixes 1-3 - Lint/BooleanSymbol - RSpec/BeEq - Style/CaseLikeIf --- .rubocop_todo.yml | 20 -------------------- lib/puppet/provider/apt_key/apt_key.rb | 7 ++++--- spec/unit/facter/apt_reboot_required_spec.rb | 4 ++-- spec/unit/puppet/type/apt_key_spec.rb | 10 +++++----- 4 files changed, 11 insertions(+), 30 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bed1ce7985..a20672eb00 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,12 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -Lint/BooleanSymbol: - Exclude: - - 'spec/unit/puppet/type/apt_key_spec.rb' - # Offense count: 3 # Configuration parameters: AllowedMethods. # AllowedMethods: enums @@ -53,13 +47,6 @@ Performance/CollectionLiteralInLoop: Exclude: - 'spec/classes/apt_update_spec.rb' -# Offense count: 6 -# This cop supports unsafe autocorrection (--autocorrect-all). -RSpec/BeEq: - Exclude: - - 'spec/unit/facter/apt_reboot_required_spec.rb' - - 'spec/unit/puppet/type/apt_key_spec.rb' - # Offense count: 6 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without @@ -141,13 +128,6 @@ Security/Open: Exclude: - 'lib/puppet/provider/apt_key/apt_key.rb' -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: MinBranchesCount. -Style/CaseLikeIf: - Exclude: - - 'lib/puppet/provider/apt_key/apt_key.rb' - # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Style/GlobalStdStream: diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index 8cdf78bb71..9ad21bcc6e 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -71,13 +71,14 @@ def self.instances def self.prefetch(resources) apt_keys = instances resources.each_key do |name| - if name.length == 40 + case name.length + when 40 provider = apt_keys.find { |key| key.fingerprint == name } resources[name].provider = provider if provider - elsif name.length == 16 + when 16 provider = apt_keys.find { |key| key.long == name } resources[name].provider = provider if provider - elsif name.length == 8 + when 8 provider = apt_keys.find { |key| key.short == name } resources[name].provider = provider if provider end diff --git a/spec/unit/facter/apt_reboot_required_spec.rb b/spec/unit/facter/apt_reboot_required_spec.rb index f922822784..b60724514e 100644 --- a/spec/unit/facter/apt_reboot_required_spec.rb +++ b/spec/unit/facter/apt_reboot_required_spec.rb @@ -14,7 +14,7 @@ allow(File).to receive(:file?).once.with('/var/run/reboot-required').and_return(true) end - it { is_expected.to eq true } + it { is_expected.to be true } end describe 'if a reboot is not required' do @@ -24,6 +24,6 @@ allow(File).to receive(:file?).once.with('/var/run/reboot-required').and_return(false) end - it { is_expected.to eq false } + it { is_expected.to be false } end end diff --git a/spec/unit/puppet/type/apt_key_spec.rb b/spec/unit/puppet/type/apt_key_spec.rb index a23aa90c4c..a146a26e82 100644 --- a/spec/unit/puppet/type/apt_key_spec.rb +++ b/spec/unit/puppet/type/apt_key_spec.rb @@ -24,19 +24,19 @@ end it 'source is not set' do - expect(resource[:source]).to eq nil + expect(resource[:source]).to be_nil end it 'content is not set' do - expect(resource[:content]).to eq nil + expect(resource[:content]).to be_nil end it 'refresh is not set' do - expect(resource[:refresh]).to eq nil + expect(resource[:refresh]).to be_nil end it 'weak_ssl is not set' do - expect(resource[:weak_ssl]).to eq nil + expect(resource[:weak_ssl]).to be_nil end end @@ -167,7 +167,7 @@ Puppet::Type.type(:apt_key).new(id: 'EF8D349F', source: 'http://apt.puppetlabs.com/pubkey.gpg', ensure: :absent, - refresh: :true) + refresh: true) }.to raise_error(%r{ensure => absent and refresh => true are mutually exclusive}) end From 8a7fc6272bc86965815f213436a24e093a329420 Mon Sep 17 00:00:00 2001 From: david22swan Date: Wed, 26 Apr 2023 16:43:31 +0100 Subject: [PATCH 13/18] (CONT-773) Rubocop Unsafe Auto Fixes 4-5 - Style/GlobalStdStream - Style/SlicingWithRange --- .rubocop_todo.yml | 12 ------------ lib/puppet/provider/apt_key/apt_key.rb | 4 ++-- tasks/init.rb | 2 +- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a20672eb00..fb3857b036 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -128,19 +128,7 @@ Security/Open: Exclude: - 'lib/puppet/provider/apt_key/apt_key.rb' -# Offense count: 1 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/GlobalStdStream: - Exclude: - - 'tasks/init.rb' - # Offense count: 1 Style/MixinUsage: Exclude: - 'spec/spec_helper.rb' - -# Offense count: 2 -# This cop supports unsafe autocorrection (--autocorrect-all). -Style/SlicingWithRange: - Exclude: - - 'lib/puppet/provider/apt_key/apt_key.rb' diff --git a/lib/puppet/provider/apt_key/apt_key.rb b/lib/puppet/provider/apt_key/apt_key.rb index 9ad21bcc6e..546f2c154b 100644 --- a/lib/puppet/provider/apt_key/apt_key.rb +++ b/lib/puppet/provider/apt_key/apt_key.rb @@ -92,8 +92,8 @@ def self.key_line_hash(pub_line, fpr_line) fingerprint = fpr_split.last return_hash = { key_fingerprint: fingerprint, - key_long: fingerprint[-16..-1], # last 16 characters of fingerprint - key_short: fingerprint[-8..-1], # last 8 characters of fingerprint + key_long: fingerprint[-16..], # last 16 characters of fingerprint + key_short: fingerprint[-8..], # last 8 characters of fingerprint key_size: pub_split[2], key_type: nil, key_created: Time.at(pub_split[5].to_i), diff --git a/tasks/init.rb b/tasks/init.rb index 132699ad01..ee141cdb69 100755 --- a/tasks/init.rb +++ b/tasks/init.rb @@ -21,7 +21,7 @@ def apt_get(action) { status: stdout.strip } end -params = JSON.parse(STDIN.read) +params = JSON.parse($stdin.read) action = params['action'] begin From 945062184700d344111871c7cd7ac768842d253e Mon Sep 17 00:00:00 2001 From: david22swan Date: Wed, 26 Apr 2023 17:09:00 +0100 Subject: [PATCH 14/18] (CONT-773) Rubocop Manual Fix 3 - Lint/ConstantDefinitionInBlock --- .rubocop_todo.yml | 9 -------- spec/defines/key_compat_spec.rb | 18 +++++----------- spec/defines/source_compat_spec.rb | 14 +++++-------- spec/defines/source_spec.rb | 33 ++++++++++++------------------ 4 files changed, 23 insertions(+), 51 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index fb3857b036..5c52997eb0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -6,15 +6,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 3 -# Configuration parameters: AllowedMethods. -# AllowedMethods: enums -Lint/ConstantDefinitionInBlock: - Exclude: - - 'spec/defines/key_compat_spec.rb' - - 'spec/defines/source_compat_spec.rb' - - 'spec/defines/source_spec.rb' - # Offense count: 6 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: diff --git a/spec/defines/key_compat_spec.rb b/spec/defines/key_compat_spec.rb index 4420337d19..8a0972e72b 100644 --- a/spec/defines/key_compat_spec.rb +++ b/spec/defines/key_compat_spec.rb @@ -21,8 +21,8 @@ def apt_key_example(title) end describe 'apt::key', type: :define do - GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F' - + let(:title) { '6F6B15509CF8E59E6E469F327F438280EF8D349F' } + let(:pre_condition) { 'include apt' } let(:facts) do { os: { @@ -40,14 +40,6 @@ def apt_key_example(title) } end - let :title do - GPG_KEY_ID - end - - let :pre_condition do - 'include apt' - end - describe 'normal operation' do describe 'default options' do it { @@ -70,12 +62,12 @@ def apt_key_example(title) let :params do { - id: GPG_KEY_ID + id: title } end it 'contains the apt_key' do - expect(subject).to contain_apt_key(title).with(id: GPG_KEY_ID, + expect(subject).to contain_apt_key(title).with(id: title, ensure: 'present', source: nil, server: 'keyserver.ubuntu.com', @@ -83,7 +75,7 @@ def apt_key_example(title) end it 'contains the apt_key present anchor' do - expect(subject).to contain_anchor("apt_key #{GPG_KEY_ID} present") + expect(subject).to contain_anchor("apt_key #{title} present") end end diff --git a/spec/defines/source_compat_spec.rb b/spec/defines/source_compat_spec.rb index a414c49386..55be585aa6 100644 --- a/spec/defines/source_compat_spec.rb +++ b/spec/defines/source_compat_spec.rb @@ -3,12 +3,8 @@ require 'spec_helper' describe 'apt::source', type: :define do - GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F' - - let :title do - 'my_source' - end - + let(:id) { '6F6B15509CF8E59E6E469F327F438280EF8D349F' } + let(:title) { 'my_source' } let :facts do { os: { @@ -47,7 +43,7 @@ 'release' => 'sid', 'repos' => 'testing', 'include' => { 'src' => false }, - 'key' => GPG_KEY_ID, + 'key' => id, 'pin' => '10', 'architecture' => 'x86_64', 'allow_unsigned' => true @@ -66,8 +62,8 @@ } it { - expect(subject).to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present', - 'id' => GPG_KEY_ID) + expect(subject).to contain_apt__key("Add key: #{id} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with('ensure' => 'present', + 'id' => id) } end diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index 8cf9a453aa..e9c0cf28af 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -3,16 +3,9 @@ require 'spec_helper' describe 'apt::source' do - GPG_KEY_ID = '6F6B15509CF8E59E6E469F327F438280EF8D349F' - - let :pre_condition do - 'class { "apt": }' - end - - let :title do - 'my_source' - end - + let(:id) { '6F6B15509CF8E59E6E469F327F438280EF8D349F' } + let(:title) { 'my_source' } + let(:pre_condition) { 'class { "apt": }' } let :facts do { os: { @@ -79,7 +72,7 @@ location: 'http://debian.mirror.iweb.ca/debian/', release: 'sid', repos: 'testing', - key: GPG_KEY_ID, + key: id, pin: '10', architecture: 'x86_64', allow_unsigned: true @@ -98,8 +91,8 @@ } it { - expect(subject).to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present', - id: GPG_KEY_ID) + expect(subject).to contain_apt__key("Add key: #{id} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'present', + id: id) } end @@ -112,7 +105,7 @@ repos: 'testing', key: { 'ensure' => 'refreshed', - 'id' => GPG_KEY_ID, + 'id' => id, 'server' => 'pgp.mit.edu', 'content' => 'GPG key content', 'source' => 'http://apt.puppetlabs.com/pubkey.gpg', @@ -136,12 +129,12 @@ } it { - expect(subject).to contain_apt__key("Add key: #{GPG_KEY_ID} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'refreshed', - id: GPG_KEY_ID, - server: 'pgp.mit.edu', - content: 'GPG key content', - source: 'http://apt.puppetlabs.com/pubkey.gpg', - weak_ssl: true) + expect(subject).to contain_apt__key("Add key: #{id} from Apt::Source my_source").that_comes_before('Apt::Setting[list-my_source]').with(ensure: 'refreshed', + id: GPG_KEY_ID, + server: 'pgp.mit.edu', + content: 'GPG key content', + source: 'http://apt.puppetlabs.com/pubkey.gpg', + weak_ssl: true) } end end From 46c94754d754cdf94fce800dd01cc48844b37ac8 Mon Sep 17 00:00:00 2001 From: david22swan Date: Wed, 26 Apr 2023 17:10:38 +0100 Subject: [PATCH 15/18] (CONT-773) Rubocop Manual Fix 4 - Performance/CollectionLiteralInLoop --- .rubocop_todo.yml | 6 ------ spec/classes/apt_update_spec.rb | 3 ++- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5c52997eb0..e978cec5ca 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -32,12 +32,6 @@ Metrics/MethodLength: Metrics/PerceivedComplexity: Max: 12 -# Offense count: 1 -# Configuration parameters: MinSize. -Performance/CollectionLiteralInLoop: - Exclude: - - 'spec/classes/apt_update_spec.rb' - # Offense count: 6 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without diff --git a/spec/classes/apt_update_spec.rb b/spec/classes/apt_update_spec.rb index ada31b1600..ede2fe02e1 100644 --- a/spec/classes/apt_update_spec.rb +++ b/spec/classes/apt_update_spec.rb @@ -154,7 +154,8 @@ ['daily', 'weekly'].each do |update_frequency| context "when apt::update['frequency'] has the value of #{update_frequency}" do - { 'we are due for a run' => 1_406_660_561, 'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| + pair = { 'we are due for a run' => 1_406_660_561, 'the update-success-stamp file does not exist' => -1 } + pair.each_pair do |desc, factval| context "when $apt_update_last_success indicates #{desc}" do let(:facts) do { From 415881576484bc7bb06568b6ed8b41c7152d8599 Mon Sep 17 00:00:00 2001 From: david22swan Date: Wed, 26 Apr 2023 17:47:07 +0100 Subject: [PATCH 16/18] (CONT-773) Rubocop Manual Fix 5 - RSpec/ContextWording --- .rubocop_todo.yml | 9 --------- spec/classes/apt_spec.rb | 2 +- spec/classes/apt_update_spec.rb | 2 +- spec/unit/puppet/provider/apt_key_spec.rb | 8 ++++---- 4 files changed, 6 insertions(+), 15 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index e978cec5ca..8b672acfb3 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -32,15 +32,6 @@ Metrics/MethodLength: Metrics/PerceivedComplexity: Max: 12 -# Offense count: 6 -# Configuration parameters: Prefixes, AllowedPatterns. -# Prefixes: when, with, without -RSpec/ContextWording: - Exclude: - - 'spec/classes/apt_spec.rb' - - 'spec/classes/apt_update_spec.rb' - - 'spec/unit/puppet/provider/apt_key_spec.rb' - # Offense count: 32 # Configuration parameters: IgnoredMetadata. RSpec/DescribeClass: diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 0e6b6b07da..12479b142d 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -389,7 +389,7 @@ } facts_hash.each do |os, facts| - context "on #{os}" do + context "when on #{os}" do let(:facts) do facts end diff --git a/spec/classes/apt_update_spec.rb b/spec/classes/apt_update_spec.rb index ede2fe02e1..c46771a52d 100644 --- a/spec/classes/apt_update_spec.rb +++ b/spec/classes/apt_update_spec.rb @@ -62,7 +62,7 @@ end end - context 'and Exec[apt_update] refreshonly is overridden to true and has recent run' do + context 'when Exec[apt_update] refreshonly is overridden to true and has recent run' do let(:facts) do { os: { diff --git a/spec/unit/puppet/provider/apt_key_spec.rb b/spec/unit/puppet/provider/apt_key_spec.rb index 7cab6ceb49..d683c9bf72 100644 --- a/spec/unit/puppet/provider/apt_key_spec.rb +++ b/spec/unit/puppet/provider/apt_key_spec.rb @@ -15,7 +15,7 @@ end end - context 'self.instances no key' do + context 'with self.instances no key' do before :each do # Unable to remove `master` from below terminology as it relies on outside code allow(described_class).to receive(:apt_key).with( @@ -28,7 +28,7 @@ end end - context 'self.instances multiple keys' do + context 'with self.instances multiple keys' do before :each do command_output = <<~OUTPUT Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.DU0GdRxjmE --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyring /etc/apt/trusted.gpg.d/puppetlabs-pc1-keyring.gpg --no-tty --list-keys --with-colons --fingerprint --fixed-list-mode @@ -54,7 +54,7 @@ end end - context 'create apt_key resource' do + context 'with create apt_key resource' do it 'apt_key with content set and source nil' do expect(described_class).to receive(:apt_key).with(['adv', '--no-tty', '--keyserver', @@ -172,7 +172,7 @@ end end - context 'key_line_hash function' do + context 'with key_line_hash function' do it 'matches rsa' do expect(described_class.key_line_hash('pub:-:1024:1:40976EAF437D05B5:1095016255:::-:::scESC:', 'fpr:::::::::630239CC130E1A7FD81A27B140976EAF437D05B5:')).to include( key_expiry: nil, From 82e0c388929245a69559261a8aec4ac37edcc567 Mon Sep 17 00:00:00 2001 From: david22swan Date: Wed, 26 Apr 2023 17:50:58 +0100 Subject: [PATCH 17/18] (CONT-773) Rubocop Manual Fix 6 - RSpec/RepeatedExampleGroupDescription --- .rubocop_todo.yml | 13 ------------- spec/acceptance/apt_spec.rb | 4 ++-- spec/classes/apt_spec.rb | 4 ++-- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 8b672acfb3..da3cce5150 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -42,13 +42,6 @@ RSpec/DescribeClass: RSpec/ExampleLength: Max: 15 -# Offense count: 3 -RSpec/LeakyConstantDeclaration: - Exclude: - - 'spec/defines/key_compat_spec.rb' - - 'spec/defines/source_compat_spec.rb' - - 'spec/defines/source_spec.rb' - # Offense count: 3 # Configuration parameters: AllowSubject. RSpec/MultipleMemoizedHelpers: @@ -88,12 +81,6 @@ RSpec/NoExpectationExample: - 'spec/acceptance/apt_key_provider_spec.rb' - 'spec/acceptance/apt_spec.rb' -# Offense count: 4 -RSpec/RepeatedExampleGroupDescription: - Exclude: - - 'spec/acceptance/apt_spec.rb' - - 'spec/classes/apt_spec.rb' - # Offense count: 3 RSpec/StubbedMock: Exclude: diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb index d726c342a2..802858e8e2 100644 --- a/spec/acceptance/apt_spec.rb +++ b/spec/acceptance/apt_spec.rb @@ -32,7 +32,7 @@ class { 'apt': MANIFEST describe 'apt class' do - context 'with reset' do + context 'with test start reset' do it 'fixes the sources.list' do run_shell('cp /etc/apt/sources.list /tmp') end @@ -52,7 +52,7 @@ class { 'apt': end end - context 'with reset' do + context 'with test end reset' do it 'fixes the sources.list' do run_shell('cp /tmp/sources.list /etc/apt') end diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 12479b142d..cb65c1e001 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -234,7 +234,7 @@ end end - context 'with lots of non-defaults' do + context 'with lots of non-defaults - one' do let :params do { update: { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 }, @@ -274,7 +274,7 @@ } end - context 'with lots of non-defaults' do + context 'with lots of non-defaults - two' do let :params do { update: { 'frequency' => 'always', 'timeout' => 1, 'tries' => 3 }, From 762808ff0d6bfc09825ff29d8ac527e44c663532 Mon Sep 17 00:00:00 2001 From: david22swan Date: Wed, 26 Apr 2023 18:05:15 +0100 Subject: [PATCH 18/18] (CONT-773) Lint/ConstantDefinitionInBlock Correction --- spec/defines/key_compat_spec.rb | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/spec/defines/key_compat_spec.rb b/spec/defines/key_compat_spec.rb index 8a0972e72b..613c7fd999 100644 --- a/spec/defines/key_compat_spec.rb +++ b/spec/defines/key_compat_spec.rb @@ -21,8 +21,7 @@ def apt_key_example(title) end describe 'apt::key', type: :define do - let(:title) { '6F6B15509CF8E59E6E469F327F438280EF8D349F' } - let(:pre_condition) { 'include apt' } + let(:key_id) { '6F6B15509CF8E59E6E469F327F438280EF8D349F' } let(:facts) do { os: { @@ -40,6 +39,14 @@ def apt_key_example(title) } end + let :title do + key_id + end + + let :pre_condition do + 'include apt' + end + describe 'normal operation' do describe 'default options' do it { @@ -62,12 +69,12 @@ def apt_key_example(title) let :params do { - id: title + id: key_id } end it 'contains the apt_key' do - expect(subject).to contain_apt_key(title).with(id: title, + expect(subject).to contain_apt_key(title).with(id: key_id, ensure: 'present', source: nil, server: 'keyserver.ubuntu.com', @@ -75,7 +82,7 @@ def apt_key_example(title) end it 'contains the apt_key present anchor' do - expect(subject).to contain_anchor("apt_key #{title} present") + expect(subject).to contain_anchor("apt_key #{key_id} present") end end