diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 50c86e74..46b0467a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,15 +1,165 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2016-08-17 14:58:12 -0700 using RuboCop version 0.42.0. +# on 2020-01-31 16:17:37 +0100 using RuboCop version 0.49.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. +# Offense count: 4 +# Cop supports --auto-correct. +Layout/AlignArray: + Exclude: + - 'lib/net/ldap.rb' + - 'lib/net/ldap/auth_adapter/sasl.rb' + - 'lib/net/ldap/connection.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, IndentOneStep, IndentationWidth. +# SupportedStyles: case, end +Layout/CaseIndentation: + Exclude: + - 'lib/net/ldap/filter.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/EmptyLineAfterMagicComment: + Exclude: + - 'net-ldap.gemspec' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines. +Layout/EmptyLineBetweenDefs: + Exclude: + - 'lib/net/ldap.rb' + - 'lib/net/ldap/dataset.rb' + - 'lib/net/snmp.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/EmptyLines: + Exclude: + - 'lib/net/snmp.rb' + # Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: AlignWith, SupportedStyles, AutoCorrect. -# SupportedStyles: keyword, variable, start_of_line +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines +Layout/EmptyLinesAroundClassBody: + Exclude: + - 'lib/net/ldap.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/EmptyLinesAroundExceptionHandlingKeywords: + Exclude: + - 'lib/net/ldap/connection.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: SupportedStyles, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_brackets +Layout/IndentArray: + EnforcedStyle: consistent + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: SupportedStyles, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_braces +Layout/IndentHash: + EnforcedStyle: consistent + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: Width, IgnoredPatterns. +Layout/IndentationWidth: + Exclude: + - 'lib/net/ber.rb' + - 'lib/net/ldap/password.rb' + - 'lib/net/snmp.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +Layout/LeadingCommentSpace: + Exclude: + - 'lib/net/ber/core_ext/array.rb' + - 'lib/net/ldap.rb' + - 'lib/net/ldap/connection.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: symmetrical, new_line, same_line +Layout/MultilineMethodCallBraceLayout: + Exclude: + - 'lib/net/ldap/filter.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: space, no_space +Layout/SpaceAroundEqualsInParameterDefault: + Exclude: + - 'lib/net/ldap/connection.rb' + - 'lib/net/snmp.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +Layout/SpaceAroundKeyword: + Exclude: + - 'lib/net/ldap/entry.rb' + - 'lib/net/snmp.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment. +Layout/SpaceAroundOperators: + Exclude: + - 'lib/net/ber/ber_parser.rb' + - 'lib/net/ldap/connection.rb' + - 'lib/net/ldap/entry.rb' + - 'lib/net/ldap/filter.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces, SpaceBeforeBlockParameters. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideBlockBraces: + Exclude: + - 'lib/net/ldap/dataset.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: SupportedStyles, EnforcedStyleForEmptyBraces, SupportedStylesForEmptyBraces. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideHashLiteralBraces: + EnforcedStyle: space + +# Offense count: 8 +# Cop supports --auto-correct. +Layout/SpaceInsideParens: + Exclude: + - 'lib/net/ldap/entry.rb' + - 'lib/net/snmp.rb' + +# Offense count: 1 +Lint/AmbiguousBlockAssociation: + Exclude: + - 'testserver/ldapserver.rb' + +# Offense count: 1 +Lint/EmptyWhen: + Exclude: + - 'lib/net/ldap/pdu.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleAlignWith, SupportedStylesAlignWith, AutoCorrect. +# SupportedStylesAlignWith: keyword, variable, start_of_line Lint/EndAlignment: Exclude: - 'testserver/ldapserver.rb' @@ -34,14 +184,13 @@ Lint/ShadowingOuterLocalVariable: Exclude: - 'lib/net/ldap/instrumentation.rb' -# Offense count: 10 +# Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. Lint/UnusedBlockArgument: Exclude: - 'lib/net/ldap.rb' - 'lib/net/snmp.rb' - - 'test/support/vm/openldap/Vagrantfile' # Offense count: 7 # Cop supports --auto-correct. @@ -55,12 +204,12 @@ Lint/UnusedMethodArgument: - 'test/test_search.rb' # Offense count: 1 -# Configuration parameters: ContextCreatingMethods. +# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods. Lint/UselessAccessModifier: Exclude: - 'lib/net/ldap/connection.rb' -# Offense count: 9 +# Offense count: 8 Lint/UselessAssignment: Exclude: - 'lib/net/ldap/connection.rb' @@ -70,42 +219,48 @@ Lint/UselessAssignment: - 'test/test_search.rb' - 'test/test_snmp.rb' -# Offense count: 47 +# Offense count: 49 Metrics/AbcSize: - Max: 114 + Max: 116 + +# Offense count: 4 +# Configuration parameters: CountComments, ExcludedMethods. +Metrics/BlockLength: + Max: 119 # Offense count: 11 +# Configuration parameters: CountBlocks. Metrics/BlockNesting: Max: 4 -# Offense count: 10 +# Offense count: 11 # Configuration parameters: CountComments. Metrics/ClassLength: - Max: 431 + Max: 429 -# Offense count: 22 +# Offense count: 23 Metrics/CyclomaticComplexity: Max: 41 -# Offense count: 225 -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes. +# Offense count: 215 +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Metrics/LineLength: Max: 360 -# Offense count: 70 +# Offense count: 74 # Configuration parameters: CountComments. Metrics/MethodLength: - Max: 130 + Max: 128 # Offense count: 1 # Configuration parameters: CountComments. Metrics/ModuleLength: - Max: 104 + Max: 103 -# Offense count: 14 +# Offense count: 15 Metrics/PerceivedComplexity: - Max: 37 + Max: 38 # Offense count: 1 Style/AccessorMethodName: @@ -124,26 +279,7 @@ Style/Alias: - 'lib/net/ldap/filter.rb' - 'lib/net/ldap/pdu.rb' -# Offense count: 4 -# Cop supports --auto-correct. -Style/AlignArray: - Exclude: - - 'lib/net/ldap.rb' - - 'lib/net/ldap/auth_adapter/sasl.rb' - - 'lib/net/ldap/connection.rb' - -# Offense count: 10 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. -# SupportedStyles: with_first_parameter, with_fixed_indentation -Style/AlignParameters: - Exclude: - - 'test/ber/test_ber.rb' - - 'test/integration/test_ber.rb' - - 'test/integration/test_bind.rb' - - 'test/integration/test_password_modify.rb' - -# Offense count: 37 +# Offense count: 33 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: always, conditionals @@ -155,7 +291,6 @@ Style/AndOr: - 'lib/net/ldap/dataset.rb' - 'lib/net/ldap/filter.rb' - 'lib/net/ldap/pdu.rb' - - 'testserver/ldapserver.rb' # Offense count: 1 # Cop supports --auto-correct. @@ -171,7 +306,7 @@ Style/BlockComments: Exclude: - 'test/test_rename.rb' -# Offense count: 6 +# Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: braces, no_braces, context_dependent @@ -179,15 +314,6 @@ Style/BracesAroundHashParameters: Exclude: - 'lib/net/ldap/auth_adapter/gss_spnego.rb' - 'lib/net/snmp.rb' - - 'test/test_ldap.rb' - -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep, IndentationWidth. -# SupportedStyles: case, end -Style/CaseIndentation: - Exclude: - - 'lib/net/ldap/filter.rb' # Offense count: 4 # Cop supports --auto-correct. @@ -216,13 +342,6 @@ Style/ClassCheck: - 'lib/net/ber/core_ext/array.rb' - 'lib/net/ldap/error.rb' -# Offense count: 13 -# Cop supports --auto-correct. -Style/ColonMethodCall: - Exclude: - - 'test/test_ldif.rb' - - 'test/test_ssl_ber.rb' - # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: Keywords. @@ -233,13 +352,13 @@ Style/CommentAnnotation: # Offense count: 1 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly. +# Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly, IncludeTernaryExpressions. # SupportedStyles: assign_to_condition, assign_inside_condition Style/ConditionalAssignment: Exclude: - 'lib/net/ldap/dn.rb' -# Offense count: 88 +# Offense count: 87 Style/ConstantName: Exclude: - 'lib/net/ldap.rb' @@ -268,53 +387,13 @@ Style/Documentation: - 'lib/net/snmp.rb' - 'testserver/ldapserver.rb' -# Offense count: 19 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: leading, trailing -Style/DotPosition: - Exclude: - - 'test/test_ldap_connection.rb' - - 'test/test_ssl_ber.rb' - # Offense count: 1 # Cop supports --auto-correct. -Style/ElseAlignment: - Exclude: - - 'testserver/ldapserver.rb' - -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: AllowAdjacentOneLineDefs. -Style/EmptyLineBetweenDefs: - Exclude: - - 'lib/net/ldap.rb' - - 'lib/net/ldap/dataset.rb' - - 'lib/net/snmp.rb' - -# Offense count: 8 -# Cop supports --auto-correct. -Style/EmptyLines: - Exclude: - - 'lib/net/snmp.rb' - - 'testserver/ldapserver.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: empty_lines, no_empty_lines -Style/EmptyLinesAroundClassBody: - Exclude: - - 'lib/net/ldap.rb' - - 'test/test_snmp.rb' - -# Offense count: 2 -# Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: empty_lines, no_empty_lines -Style/EmptyLinesAroundModuleBody: +# SupportedStyles: compact, expanded +Style/EmptyMethod: Exclude: - - 'testserver/ldapserver.rb' + - 'test/test_auth_adapter.rb' # Offense count: 3 # Cop supports --auto-correct. @@ -323,7 +402,8 @@ Style/EvenOdd: - 'lib/net/ldap/dn.rb' # Offense count: 1 -# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts. +# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms. +# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS Style/FileName: Exclude: - 'lib/net-ldap.rb' @@ -334,10 +414,16 @@ Style/GlobalVars: Exclude: - 'testserver/ldapserver.rb' -# Offense count: 161 +# Offense count: 2 +# Configuration parameters: MinBodyLength. +Style/GuardClause: + Exclude: + - 'lib/net/ldap/filter.rb' + +# Offense count: 159 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. -# SupportedStyles: ruby19, ruby19_no_mixed_keys, hash_rockets +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys Style/HashSyntax: Exclude: - 'lib/net/ber.rb' @@ -347,7 +433,6 @@ Style/HashSyntax: - 'lib/net/ldap/connection.rb' - 'lib/net/ldap/pdu.rb' - 'lib/net/snmp.rb' - - 'test/integration/test_bind.rb' - 'test/test_auth_adapter.rb' - 'test/test_ldap.rb' - 'test/test_ldap_connection.rb' @@ -360,7 +445,7 @@ Style/IfInsideElse: Exclude: - 'lib/net/ldap/instrumentation.rb' -# Offense count: 7 +# Offense count: 6 # Cop supports --auto-correct. # Configuration parameters: MaxLineLength. Style/IfUnlessModifier: @@ -370,40 +455,6 @@ Style/IfUnlessModifier: - 'lib/net/ldap.rb' - 'lib/net/ldap/filter.rb' - 'lib/net/snmp.rb' - - 'test/test_ldap_connection.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: SupportedStyles, IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_brackets -Style/IndentArray: - EnforcedStyle: consistent - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: SupportedStyles, IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_braces -Style/IndentHash: - EnforcedStyle: consistent - -# Offense count: 10 -# Cop supports --auto-correct. -# Configuration parameters: Width. -Style/IndentationWidth: - Exclude: - - 'lib/net/ber.rb' - - 'lib/net/ldap/password.rb' - - 'lib/net/snmp.rb' - - 'test/test_snmp.rb' - - 'testserver/ldapserver.rb' - -# Offense count: 3 -# Cop supports --auto-correct. -Style/LeadingCommentSpace: - Exclude: - - 'lib/net/ber/core_ext/array.rb' - - 'lib/net/ldap.rb' - - 'lib/net/ldap/connection.rb' # Offense count: 21 # Cop supports --auto-correct. @@ -422,37 +473,13 @@ Style/MethodMissing: - 'lib/net/ldap/dn.rb' - 'lib/net/ldap/entry.rb' -# Offense count: 1 -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: snake_case, camelCase -Style/MethodName: - Exclude: - - 'lib/net/ldap/filter.rb' - -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: symmetrical, new_line, same_line -Style/MultilineMethodCallBraceLayout: - Exclude: - - 'lib/net/ldap/filter.rb' - - 'test/test_entry.rb' - - 'test/test_ldap_connection.rb' - -# Offense count: 1 +# Offense count: 2 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. -# SupportedStyles: aligned, indented, indented_relative_to_receiver -Style/MultilineMethodCallIndentation: - Exclude: - - 'test/test_ldap_connection.rb' - -# Offense count: 1 -Style/MultilineTernaryOperator: +Style/MultilineIfModifier: Exclude: - 'lib/net/ldap/connection.rb' -# Offense count: 26 +# Offense count: 25 # Cop supports --auto-correct. Style/MutableConstant: Exclude: @@ -463,12 +490,13 @@ Style/MutableConstant: - 'lib/net/ldap/filter.rb' - 'lib/net/ldap/version.rb' - 'lib/net/snmp.rb' - - 'test/support/vm/openldap/Vagrantfile' - 'test/test_ldif.rb' - 'testserver/ldapserver.rb' # Offense count: 1 # Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: both, prefix, postfix Style/NegatedIf: Exclude: - 'test/test_helper.rb' @@ -509,15 +537,17 @@ Style/Not: # Offense count: 11 # Cop supports --auto-correct. +# Configuration parameters: Strict. Style/NumericLiterals: MinDigits: 8 -# Offense count: 4 +# Offense count: 3 # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. +# Configuration parameters: AutoCorrect, EnforcedStyle, SupportedStyles. # SupportedStyles: predicate, comparison Style/NumericPredicate: Exclude: + - 'spec/**/*' - 'lib/net/ber/core_ext/integer.rb' - 'lib/net/ldap/dn.rb' - 'testserver/ldapserver.rb' @@ -537,13 +567,18 @@ Style/ParenthesesAroundCondition: - 'lib/net/ldap/auth_adapter/sasl.rb' - 'lib/net/ldap/auth_adapter/simple.rb' -# Offense count: 3 +# Offense count: 11 # Cop supports --auto-correct. # Configuration parameters: PreferredDelimiters. Style/PercentLiteralDelimiters: Exclude: - 'net-ldap.gemspec' + - 'test/integration/test_add.rb' + - 'test/integration/test_delete.rb' + - 'test/integration/test_open.rb' + - 'test/integration/test_password_modify.rb' - 'test/test_entry.rb' + - 'test/test_helper.rb' # Offense count: 11 # Cop supports --auto-correct. @@ -619,69 +654,6 @@ Style/Semicolon: - 'lib/net/ldap/error.rb' - 'testserver/ldapserver.rb' -# Offense count: 2 -# Configuration parameters: Methods. -# Methods: {"reduce"=>["a", "e"]}, {"inject"=>["a", "e"]} -Style/SingleLineBlockParams: - Exclude: - - 'lib/net/ldap/filter.rb' - -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: space, no_space -Style/SpaceAroundEqualsInParameterDefault: - Exclude: - - 'lib/net/ldap/connection.rb' - - 'lib/net/snmp.rb' - -# Offense count: 4 -# Cop supports --auto-correct. -Style/SpaceAroundKeyword: - Exclude: - - 'lib/net/ldap/entry.rb' - - 'lib/net/snmp.rb' - -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment. -Style/SpaceAroundOperators: - Exclude: - - 'lib/net/ber/ber_parser.rb' - - 'lib/net/ldap/connection.rb' - - 'lib/net/ldap/entry.rb' - - 'lib/net/ldap/filter.rb' - - 'test/test_entry.rb' - - 'test/test_ldap_connection.rb' - -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. -# SupportedStyles: space, no_space -Style/SpaceInsideBlockBraces: - Exclude: - - 'lib/net/ldap/dataset.rb' - - 'test/test_snmp.rb' - - 'testserver/ldapserver.rb' - -# Offense count: 13 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles. -# SupportedStyles: space, no_space, compact -Style/SpaceInsideHashLiteralBraces: - Exclude: - - 'lib/net/ldap/dataset.rb' - - 'test/test_ldap.rb' - -# Offense count: 20 -# Cop supports --auto-correct. -Style/SpaceInsideParens: - Exclude: - - 'lib/net/ldap/entry.rb' - - 'lib/net/snmp.rb' - - 'test/test_password.rb' - - 'testserver/ldapserver.rb' - # Offense count: 5 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. @@ -692,7 +664,7 @@ Style/SpecialGlobalVars: - 'net-ldap.gemspec' - 'testserver/ldapserver.rb' -# Offense count: 679 +# Offense count: 649 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes @@ -704,10 +676,17 @@ Style/StructInheritance: Exclude: - 'test/test_ldap.rb' +# Offense count: 10 +# Cop supports --auto-correct. +# Configuration parameters: MinSize, SupportedStyles. +# SupportedStyles: percent, brackets +Style/SymbolArray: + EnforcedStyle: brackets + # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, AllowSafeAssignment. -# SupportedStyles: require_parentheses, require_no_parentheses +# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex Style/TernaryParentheses: Exclude: - 'lib/net/ber/core_ext/integer.rb' @@ -744,6 +723,13 @@ Style/WordArray: EnforcedStyle: percent MinSize: 3 +# Offense count: 2 +# Cop supports --auto-correct. +Style/YodaCondition: + Exclude: + - 'lib/net/ber/ber_parser.rb' + - 'testserver/ldapserver.rb' + # Offense count: 6 # Cop supports --auto-correct. Style/ZeroLengthPredicate: diff --git a/lib/net/ldap/filter.rb b/lib/net/ldap/filter.rb index 6f064488..b7a92c60 100644 --- a/lib/net/ldap/filter.rb +++ b/lib/net/ldap/filter.rb @@ -646,7 +646,7 @@ def match(entry) ## # Converts escaped characters (e.g., "\\28") to unescaped characters # @note slawson20170317: Don't attempt to unescape 16 byte binary data which we assume are objectGUIDs - # The binary form of 5936AE79-664F-44EA-BCCB-5C39399514C6 triggers a BINARY -> UTF-8 conversion error + # The binary form of 5936AE79-664F-44EA-BCCB-5C39399514C6 triggers a BINARY -> UTF-8 conversion error def unescape(right) right = right.to_s if right.length == 16 && right.encoding == Encoding::BINARY diff --git a/test/ber/test_ber.rb b/test/ber/test_ber.rb index 5d5c1266..b700972e 100644 --- a/test/ber/test_ber.rb +++ b/test/ber/test_ber.rb @@ -95,7 +95,7 @@ def test_utf8_encodable_strings def test_encode_binary_data # This is used for searching for GUIDs in Active Directory assert_equal "\x04\x10" + "j1\xB4\xA1*\xA2zA\xAC\xA9`?'\xDDQ\x16".b, - ["6a31b4a12aa27a41aca9603f27dd5116"].pack("H*").to_ber_bin + ["6a31b4a12aa27a41aca9603f27dd5116"].pack("H*").to_ber_bin end def test_non_utf8_encodable_strings diff --git a/test/integration/test_ber.rb b/test/integration/test_ber.rb index 3b1ba09b..4464bf78 100644 --- a/test/integration/test_ber.rb +++ b/test/integration/test_ber.rb @@ -25,6 +25,6 @@ def test_true_ber_encoding end assert_includes Net::LDAP::ResultCodesSearchSuccess, - @ldap.get_operation_result.code, "should be a successful search operation" + @ldap.get_operation_result.code, "should be a successful search operation" end end diff --git a/test/integration/test_bind.rb b/test/integration/test_bind.rb index 7df263c1..5bae8ffa 100644 --- a/test/integration/test_bind.rb +++ b/test/integration/test_bind.rb @@ -1,7 +1,6 @@ require_relative '../test_helper' class TestBindIntegration < LDAPIntegrationTestCase - INTEGRATION_HOSTNAME = 'ldap.example.org'.freeze def test_bind_success @@ -28,7 +27,7 @@ def test_bind_anonymous_fail assert_equal Net::LDAP::ResultCodeUnwillingToPerform, result.code assert_equal Net::LDAP::ResultStrings[Net::LDAP::ResultCodeUnwillingToPerform], result.message assert_equal "unauthenticated bind (DN with no password) disallowed", - result.error_message + result.error_message assert_equal "", result.matched_dn end diff --git a/test/integration/test_password_modify.rb b/test/integration/test_password_modify.rb index 8c4d8593..65507c80 100644 --- a/test/integration/test_password_modify.rb +++ b/test/integration/test_password_modify.rb @@ -3,7 +3,7 @@ class TestPasswordModifyIntegration < LDAPIntegrationTestCase def setup super - @admin_account = {dn: 'cn=admin,dc=example,dc=org', password: 'admin', method: :simple} + @admin_account = { dn: 'cn=admin,dc=example,dc=org', password: 'admin', method: :simple } @ldap.authenticate @admin_account[:dn], @admin_account[:password] @dn = 'uid=modify-password-user1,ou=People,dc=example,dc=org' @@ -35,13 +35,13 @@ def test_password_modify new_password: 'passworD2') assert @ldap.get_operation_result.extended_response.nil?, - 'Should not have generated a new password' + 'Should not have generated a new password' refute @ldap.bind(username: @dn, password: 'admin', method: :simple), - 'Old password should no longer be valid' + 'Old password should no longer be valid' assert @ldap.bind(username: @dn, password: 'passworD2', method: :simple), - 'New password should be valid' + 'New password should be valid' end def test_password_modify_generate @@ -54,10 +54,10 @@ def test_password_modify_generate assert generated_password, 'Should have generated a password' refute @ldap.bind(username: @dn, password: 'admin', method: :simple), - 'Old password should no longer be valid' + 'Old password should no longer be valid' assert @ldap.bind(username: @dn, password: generated_password, method: :simple), - 'New password should be valid' + 'New password should be valid' end def test_password_modify_generate_no_old_password @@ -69,10 +69,10 @@ def test_password_modify_generate_no_old_password assert generated_password, 'Should have generated a password' refute @ldap.bind(username: @dn, password: 'admin', method: :simple), - 'Old password should no longer be valid' + 'Old password should no longer be valid' assert @ldap.bind(username: @dn, password: generated_password, method: :simple), - 'New password should be valid' + 'New password should be valid' end def test_password_modify_overwrite_old_password @@ -81,10 +81,10 @@ def test_password_modify_overwrite_old_password new_password: 'passworD3') refute @ldap.bind(username: @dn, password: 'admin', method: :simple), - 'Old password should no longer be valid' + 'Old password should no longer be valid' assert @ldap.bind(username: @dn, password: 'passworD3', method: :simple), - 'New password should be valid' + 'New password should be valid' end def teardown diff --git a/test/test_entry.rb b/test/test_entry.rb index e2184747..2095f581 100644 --- a/test/test_entry.rb +++ b/test/test_entry.rb @@ -47,7 +47,8 @@ def setup %Q{dn: something foo: foo barAttribute: bar - }) + }, + ) end def test_attribute @@ -59,7 +60,7 @@ def test_modify_attribute @entry.foo = 'bar' assert_equal ['bar'], @entry.foo - @entry.fOo= 'baz' + @entry.fOo = 'baz' assert_equal ['baz'], @entry.foo end end diff --git a/test/test_filter_parser.rb b/test/test_filter_parser.rb index 6f1ca48b..7319abab 100644 --- a/test/test_filter_parser.rb +++ b/test/test_filter_parser.rb @@ -1,4 +1,5 @@ # encoding: utf-8 + require_relative 'test_helper' class TestFilterParser < Test::Unit::TestCase diff --git a/test/test_ldap.rb b/test/test_ldap.rb index 8d6a9a72..66962e9d 100644 --- a/test/test_ldap.rb +++ b/test/test_ldap.rb @@ -94,7 +94,7 @@ def test_encryption def test_normalize_encryption_symbol enc = @subject.send(:normalize_encryption, :start_tls) - assert_equal enc, {:method => :start_tls, :tls_options => {}} + assert_equal enc, :method => :start_tls, :tls_options => {} end def test_normalize_encryption_nil @@ -104,11 +104,11 @@ def test_normalize_encryption_nil def test_normalize_encryption_string enc = @subject.send(:normalize_encryption, 'start_tls') - assert_equal enc, {:method => :start_tls, :tls_options => {}} + assert_equal enc, :method => :start_tls, :tls_options => {} end def test_normalize_encryption_hash - enc = @subject.send(:normalize_encryption, {:method => :start_tls, :tls_options => {:foo => :bar}}) - assert_equal enc, {:method => :start_tls, :tls_options => {:foo => :bar}} + enc = @subject.send(:normalize_encryption, :method => :start_tls, :tls_options => { :foo => :bar }) + assert_equal enc, :method => :start_tls, :tls_options => { :foo => :bar } end end diff --git a/test/test_ldap_connection.rb b/test/test_ldap_connection.rb index 8489c377..969d695a 100644 --- a/test/test_ldap_connection.rb +++ b/test/test_ldap_connection.rb @@ -124,7 +124,7 @@ def test_modify_ops_add end def test_modify_ops_replace - args = { :operations =>[[:replace, "mail", "testuser@example.com"]] } + args = { :operations => [[:replace, "mail", "testuser@example.com"]] } result = Net::LDAP::Connection.modify_ops(args[:operations]) expected = ["0#\n\x01\x020\x1E\x04\x04mail1\x16\x04\x14testuser@example.com"] assert_equal(expected, result) @@ -191,9 +191,9 @@ def test_queued_read_reads_until_message_id_match result2 = make_message(2) mock = flexmock("socket") - mock.should_receive(:read_ber). - and_return(result1). - and_return(result2) + mock.should_receive(:read_ber) + .and_return(result1) + .and_return(result2) conn = Net::LDAP::Connection.new(:socket => mock) assert result = conn.queued_read(2) @@ -206,9 +206,9 @@ def test_queued_read_modify result2 = make_message(2, app_tag: Net::LDAP::PDU::ModifyResponse) mock = flexmock("socket") - mock.should_receive(:read_ber). - and_return(result1). - and_return(result2) + mock.should_receive(:read_ber) + .and_return(result1) + .and_return(result2) mock.should_receive(:write) conn = Net::LDAP::Connection.new(:socket => mock) @@ -227,9 +227,9 @@ def test_queued_read_add result2 = make_message(2, app_tag: Net::LDAP::PDU::AddResponse) mock = flexmock("socket") - mock.should_receive(:read_ber). - and_return(result1). - and_return(result2) + mock.should_receive(:read_ber) + .and_return(result1) + .and_return(result2) mock.should_receive(:write) conn = Net::LDAP::Connection.new(:socket => mock) @@ -245,9 +245,9 @@ def test_queued_read_rename result2 = make_message(2, app_tag: Net::LDAP::PDU::ModifyRDNResponse) mock = flexmock("socket") - mock.should_receive(:read_ber). - and_return(result1). - and_return(result2) + mock.should_receive(:read_ber) + .and_return(result1) + .and_return(result2) mock.should_receive(:write) conn = Net::LDAP::Connection.new(:socket => mock) @@ -266,9 +266,9 @@ def test_queued_read_delete result2 = make_message(2, app_tag: Net::LDAP::PDU::DeleteResponse) mock = flexmock("socket") - mock.should_receive(:read_ber). - and_return(result1). - and_return(result2) + mock.should_receive(:read_ber) + .and_return(result1) + .and_return(result2) mock.should_receive(:write) conn = Net::LDAP::Connection.new(:socket => mock) @@ -284,13 +284,13 @@ def test_queued_read_setup_encryption_with_start_tls result2 = make_message(2, app_tag: Net::LDAP::PDU::ExtendedResponse) mock = flexmock("socket") - mock.should_receive(:read_ber). - and_return(result1). - and_return(result2) + mock.should_receive(:read_ber) + .and_return(result1) + .and_return(result2) mock.should_receive(:write) conn = Net::LDAP::Connection.new(:socket => mock) - flexmock(Net::LDAP::Connection).should_receive(:wrap_with_ssl).with(mock, {}, nil). - and_return(mock) + flexmock(Net::LDAP::Connection).should_receive(:wrap_with_ssl).with(mock, {}, nil) + .and_return(mock) conn.next_msgid # simulates ongoing query @@ -303,9 +303,9 @@ def test_queued_read_bind_simple result2 = make_message(2, app_tag: Net::LDAP::PDU::BindResult) mock = flexmock("socket") - mock.should_receive(:read_ber). - and_return(result1). - and_return(result2) + mock.should_receive(:read_ber) + .and_return(result1) + .and_return(result2) mock.should_receive(:write) conn = Net::LDAP::Connection.new(:socket => mock) @@ -314,7 +314,8 @@ def test_queued_read_bind_simple assert result = conn.bind( method: :simple, username: "uid=user1,ou=People,dc=rubyldap,dc=com", - password: "passworD1") + password: "passworD1", + ) assert result.success? assert_equal 2, result.message_id end @@ -324,9 +325,9 @@ def test_queued_read_bind_sasl result2 = make_message(2, app_tag: Net::LDAP::PDU::BindResult) mock = flexmock("socket") - mock.should_receive(:read_ber). - and_return(result1). - and_return(result2) + mock.should_receive(:read_ber) + .and_return(result1) + .and_return(result2) mock.should_receive(:write) conn = Net::LDAP::Connection.new(:socket => mock) @@ -336,7 +337,8 @@ def test_queued_read_bind_sasl method: :sasl, mechanism: "fake", initial_credential: "passworD1", - challenge_response: flexmock("challenge proc")) + challenge_response: flexmock("challenge proc"), + ) assert result.success? assert_equal 2, result.message_id end @@ -469,8 +471,8 @@ def test_search_net_ldap_connection_event search_result_ber = Net::BER::BerIdentifiedArray.new([Net::LDAP::ResultCodeSuccess, "", ""]) search_result_ber.ber_identifier = Net::LDAP::PDU::SearchResult search_result = [1, search_result_ber] - @tcp_socket.should_receive(:read_ber).and_return(search_data). - and_return(search_result) + @tcp_socket.should_receive(:read_ber).and_return(search_data) + .and_return(search_result) events = @service.subscribe "search.net_ldap_connection" unread = @service.subscribe "search_messages_unread.net_ldap_connection" diff --git a/test/test_ldif.rb b/test/test_ldif.rb index cc1ee2bf..c74ea6e7 100644 --- a/test/test_ldif.rb +++ b/test/test_ldif.rb @@ -22,46 +22,46 @@ def test_ldif_with_version def test_ldif_with_comments str = ["# Hello from LDIF-land", "# This is an unterminated comment"] io = StringIO.new(str[0] + "\r\n" + str[1]) - ds = Net::LDAP::Dataset::read_ldif(io) + ds = Net::LDAP::Dataset.read_ldif(io) assert_equal(str, ds.comments) end def test_ldif_with_password psw = "goldbricks" - hashed_psw = "{SHA}" + Base64::encode64(Digest::SHA1.digest(psw)).chomp + hashed_psw = "{SHA}" + Base64.encode64(Digest::SHA1.digest(psw)).chomp - ldif_encoded = Base64::encode64(hashed_psw).chomp - ds = Net::LDAP::Dataset::read_ldif(StringIO.new("dn: Goldbrick\r\nuserPassword:: #{ldif_encoded}\r\n\r\n")) + ldif_encoded = Base64.encode64(hashed_psw).chomp + ds = Net::LDAP::Dataset.read_ldif(StringIO.new("dn: Goldbrick\r\nuserPassword:: #{ldif_encoded}\r\n\r\n")) recovered_psw = ds["Goldbrick"][:userpassword].shift assert_equal(hashed_psw, recovered_psw) end def test_ldif_with_continuation_lines - ds = Net::LDAP::Dataset::read_ldif(StringIO.new("dn: abcdefg\r\n hijklmn\r\n\r\n")) + ds = Net::LDAP::Dataset.read_ldif(StringIO.new("dn: abcdefg\r\n hijklmn\r\n\r\n")) assert_equal(true, ds.key?("abcdefghijklmn")) end def test_ldif_with_continuation_lines_and_extra_whitespace - ds1 = Net::LDAP::Dataset::read_ldif(StringIO.new("dn: abcdefg\r\n hijklmn\r\n\r\n")) + ds1 = Net::LDAP::Dataset.read_ldif(StringIO.new("dn: abcdefg\r\n hijklmn\r\n\r\n")) assert_equal(true, ds1.key?("abcdefg hijklmn")) - ds2 = Net::LDAP::Dataset::read_ldif(StringIO.new("dn: abcdefg\r\n hij klmn\r\n\r\n")) + ds2 = Net::LDAP::Dataset.read_ldif(StringIO.new("dn: abcdefg\r\n hij klmn\r\n\r\n")) assert_equal(true, ds2.key?("abcdefghij klmn")) end def test_ldif_tab_is_not_continuation - ds = Net::LDAP::Dataset::read_ldif(StringIO.new("dn: key\r\n\tnotcontinued\r\n\r\n")) + ds = Net::LDAP::Dataset.read_ldif(StringIO.new("dn: key\r\n\tnotcontinued\r\n\r\n")) assert_equal(true, ds.key?("key")) end def test_ldif_with_base64_dn str = "dn:: Q049QmFzZTY0IGRuIHRlc3QsT1U9VGVzdCxPVT1Vbml0cyxEQz1leGFtcGxlLERDPWNvbQ==\r\n\r\n" - ds = Net::LDAP::Dataset::read_ldif(StringIO.new(str)) + ds = Net::LDAP::Dataset.read_ldif(StringIO.new(str)) assert_equal(true, ds.key?("CN=Base64 dn test,OU=Test,OU=Units,DC=example,DC=com")) end def test_ldif_with_base64_dn_and_continuation_lines str = "dn:: Q049QmFzZTY0IGRuIHRlc3Qgd2l0aCBjb250aW51YXRpb24gbGluZSxPVT1UZXN0LE9VPVVua\r\n XRzLERDPWV4YW1wbGUsREM9Y29t\r\n\r\n" - ds = Net::LDAP::Dataset::read_ldif(StringIO.new(str)) + ds = Net::LDAP::Dataset.read_ldif(StringIO.new(str)) assert_equal(true, ds.key?("CN=Base64 dn test with continuation line,OU=Test,OU=Units,DC=example,DC=com")) end @@ -69,7 +69,7 @@ def test_ldif_with_base64_dn_and_continuation_lines # to verify the content. def test_ldif File.open(TestLdifFilename, "r") do |f| - ds = Net::LDAP::Dataset::read_ldif(f) + ds = Net::LDAP::Dataset.read_ldif(f) assert_equal(13, ds.length) end end @@ -84,7 +84,7 @@ def test_to_ldif entries = data.lines.grep(/^dn:\s*/) { $'.chomp } dn_entries = entries.dup - ds = Net::LDAP::Dataset::read_ldif(io) do |type, value| + ds = Net::LDAP::Dataset.read_ldif(io) do |type, value| case type when :dn assert_equal(dn_entries.first, value) diff --git a/test/test_password.rb b/test/test_password.rb index 87b47d91..685b3a3d 100644 --- a/test/test_password.rb +++ b/test/test_password.rb @@ -4,7 +4,7 @@ class TestPassword < Test::Unit::TestCase def test_psw - assert_equal("{MD5}xq8jwrcfibi0sZdZYNkSng==", Net::LDAP::Password.generate( :md5, "cashflow" )) - assert_equal("{SHA}YE4eGkN4BvwNN1f5R7CZz0kFn14=", Net::LDAP::Password.generate( :sha, "cashflow" )) + assert_equal("{MD5}xq8jwrcfibi0sZdZYNkSng==", Net::LDAP::Password.generate(:md5, "cashflow")) + assert_equal("{SHA}YE4eGkN4BvwNN1f5R7CZz0kFn14=", Net::LDAP::Password.generate(:sha, "cashflow")) end end diff --git a/test/test_snmp.rb b/test/test_snmp.rb index 6a809a80..b6d1e9c8 100644 --- a/test/test_snmp.rb +++ b/test/test_snmp.rb @@ -17,7 +17,7 @@ def self.raw_string(s) def test_invalid_packet data = "xxxx" assert_raise(Net::BER::BerError) do -ary = data.read_ber(Net::SNMP::AsnSyntax) + ary = data.read_ber(Net::SNMP::AsnSyntax) end end @@ -41,7 +41,7 @@ def _test_consume_string def test_weird_packet assert_raise(Net::SnmpPdu::Error) do -Net::SnmpPdu.parse("aaaaaaaaaaaaaa") + Net::SnmpPdu.parse("aaaaaaaaaaaaaa") end end @@ -93,7 +93,7 @@ def test_make_response def test_make_bad_response pdu = Net::SnmpPdu.new - assert_raise(Net::SnmpPdu::Error) {pdu.to_ber_string} + assert_raise(Net::SnmpPdu::Error) { pdu.to_ber_string } pdu.pdu_type = :get_response pdu.request_id = 999 pdu.to_ber_string @@ -115,5 +115,4 @@ def test_community pdu = Net::SnmpPdu.parse(ary) assert_equal("xxxxxx", pdu.community) end - end diff --git a/test/test_ssl_ber.rb b/test/test_ssl_ber.rb index 7711558b..873e3325 100644 --- a/test/test_ssl_ber.rb +++ b/test/test_ssl_ber.rb @@ -5,7 +5,7 @@ class TestSSLBER < Test::Unit::TestCase # Transmits str to @to and reads it back from @from. # def transmit(str) - Timeout::timeout(1) do + Timeout.timeout(1) do @to.write(str) @to.close @@ -22,8 +22,8 @@ def setup # # TODO: Replace test with real socket # https://github.com/ruby-ldap/ruby-net-ldap/pull/121#discussion_r18746386 - flexmock(OpenSSL::SSL::SSLSocket). - new_instances.should_receive(:connect => nil) + flexmock(OpenSSL::SSL::SSLSocket) + .new_instances.should_receive(:connect => nil) @to = Net::LDAP::Connection.wrap_with_ssl(@to) @from = Net::LDAP::Connection.wrap_with_ssl(@from) diff --git a/testserver/ldapserver.rb b/testserver/ldapserver.rb index 809f9e7e..aa8881a2 100644 --- a/testserver/ldapserver.rb +++ b/testserver/ldapserver.rb @@ -15,7 +15,6 @@ #------------------------------------------------ module LdapServer - LdapServerAsnSyntax = { :application => { :constructed => { @@ -46,7 +45,7 @@ def receive_data data @data ||= ""; @data << data while pdu = @data.read_ber!(LdapServerAsnSyntax) begin - handle_ldap_pdu pdu + handle_ldap_pdu pdu rescue $logger.error "closing connection due to error #{$!}" close_connection @@ -87,9 +86,7 @@ def handle_bind_request pdu end end - - - #-- + # -- # Search Response ::= # CHOICE { # entry [APPLICATION 4] SEQUENCE { @@ -119,9 +116,9 @@ def handle_search_request pdu # pdu[1][7] is the list of requested attributes. # If it's an empty array, that means that *all* attributes were requested. requested_attrs = if pdu[1][7].length > 0 - pdu[1][7].map(&:downcase) - else - :all + pdu[1][7].map(&:downcase) + else + :all end filters = pdu[1][6] @@ -131,13 +128,13 @@ def handle_search_request pdu end # TODO, what if this returns nil? - filter = Net::LDAP::Filter.parse_ldap_filter( filters ) + filter = Net::LDAP::Filter.parse_ldap_filter(filters) $ldif.each do |dn, entry| - if filter.match( entry ) + if filter.match(entry) attrs = [] entry.each do |k, v| - if requested_attrs == :all or requested_attrs.include?(k.downcase) + if requested_attrs == :all || requested_attrs.include?(k.downcase) attrvals = v.map(&:to_ber).to_ber_set attrs << [k.to_ber, attrvals].to_ber_sequence end @@ -149,32 +146,27 @@ def handle_search_request pdu end end - send_ldap_response 5, pdu[0].to_i, 0, "", "Was that what you wanted?" end - - def send_ldap_response pkt_tag, msgid, code, dn, text - send_data( [msgid.to_ber, [code.to_ber, dn.to_ber, text.to_ber].to_ber_appsequence(pkt_tag)].to_ber ) + send_data([msgid.to_ber, [code.to_ber, dn.to_ber, text.to_ber].to_ber_appsequence(pkt_tag)].to_ber) end - end - #------------------------------------------------ # Rather bogus, a global method, which reads a HARDCODED filename # parses out LDIF data. It will be used to serve LDAP queries out of this server. # def load_test_data - ary = File.readlines( "./testdata.ldif" ) + ary = File.readlines("./testdata.ldif") hash = {} - while line = ary.shift and line.chomp! + while (line = ary.shift) && line.chomp! if line =~ /^dn:[\s]*/i dn = $' hash[dn] = {} - while attr = ary.shift and attr.chomp! and attr =~ /^([\w]+)[\s]*:[\s]*/ + while (attr = ary.shift) && attr.chomp! && attr =~ /^([\w]+)[\s]*:[\s]*/ hash[dn][$1.downcase] ||= [] hash[dn][$1.downcase] << $' end @@ -183,7 +175,6 @@ def load_test_data hash end - #------------------------------------------------ if __FILE__ == $0 @@ -204,6 +195,6 @@ def load_test_data EventMachine.run do $logger.info "starting LDAP server on 127.0.0.1 port 3890" EventMachine.start_server "127.0.0.1", 3890, LdapServer - EventMachine.add_periodic_timer 60, proc {$logger.info "heartbeat"} + EventMachine.add_periodic_timer 60, proc { $logger.info "heartbeat" } end end
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: