Skip to content

Commit

Permalink
Autofix Rubocop Style/CaseLikeIf (mastodon#23756)
Browse files Browse the repository at this point in the history
  • Loading branch information
nschonni authored May 4, 2023
1 parent 1fe04f7 commit d5a185d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
6 changes: 0 additions & 6 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1031,12 +1031,6 @@ Style/CaseEquality:
Exclude:
- 'config/initializers/trusted_proxies.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: MinBranchesCount.
Style/CaseLikeIf:
Exclude:
- 'app/controllers/concerns/signature_verification.rb'

# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowedMethods, AllowedPatterns.
# AllowedMethods: ==, equal?, eql?
Expand Down
7 changes: 4 additions & 3 deletions app/controllers/concerns/signature_verification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,15 @@ def verify_signature(actor, signature, compare_signed_string)

def build_signed_string
signed_headers.map do |signed_header|
if signed_header == Request::REQUEST_TARGET
case signed_header
when Request::REQUEST_TARGET
"#{Request::REQUEST_TARGET}: #{request.method.downcase} #{request.path}"
elsif signed_header == '(created)'
when '(created)'
raise SignatureVerificationError, 'Invalid pseudo-header (created) for rsa-sha256' unless signature_algorithm == 'hs2019'
raise SignatureVerificationError, 'Pseudo-header (created) used but corresponding argument missing' if signature_params['created'].blank?

"(created): #{signature_params['created']}"
elsif signed_header == '(expires)'
when '(expires)'
raise SignatureVerificationError, 'Invalid pseudo-header (expires) for rsa-sha256' unless signature_algorithm == 'hs2019'
raise SignatureVerificationError, 'Pseudo-header (expires) used but corresponding argument missing' if signature_params['expires'].blank?

Expand Down

0 comments on commit d5a185d

Please sign in to comment.