frontend: resolve asn in dns/whois/fail order & fix tests

This commit is contained in:
Lan Tian
2021-07-31 16:56:39 +08:00
committed by Yuhui Xu
parent 2e0cb131ca
commit bee26f421c
4 changed files with 60 additions and 18 deletions

View File

@@ -5,8 +5,18 @@ import (
"testing"
)
func TestGetASNRepresentation(t *testing.T) {
func TestGetASNRepresentationDNS(t *testing.T) {
setting.dnsInterface = "asn.cymru.com"
setting.whoisServer = ""
result := getASNRepresentation("6939")
if !strings.Contains(result, "HURRICANE") {
t.Errorf("Lookup AS6939 failed, got %s", result)
}
}
func TestGetASNRepresentationWhois(t *testing.T) {
setting.dnsInterface = ""
setting.whoisServer = "whois.arin.net"
result := getASNRepresentation("6939")
if !strings.Contains(result, "HURRICANE") {
t.Errorf("Lookup AS6939 failed, got %s", result)
@@ -15,6 +25,7 @@ func TestGetASNRepresentation(t *testing.T) {
func TestGetASNRepresentationFallback(t *testing.T) {
setting.dnsInterface = ""
setting.whoisServer = ""
result := getASNRepresentation("6939")
if result != "AS6939" {
t.Errorf("Lookup AS6939 failed, got %s", result)