forked from likexian/whois-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror_test.go
111 lines (93 loc) · 3.4 KB
/
error_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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
* Copyright 2014-2021 Li Kexian
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Go module for domain whois information parsing
* https://www.likexian.com/
*/
package whoisparser
import (
"testing"
"github.com/likexian/gokit/assert"
)
func TestAsisDomainNotFound(t *testing.T) {
// iamnotexistsdomain.CN
data := `No matching record.`
assert.True(t, isDomainNotFound(data))
// iamnotexistsdomain.com
data = `No match for "IAMNOTEXISTSDOMAIN.COM".
>>> Last update of whois database: 2021-01-15T11:26:46Z <<<`
assert.True(t, isDomainNotFound(data))
// likexian.com
data = `Domain Name: LIKEXIAN.COM
Registry Domain ID: 1665843940_DOMAIN_COM-VRSN`
assert.False(t, isDomainNotFound(data))
}
func TestAsisReservedDomain(t *testing.T) {
// gov.cn
data := `the Domain Name you apply can not be registered online. Please consult your Domain Name registrar`
assert.True(t, isReservedDomain(data))
// good.download
data = `Reserved Domain Name
URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/`
assert.True(t, isReservedDomain(data))
// likexian.com
data = `Domain Name: LIKEXIAN.COM
Registry Domain ID: 1665843940_DOMAIN_COM-VRSN`
assert.False(t, isReservedDomain(data))
}
func TestAsisPremiumDomain(t *testing.T) {
// good.games
data := `This platinum domain is available for purchase.
If you would like to make an offer, please contact platinums@donuts.email.
This name is reserved by the Registry in accordance with ICANN Policy.`
assert.True(t, isPremiumDomain(data))
// cool.guru
data = `Domain not found.
This premium domain is available for purchase.
If you would like to make an offer, please contact platinums@donuts.email.`
assert.True(t, isPremiumDomain(data))
// likexian.com
data = `Domain Name: LIKEXIAN.COM
Registry Domain ID: 1665843940_DOMAIN_COM-VRSN`
assert.False(t, isPremiumDomain(data))
}
func TestAsisBlockedDomain(t *testing.T) {
// google.chat
data := `The registration of this domain is restricted,
as it is protected by the Donuts DPML Brand Protection policy.
Additional information can be found at https://donuts.domains/what-we-do/brand-protection.`
assert.True(t, isBlockedDomain(data))
// google.lol
data = `This name is not available for registration:
This name subscribes to the Uni EPS+ product`
assert.True(t, isBlockedDomain(data))
// paypal.sex
data = `This name is not available for registration:
This name subscribes to the AdultBlock product`
assert.True(t, isBlockedDomain(data))
// likexian.com
data = `Domain Name: LIKEXIAN.COM
Registry Domain ID: 1665843940_DOMAIN_COM-VRSN`
assert.False(t, isBlockedDomain(data))
}
func TestAsisLimitExceeded(t *testing.T) {
// xxx.org
data := `WHOIS LIMIT EXCEEDED - SEE WWW.PIR.ORG/WHOIS FOR DETAILS`
assert.True(t, isLimitExceeded(data))
// likexian.com
data = `Domain Name: LIKEXIAN.COM
Registry Domain ID: 1665843940_DOMAIN_COM-VRSN`
assert.False(t, isLimitExceeded(data))
}