Skip to content
This repository was archived by the owner on Feb 3, 2024. It is now read-only.

Commit 1e87df8

Browse files
author
MooCow
authored
Merge pull request #236 from maarten-boot/master
create a test environment with static test data
2 parents 38fb737 + ae3861c commit 1e87df8

File tree

14 files changed

+332
-36
lines changed

14 files changed

+332
-36
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,4 @@ out
6969
reformat-code.sh
7070
t1.py
7171
typescript
72+
test.out

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ Raise an issue https://github.com/DannyCork/python-whois/issues/new
6565
2022-11-04: maarten_boot
6666
* add support for Iana example.com, example.net
6767

68+
2022-11-07: maarten_boot
69+
* add testing against static known data in dir: ./testdata/<domain>/output
70+
* test.sh will test all domains in testdata without actually calling whois, the input data is instead read from testdata/<domain>/input
71+
6872
## Support
6973
* Python 3.x is supported.
7074
* Python 2.x IS NOT supported.

test.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#! /usr/bin/bash
2+
3+
# signal whois module that we are testing, this reads data from testdata/<domain>/in
4+
export TEST_WHOIS_PYTHON="1"
5+
6+
TestDataDir="./testdata"
7+
8+
get_testdomains()
9+
{
10+
ls "$TestDataDir" |
11+
grep -v ".sh"
12+
}
13+
14+
testOneDomain()
15+
{
16+
domain="$1"
17+
[ ! -d "$TestDataDir/$domain" ] && return
18+
19+
echo "testing: $domain"
20+
./test2.py -d "$domain" >"$TestDataDir/$domain/test.out"
21+
22+
diff "$TestDataDir/$domain/output" "$TestDataDir/$domain/test.out" | tee "$TestDataDir/$domain/out"
23+
}
24+
25+
main()
26+
{
27+
get_testdomains |
28+
while read line
29+
do
30+
testOneDomain $(basename $line)
31+
done
32+
}
33+
34+
main

testdata/example.com/input

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[Querying whois.verisign-grs.com]
2+
[Redirected to whois.iana.org]
3+
[Querying whois.iana.org]
4+
[whois.iana.org]
5+
% IANA WHOIS server
6+
% for more information on IANA, visit http://www.iana.org
7+
% This query returned 1 object
8+
9+
domain: EXAMPLE.COM
10+
11+
organisation: Internet Assigned Numbers Authority
12+
13+
created: 1992-01-01
14+
source: IANA
15+

testdata/example.com/output

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## ===== TEST DOMAINS
2+
3+
test domain: <<<<<<<<<< example.com >>>>>>>>>>>>>>>>>>>>
4+
name str 'example.com'
5+
tld str 'com'
6+
registrar str 'Internet Assigned Numbers Authority'
7+
registrant_country str ''
8+
creation_date datetime.datetime 1992-01-01 00:00:00
9+
expiration_date NoneType None
10+
last_updated NoneType None
11+
status str ''
12+
statuses list ['']
13+
dnssec bool False
14+
name_servers list []
15+
registrant str ''

testdata/example.net/input

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[Querying whois.verisign-grs.com]
2+
[Redirected to whois.iana.org]
3+
[Querying whois.iana.org]
4+
[whois.iana.org]
5+
% IANA WHOIS server
6+
% for more information on IANA, visit http://www.iana.org
7+
% This query returned 1 object
8+
9+
domain: EXAMPLE.NET
10+
11+
organisation: Internet Assigned Numbers Authority
12+
13+
created: 1992-01-01
14+
source: IANA
15+

testdata/example.net/output

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## ===== TEST DOMAINS
2+
3+
test domain: <<<<<<<<<< example.net >>>>>>>>>>>>>>>>>>>>
4+
name str 'example.net'
5+
tld str 'net'
6+
registrar str 'Internet Assigned Numbers Authority'
7+
registrant_country str ''
8+
creation_date datetime.datetime 1992-01-01 00:00:00
9+
expiration_date NoneType None
10+
last_updated NoneType None
11+
status str ''
12+
statuses list ['']
13+
dnssec bool False
14+
name_servers list []
15+
registrant str ''

