You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

34 lines
1.0 KiB

  1. // Copyright 2013 The Go Authors. All rights reserved.
  2. //
  3. // Use of this source code is governed by a BSD-style
  4. // license that can be found in the LICENSE file or at
  5. // https://developers.google.com/open-source/licenses/bsd.
  6. package main
  7. import (
  8. "net/http"
  9. "testing"
  10. )
  11. var robotTests = []string{
  12. "Mozilla/5.0 (compatible; TweetedTimes Bot/1.0; +http://tweetedtimes.com)",
  13. "Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)",
  14. "Mozilla/5.0 (compatible; MJ12bot/v1.4.3; http://www.majestic12.co.uk/bot.php?+)",
  15. "Go 1.1 package http",
  16. "Java/1.7.0_25 0.003 0.003",
  17. "Python-urllib/2.6",
  18. "Mozilla/5.0 (compatible; archive.org_bot +http://www.archive.org/details/archive.org_bot)",
  19. "Mozilla/5.0 (compatible; Ezooms/1.0; ezooms.bot@gmail.com)",
  20. "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",
  21. }
  22. func TestRobots(t *testing.T) {
  23. for _, tt := range robotTests {
  24. req := http.Request{Header: http.Header{"User-Agent": {tt}}}
  25. if !isRobot(&req) {
  26. t.Errorf("%s not a robot", tt)
  27. }
  28. }
  29. }