Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.7)
rubocop (1.89.0)
json (~> 2.3)
rubocop (1.90.0)
json (>= 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (>= 1.10)
Expand Down
9 changes: 3 additions & 6 deletions lib/minfraud/validates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,12 @@ def validate_ip(field, value)
raise InvalidInputError, "The #{field} value is not valid. It must be an individual IP address."
end

# rubocop:disable Style/RescueStandardError
# rubocop:disable-next Style/RescueStandardError
begin
IPAddr.new(s)
rescue
raise InvalidInputError, "The #{field} value is not valid. It must be an IPv4 or IPv6 address."
end
# rubocop:enable Style/RescueStandardError

nil
end
Expand Down Expand Up @@ -279,13 +278,12 @@ def validate_email(field, value)
def validate_rfc3339(field, value)
return if !value

# rubocop:disable Style/RescueStandardError
# rubocop:disable-next Style/RescueStandardError
begin
DateTime.rfc3339(value)
rescue
raise InvalidInputError, "The #{field} value is not valid. It must be in the RFC 3339 date-time format."
end
# rubocop:enable Style/RescueStandardError

nil
end
Expand Down Expand Up @@ -321,7 +319,7 @@ def validate_uri(field, value)
raise InvalidInputError, "The #{field} value is not valid. It must not exceed 1024 characters."
end

# rubocop:disable Style/RescueStandardError
# rubocop:disable-next Style/RescueStandardError
begin
u = URI(value)
if !u.scheme
Expand All @@ -330,7 +328,6 @@ def validate_uri(field, value)
rescue
raise InvalidInputError, "The #{field} value is not valid. It must be an absolute URI."
end
# rubocop:enable Style/RescueStandardError
end
# rubocop:enable Metrics/ModuleLength
end
Expand Down
4 changes: 2 additions & 2 deletions spec/http_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

it 'makes an HTTP request resulting in an HTTP 401' do
stub_request(:post, /score/).with(
body: '{"device":{"ip_address":"1.2.3.4"}}',
body: '{"device":{"ip_address":"1.2.3.4"}}',
).to_return(
body: '{"code":"ACCOUNT_ID_REQUIRED","error":"You have not supplied a MaxMind account ID in the Authorization header."}',
headers: {
Expand Down Expand Up @@ -91,7 +91,7 @@

it 'makes an HTTP request resulting in an HTTP 401' do
stub_request(:post, /report/).with(
body: '{"ip_address":"1.2.3.4"}',
body: '{"ip_address":"1.2.3.4"}',
).to_return(
body: '{"code":"ACCOUNT_ID_REQUIRED","error":"You have not supplied a MaxMind account ID in the Authorization header."}',
headers: {
Expand Down
Loading