Sha256: 8a6bc775a07180bbbc76de984a7c5e4fb89a750e6462a8da929352babbe15358

Contents?: true

Size: 840 Bytes

Versions: 1

Compression:

Stored size: 840 Bytes

Contents

# frozen_string_literal: true

require 'minitest/autorun'
require 'minitest/hooks/test'
require 'lib/dns_server_mock'
require 'legitbot'

class AhrefsTest < Minitest::Test
  include Minitest::Hooks
  include DnsServerMock

  def test_malicious_ip
    ip = '149.210.164.47'
    match = Legitbot::Ahrefs.new ip
    refute match.valid?
  end

  def test_valid_ip
    ip = '54.36.148.0'
    match = Legitbot::Ahrefs.new ip
    assert match.valid?
  end

  def test_malicious_ua
    bot = Legitbot.bot(
      'Mozilla/5.0 (compatible; AhrefsBot/6.1; +http://ahrefs.com/robot/)',
      '149.210.164.47'
    )
    assert bot
    refute bot.valid?
  end

  def test_valid_ua
    bot = Legitbot.bot(
      'Mozilla/5.0 (compatible; AhrefsBot/6.1; +http://ahrefs.com/robot/)',
      '54.36.148.0'
    )
    assert bot
    assert bot.valid?
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
legitbot-1.6.0 test/ahrefs_test.rb