Sha256: 7b8f0fa2701fa57070dba4ee49f65e01faca715c2d8ecfa56ff38de0c08991f7

Contents?: true

Size: 1.2 KB

Versions: 8

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

require_relative 'test_helper'

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

  def test_malicious_ip
    ip = '149.210.164.47'
    match = Legitbot::BLEXBot.new ip

    refute_predicate match, :valid?
  end

  def test_valid_ip
    ip = '65.21.113.197'
    match = Legitbot::BLEXBot.new ip

    assert_predicate match, :valid?
  end

  def test_malicious_ua
    bot = Legitbot.bot(
      'Mozilla/5.0 (compatible; BLEXBot/1.0; +http://webmeup-crawler.com/)',
      '149.210.164.47'
    )

    assert bot
    refute_predicate bot, :valid?
  end

  def test_valid_ua
    bot = Legitbot.bot(
      'Mozilla/5.0 (compatible; BLEXBot/1.0; +http://webmeup-crawler.com/)',
      '65.21.113.197'
    )

    assert bot
    assert_predicate bot, :valid?
  end

  def test_valid_name
    bot = Legitbot.bot(
      'Mozilla/5.0 (compatible; BLEXBot/1.0; +http://webmeup-crawler.com/)',
      '65.21.113.197'
    )

    assert_equal :blexbot, bot.detected_as
  end

  def test_fake_name
    bot = Legitbot.bot(
      'Mozilla/5.0 (compatible; BLEXBot/1.0; +http://webmeup-crawler.com/)',
      '81.1.172.108'
    )

    assert_equal :blexbot, bot.detected_as
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
legitbot-1.11.7 test/blexbot_test.rb
legitbot-1.11.6 test/blexbot_test.rb
legitbot-1.11.5 test/blexbot_test.rb
legitbot-1.11.4 test/blexbot_test.rb
legitbot-1.11.3 test/blexbot_test.rb
legitbot-1.11.2 test/blexbot_test.rb
legitbot-1.11.1 test/blexbot_test.rb
legitbot-1.11.0 test/blexbot_test.rb