-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathparser_th_test.go
60 lines (49 loc) · 2.23 KB
/
parser_th_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
package whoisparser
import (
"github.com/stretchr/testify/assert"
"io/ioutil"
"testing"
)
func TestParserTh(t *testing.T) {
assertParamsMap := AssertParamsMap{
"Registrar": {
{TargetField: "DomainName", ExpectedResult: "GOOGLE.CO.TH", AssertType: AssertTypeEqual},
{TargetField: "RegistrarName", ExpectedResult: "T.H.NIC Co., Ltd.", AssertType: AssertTypeEqual},
{TargetField: "NameServers", ExpectedResult: "NS3.GOOGLE.COM", AssertType: AssertTypeContains},
{TargetField: "DomainDNSSEC", ExpectedResult: "unsigned", AssertType: AssertTypeEqual},
{TargetField: "DomainStatus", ExpectedResult: "ACTIVE", AssertType: AssertTypeEqual},
{TargetField: "UpdatedDate", ExpectedResult: "16 Sep 2019", AssertType: AssertTypeEqual},
{TargetField: "CreatedDate", ExpectedResult: "08 Oct 2004", AssertType: AssertTypeEqual},
{TargetField: "ExpirationDate", ExpectedResult: "07 Oct 2020", AssertType: AssertTypeEqual},
},
"Registrant": {
{TargetField: "Organization", ExpectedResult: "Google Inc.", AssertType: AssertTypeEqual},
{TargetField: "Country", ExpectedResult: "US", AssertType: AssertTypeEqual},
{TargetField: "Street", ExpectedResult: "Personal Information*", AssertType: AssertTypeEqual},
},
"Tech": {
{TargetField: "Organization", ExpectedResult: "Personal Information*", AssertType: AssertTypeEqual},
{TargetField: "Street", ExpectedResult: "Personal Information*", AssertType: AssertTypeEqual},
{TargetField: "Country", ExpectedResult: "US", AssertType: AssertTypeEqual},
},
}
testDataFilepath := "test_data/whois_th/google.co.th.txt"
parserName := ".th parser"
runParserAssertions(t, thParser, parserName, testDataFilepath, assertParamsMap)
}
func TestParserThNoSuchDomainErr(t *testing.T) {
var fileBytes []byte
var err error
var text string
var whoisRecord *Record
fileBytes, err = ioutil.ReadFile("test_data/whois_th/no_such_domain.txt")
assert.NoError(t, err, "failed to open file with test data")
text = string(fileBytes)
whoisRecord = thParser.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)
}