Skip to content

Commit

Permalink
Pet rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
smortex committed Aug 18, 2023
1 parent e34750a commit 5cf9b17
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/puppet/type/openldap_database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,17 @@ def insync?(is)
when %r{^\{MD5\}.+}
"{MD5}#{Digest::MD5.hexdigest(should)}" == is
when %r{^\{SMD5\}.+}
salt = is[16..-1]
salt = is[16..]
md5_hash_with_salt = "#{Digest::MD5.digest(should + salt)}#{salt}"
is == "{SMD5}#{[md5_hash_with_salt].pack('m').delete("\n")}"
when %r{^\{SSHA\}.+}
decoded = Base64.decode64(is.gsub(%r{^\{SSHA\}}, ''))
salt = decoded[20..-1]
salt = decoded[20..]
"{SSHA}#{Base64.encode64("#{Digest::SHA1.digest("#{should}#{salt}")}#{salt}").chomp}" == is
when %r{^\{SHA\}.+}
"{SHA}#{Digest::SHA1.hexdigest(should)}" == is
when %r{^\{(SHA(256|384|512))\}}
matches = is.match("^\{(SHA[\\d]{,3})\}")
matches = is.match('^{(SHA[\\d]{,3})}')
raise ArgumentError, "Invalid password format: #{is}" if matches.nil?

crypto = matches[1]
Expand Down
2 changes: 1 addition & 1 deletion spec/functions/openldap_password_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# rubocop:disable RSpec/DescribeSymbol
describe :openldap_password do
it { is_expected.not_to eq(nil) }
it { is_expected.not_to be_nil }

it 'fails with wrong number of arguments' do
is_expected.to run.with_params.and_raise_error(StandardError)
Expand Down

0 comments on commit 5cf9b17

Please sign in to comment.