-
Notifications
You must be signed in to change notification settings - Fork 3
/
parser_kz_test.go
64 lines (53 loc) · 2.59 KB
/
parser_kz_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package whoisparser
import (
"github.com/stretchr/testify/assert"
"io/ioutil"
"testing"
)
func TestParserKz(t *testing.T) {
assertParamsMap := AssertParamsMap{
"Registrar": {
{TargetField: "DomainName", ExpectedResult: "google.kz", AssertType: AssertTypeEqual},
{TargetField: "NameServers", ExpectedResult: "ns1.google.com", AssertType: AssertTypeContains},
{TargetField: "CreatedDate", ExpectedResult: "1999-06-07 13:01:43 (GMT+0:00)", AssertType: AssertTypeContains},
{TargetField: "DomainStatus", ExpectedResult: "ok - Normal state.", AssertType: AssertTypeContains},
{TargetField: "UpdatedDate", ExpectedResult: "2012-11-28 03:16:59 (GMT+0:00)", AssertType: AssertTypeContains},
{TargetField: "RegistrarName", ExpectedResult: "KAZNIC", AssertType: AssertTypeContains},
},
"Registrant": {
{TargetField: "Name", ExpectedResult: "Google Inc.", AssertType: AssertTypeEqual},
{TargetField: "Organization", ExpectedResult: "Google Inc.", AssertType: AssertTypeEqual},
{TargetField: "Street", ExpectedResult: "2400 E. Bayshore Pkwy", AssertType: AssertTypeEqual},
{TargetField: "City", ExpectedResult: "Mountain View", AssertType: AssertTypeEqual},
{TargetField: "Province", ExpectedResult: "CA", AssertType: AssertTypeEqual},
{TargetField: "PostalCode", ExpectedResult: "94043", AssertType: AssertTypeEqual},
{TargetField: "Country", ExpectedResult: "US", AssertType: AssertTypeEqual},
},
"Admin": {
{TargetField: "ID", ExpectedResult: "C000000197393-KZ", AssertType: AssertTypeEqual},
{TargetField: "Name", ExpectedResult: "DNS Admin", AssertType: AssertTypeEqual},
{TargetField: "Phone", ExpectedResult: "+1.6502530000 ", AssertType: AssertTypeEqual},
{TargetField: "Fax", ExpectedResult: "+1.6506188571 ", AssertType: AssertTypeEqual},
{TargetField: "Email", ExpectedResult: "[email protected]", AssertType: AssertTypeEqual},
},
}
testDataFilepath := "test_data/whois_kz/google.kz.txt"
parserName := ".kz parser"
runParserAssertions(t, kzParser, parserName, testDataFilepath, assertParamsMap)
}
func TestParserKzNoSuchDomainErr(t *testing.T) {
var fileBytes []byte
var err error
var text string
var whoisRecord *Record
fileBytes, err = ioutil.ReadFile("test_data/whois_kz/no_such_domain.txt")
assert.NoError(t, err, "failed to open file with test data")
text = string(fileBytes)
whoisRecord = kzParser.Parse(text)
assert.True(t, whoisRecord.ErrCode == ErrCodeNoSuchDomain)
assert.Nil(t, whoisRecord.Registrar)
assert.Nil(t, whoisRecord.Registrant)
assert.Nil(t, whoisRecord.Bill)
assert.Nil(t, whoisRecord.Admin)
assert.Nil(t, whoisRecord.Tech)
}