2024-02-25 12:15:55 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-11-25 11:27:38 -05:00
|
|
|
require "test_helper"
|
2017-11-22 16:19:30 -05:00
|
|
|
|
|
|
|
class CloudflareServiceTest < ActiveSupport::TestCase
|
2018-11-11 21:18:21 -05:00
|
|
|
context "#ips" do
|
|
|
|
should "work" do
|
2022-11-25 11:27:38 -05:00
|
|
|
ipv4 = "173.245.48.0/20"
|
|
|
|
ipv6 = "2400:cb00::/32"
|
|
|
|
dummy_response = {
|
|
|
|
result: {
|
|
|
|
ipv4_cidrs: [ipv4],
|
|
|
|
ipv6_cidrs: [ipv6],
|
|
|
|
},
|
|
|
|
}
|
2024-04-26 09:57:56 -04:00
|
|
|
stub_request(:get, CloudflareService.endpoint).to_return(status: 200, body: dummy_response.to_json)
|
2022-11-25 11:27:38 -05:00
|
|
|
assert_equal([IPAddr.new(ipv4), IPAddr.new(ipv6)], CloudflareService.ips)
|
2018-11-11 21:18:21 -05:00
|
|
|
end
|
|
|
|
end
|
2017-11-22 16:19:30 -05:00
|
|
|
end
|