Sha256: ab465d163f2f43b5ad2ffe6c3a23ee4dadf443e4cd587b05940300a0d448d23c

Contents?: true

Size: 993 Bytes

Versions: 13

Compression:

Stored size: 993 Bytes

Contents

# frozen_string_literal: true

require 'minitest/autorun'
require 'legitbot'

class AlexaTest < Minitest::Test
  def test_malicious_ip
    ip = '149.210.164.47'
    match = Legitbot::Alexa.new ip
    assert !match.valid?, msg: "#{ip} is not a real Alexa IP"
  end

  def test_valid_ip
    ip = '52.86.176.3'
    match = Legitbot::Alexa.new ip
    assert match.valid?, msg: "#{ip} is a valid Alexa IP"
  end

  def test_malicious_ua
    bot = Legitbot.bot(
      'Mozilla/5.0 (compatible; Alexabot/1.0; +http://www.alexa.com/help/certifyscan; certifyscan@alexa.com)',
      '149.210.164.47'
    )
    assert bot, msg: 'Alexa detected from User-Agent'
    assert !bot.valid?, msg: 'Not a valid Alexa'
  end

  def test_valid_ua
    bot = Legitbot.bot(
      'Mozilla/5.0 (compatible; Alexabot/1.0; +http://www.alexa.com/help/certifyscan; certifyscan@alexa.com)',
      '52.86.176.3'
    )
    assert bot, msg: 'Alexa detected from User-Agent'
    assert bot.valid?, msg: 'Valid Alexa'
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
legitbot-1.5.1 test/alexa_test.rb
legitbot-1.5.0 test/alexa_test.rb
legitbot-1.4.5 test/alexa_test.rb
legitbot-1.4.4 test/alexa_test.rb
legitbot-1.4.3 test/alexa_test.rb
legitbot-1.4.2 test/alexa_test.rb
legitbot-1.4.1 test/alexa_test.rb
legitbot-1.4.0 test/alexa_test.rb
legitbot-1.3.0 test/alexa_test.rb
legitbot-1.2.0 test/alexa_test.rb
legitbot-1.1.1 test/alexa_test.rb
legitbot-1.1.0 test/alexa_test.rb
legitbot-1.0.2 test/alexa_test.rb