-
Notifications
You must be signed in to change notification settings - Fork 20
/
helper_test.go
141 lines (110 loc) · 3.54 KB
/
helper_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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package ripego
import (
"testing"
)
const (
WHOIS_DATA_RPSL = `% This is the RIPE Database query service.
% The objects are in RPSL format.
%
% The RIPE Database is subject to Terms and Conditions.
% See http://www.ripe.net/db/support/db-terms-conditions.pdf
% Note: this output has been filtered.
% To receive output for a database update, use the "-B" flag.
% Information related to '178.18.192.0 - 178.18.207.255'
% Abuse contact for '178.18.192.0 - 178.18.207.255' is '[email protected]'
inetnum: 178.18.192.0 - 178.18.207.255
netname: TR-VARGONEN-20100423
descr: Vargonen Teknoloji ve Bilisim Sanayi Ticaret Anonim Sirketi
country: TR
org: ORG-VTIv1-RIPE
admin-c: VT5050-RIPE
tech-c: VT5050-RIPE
status: ALLOCATED PA
mnt-by: RIPE-NCC-HM-MNT
mnt-lower: MNT-VRGN
mnt-routes: MNT-VRGN
created: 2010-04-23T15:52:35Z
last-modified: 2014-12-11T10:31:35Z
source: RIPE # Filtered
organisation: ORG-VTIv1-RIPE
org-name: Vargonen Teknoloji ve Bilisim Sanayi Ticaret Anonim Sirketi
org-type: LIR
address: Vargonen Teknoloji ve Bilisim Sanayi Ticaret Anonim Sirketi
address: Ankara Cad No 81 Bayrakli Tower Kat 19 Bayrakli
address: 35030
address: IZMIR
address: TURKEY
phone: +908506600099
fax-no: +902324570021
abuse-c: AR17405-RIPE
mnt-ref: MNT-VRGN
mnt-ref: RIPE-NCC-HM-MNT
mnt-by: RIPE-NCC-HM-MNT
abuse-mailbox: [email protected]
created: 2010-04-07T13:50:24Z
last-modified: 2015-01-07T21:19:36Z
source: RIPE # Filtered
person: Vargonen LIR Admin
address: Ankara Cad. No:81 Bayrakli Tower
address: Kat:19
address: Bayrakli - Izmir
address: TR
phone: +90 850 660 00 99
abuse-mailbox: [email protected]
fax-no: +90 232 457 00 21
nic-hdl: VT5050-RIPE
created: 2010-04-14T11:24:11Z
last-modified: 2015-01-07T21:13:34Z
source: RIPE # Filtered
mnt-by: MNT-VRGN
% Information related to '178.18.196.0/24AS43391'
route: 178.18.196.0/24
descr: Vargonen Route
origin: AS43391
mnt-by: MNT-VRGN
created: 2014-12-01T23:24:24Z
last-modified: 2015-01-07T21:30:22Z
source: RIPE # Filtered
% This query was served by the RIPE Database Query Service version 1.85.1 (DB-3)`
)
/*
func TestTcpContent(t *testing.T) {
d, err := GetTcpContent("178.18.196.250", "whois.ripe.net")
if err != nil {
t.Fatal(err.Error())
}
if d == "" {
t.Fatal("TCP data obtained")
}
}*/
func TestReadLineValue(t *testing.T) {
line1 := "inetnum: 178.18.192.0 - 178.18.207.255"
va1 := parseRPSLine(line1)
if va1 == "" {
t.Fatal("Value cannot be determined")
}
if va1 != "178.18.192.0 - 178.18.207.255" {
t.Fatalf("not expected data: %s", va1)
}
t.Log(va1)
}
func TestParseData(t *testing.T) {
w := WhoisInfo{}
w.AdminC = parseRPSLValue(WHOIS_DATA_RPSL, "inetnum", "admin-c")
w.Person = WhoisPerson{}
w.Person.Name = parseRPSLValue(WHOIS_DATA_RPSL, "person", "person")
w.Route = WhoisRoute{}
w.Route.Origin = parseRPSLValue(WHOIS_DATA_RPSL, "route", "origin")
if w.AdminC != "VT5050-RIPE" {
t.Fatalf("No expected inetnum data: %s", w.AdminC)
}
t.Logf("inetnum admin-c: ", w.AdminC)
if w.Person.Name != "Vargonen LIR Admin" {
t.Fatalf("No expected person data: %s", w.Person.Name)
}
t.Logf("person person: ", w.Person.Name)
if w.Route.Origin != "AS43391" {
t.Fatalf("No expected route data: %s", w.Route.Origin)
}
t.Logf("route origin: ", w.Route.Origin)
}