tests: remove SKIP_CLOUDFLARE_CHECK env variable.
This was a hack to deal with the Cloudflare check sometimes being slow or timing out during tests. The call to https://api.cloudflare.com/client/v4/ips could hang if there were IPv6 connectivity problems. If this happens, make sure that IPv6 is configured properly and that `curl -v --http1.1 -6 https://api.cloudflare.com/client/v4/ips` works.
This commit is contained in:
@@ -92,8 +92,6 @@ module Downloads
|
|||||||
end
|
end
|
||||||
|
|
||||||
def is_cloudflare?(url)
|
def is_cloudflare?(url)
|
||||||
return false if ENV["SKIP_CLOUDFLARE_CHECK"]
|
|
||||||
|
|
||||||
ip_addr = IPAddr.new(Resolv.getaddress(url.hostname))
|
ip_addr = IPAddr.new(Resolv.getaddress(url.hostname))
|
||||||
CloudflareService.new.ips.any? { |subnet| subnet.include?(ip_addr) }
|
CloudflareService.new.ips.any? { |subnet| subnet.include?(ip_addr) }
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -95,8 +95,6 @@ CurrentUser.user = User.admins.first
|
|||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
|
|
||||||
if Upload.count == 0
|
if Upload.count == 0
|
||||||
ENV["SKIP_CLOUDFLARE_CHECK"] = "true"
|
|
||||||
|
|
||||||
puts "Creating uploads"
|
puts "Creating uploads"
|
||||||
1.upto(50) do |i|
|
1.upto(50) do |i|
|
||||||
color1 = rand(4096).to_s(16)
|
color1 = rand(4096).to_s(16)
|
||||||
|
|||||||
@@ -4,15 +4,10 @@ module Downloads
|
|||||||
class FileTest < ActiveSupport::TestCase
|
class FileTest < ActiveSupport::TestCase
|
||||||
context "A post download" do
|
context "A post download" do
|
||||||
setup do
|
setup do
|
||||||
ENV["SKIP_CLOUDFLARE_CHECK"] = "1"
|
|
||||||
@source = "http://www.google.com/intl/en_ALL/images/logo.gif"
|
@source = "http://www.google.com/intl/en_ALL/images/logo.gif"
|
||||||
@download = Downloads::File.new(@source)
|
@download = Downloads::File.new(@source)
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
|
||||||
ENV["SKIP_CLOUDFLARE_CHECK"] = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
context "for a banned IP" do
|
context "for a banned IP" do
|
||||||
setup do
|
setup do
|
||||||
Resolv.expects(:getaddress).returns("127.0.0.1").at_least_once
|
Resolv.expects(:getaddress).returns("127.0.0.1").at_least_once
|
||||||
|
|||||||
Reference in New Issue
Block a user