testdata/example.org/input

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
[Querying whois.pir.org]
2+
[whois.pir.org]
3+
Domain Name: example.org
4+
Registry Domain ID: 13a1800564ae4cf589c9f5723a630958-LROR
5+
Registrar WHOIS Server:
6+
Registrar URL:
7+
Updated Date: 2022-10-14T04:00:28Z
8+
Creation Date: 1995-08-31T04:00:00Z
9+
Registry Expiry Date: 2023-08-30T04:00:00Z
10+
Registrar: ICANN
11+
Registrar IANA ID: 376
12+
Registrar Abuse Contact Email:
13+
Registrar Abuse Contact Phone:
14+
Domain Status: serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited
15+
Domain Status: serverRenewProhibited https://icann.org/epp#serverRenewProhibited
16+
Domain Status: serverTransferProhibited https://icann.org/epp#serverTransferProhibited
17+
Domain Status: serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited
18+
Registry Registrant ID: REDACTED FOR PRIVACY
19+
Registrant Name: REDACTED FOR PRIVACY
20+
Registrant Organization: ICANN
21+
Registrant Street: REDACTED FOR PRIVACY
22+
Registrant City: REDACTED FOR PRIVACY
23+
Registrant State/Province: CA
24+
Registrant Postal Code: REDACTED FOR PRIVACY
25+
Registrant Country: US
26+
Registrant Phone: REDACTED FOR PRIVACY
27+
Registrant Phone Ext: REDACTED FOR PRIVACY
28+
Registrant Fax: REDACTED FOR PRIVACY
29+
Registrant Fax Ext: REDACTED FOR PRIVACY
30+
Registrant Email: Please query the RDDS service of the Registrar of Record identified in this output for information on how to contact the Registrant, Admin, or Tech contact of the queried domain name.
31+
Registry Admin ID: REDACTED FOR PRIVACY
32+
Admin Name: REDACTED FOR PRIVACY
33+
Admin Organization: REDACTED FOR PRIVACY
34+
Admin Street: REDACTED FOR PRIVACY
35+
Admin City: REDACTED FOR PRIVACY
36+
Admin State/Province: REDACTED FOR PRIVACY
37+
Admin Postal Code: REDACTED FOR PRIVACY
38+
Admin Country: REDACTED FOR PRIVACY
39+
Admin Phone: REDACTED FOR PRIVACY
40+
Admin Phone Ext: REDACTED FOR PRIVACY
41+
Admin Fax: REDACTED FOR PRIVACY
42+
Admin Fax Ext: REDACTED FOR PRIVACY
43+
Admin Email: Please query the RDDS service of the Registrar of Record identified in this output for information on how to contact the Registrant, Admin, or Tech contact of the queried domain name.
44+
Registry Tech ID: REDACTED FOR PRIVACY
45+
Tech Name: REDACTED FOR PRIVACY
46+
Tech Organization: REDACTED FOR PRIVACY
47+
Tech Street: REDACTED FOR PRIVACY
48+
Tech City: REDACTED FOR PRIVACY
49+
Tech State/Province: REDACTED FOR PRIVACY
50+
Tech Postal Code: REDACTED FOR PRIVACY
51+
Tech Country: REDACTED FOR PRIVACY
52+
Tech Phone: REDACTED FOR PRIVACY
53+
Tech Phone Ext: REDACTED FOR PRIVACY
54+
Tech Fax: REDACTED FOR PRIVACY
55+
Tech Fax Ext: REDACTED FOR PRIVACY
56+
Tech Email: Please query the RDDS service of the Registrar of Record identified in this output for information on how to contact the Registrant, Admin, or Tech contact of the queried domain name.
57+
Name Server: a.iana-servers.net
58+
Name Server: b.iana-servers.net
59+
DNSSEC: signedDelegation
60+
URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/
61+
>>> Last update of WHOIS database: 2022-11-07T09:27:18Z <<<
62+
63+
For more information on Whois status codes, please visit https://icann.org/epp
64+
65+
Terms of Use: Access to Public Interest Registry WHOIS information is provided to assist persons in determining the contents of a domain name registration record in the Public Interest Registry registry database. The data in this record is provided by Public Interest Registry for informational purposes only, and Public Interest Registry does not guarantee its accuracy. This service is intended only for query-based access. You agree that you will use this data only for lawful purposes and that, under no circumstances will you use this data to (a) allow, enable, or otherwise support the transmission by e-mail, telephone, or facsimile of mass unsolicited, commercial advertising or solicitations to entities other than the data recipient's own existing customers; or (b) enable high volume, automated, electronic processes that send queries or data to the systems of Registry Operator, a Registrar, or Donuts except as reasonably necessary to register domain names or modify existing registrations. All rights reserved. Public Interest Registry reserves the right to modify these terms at any time. By submitting this query, you agree to abide by this policy. The Registrar of Record identified in this output may have an RDDS service that can be queried for additional information on how to contact the Registrant, Admin, or Tech contact of the queried domain name.

testdata/example.org/output

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## ===== TEST DOMAINS
2+
3+
test domain: <<<<<<<<<< example.org >>>>>>>>>>>>>>>>>>>>
4+
name str 'example.org'
5+
tld str 'org'
6+
registrar str 'ICANN'
7+
registrant_country str 'US'
8+
creation_date datetime.datetime 1995-08-31 04:00:00
9+
expiration_date datetime.datetime 2023-08-30 04:00:00
10+
last_updated NoneType None
11+
status str 'serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited'
12+
statuses list ['serverDeleteProhibited https://icann.org/epp#serverDeleteProhibited', 'serverRenewProhibited https://icann.org/epp#serverRenewProhibited', 'serverTransferProhibited https://icann.org/epp#serverTransferProhibited', 'serverUpdateProhibited https://icann.org/epp#serverUpdateProhibited']
13+
dnssec bool True
14+
name_servers list ['a.iana-servers.net', 'b.iana-servers.net']
15+
registrant str 'ICANN'

testdata/make_testdata.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#! /usr/bin/bash
2+
3+
DOMAINS=(
4+
example.net
5+
example.com
6+
example.org
7+
meta.co.uk
8+
)
9+
10+
for str in ${DOMAINS[@]}
11+
do
12+
echo "$str"
13+
14+
# create one dir for each domain we will test
15+
mkdir -p "$str"
16+
17+
# dump the raw whois data as in
18+
whois "$str" | tee "./$str/input"
19+
20+
# dump the expected output as out
21+
../test2.py -d "$str" | tee "./$str/output"
22+
done

0 commit comments

Comments
 (0)