-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow Applebot to masquerade as Googlebot [closes #6]
- Loading branch information
Showing
3 changed files
with
31 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'minitest/autorun' | ||
require 'legitbot' | ||
|
||
class AppleAsGoogleTest < Minitest::Test | ||
def test_valid_ip | ||
ip = "17.58.98.60" | ||
match = Legitbot::Apple_as_Google.new(ip) | ||
assert match.valid?, msg: "#{ip} is a valid Applebot IP" | ||
end | ||
|
||
def test_invalid_ip | ||
ip = "127.0.0.1" | ||
match = Legitbot::Apple_as_Google.new(ip) | ||
assert match.fake?, msg: "#{ip} is a fake Applebot IP" | ||
end | ||
|
||
def test_user_agent | ||
bot = Legitbot.bot("Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)", "17.58.98.60") | ||
assert_equal :apple_as_google, bot.detected_as | ||
assert bot.valid?, msg: "A valid Applebot User-agent and IP" | ||
end | ||
end |