tests: Fix the initial selection of a server
[App-Abuser.git] / t / Stub.pm
blobacd8df7da4b5189f7a89332c563a50b4351d8efe
1 package Stub;
2 use strict;
3 use warnings;
4 use utf8;
6 my $examples = {
7 'whois.afrinic.net' => {
8 '192.0.2.3' => <<'OUTPUT',
9 % This is the AfriNIC Whois server.
10 % The AFRINIC whois database is subject to the following terms of Use. See https://afrinic.net/whois/terms
12 % Note: this output has been filtered.
13 % To receive output for a database update, use the "-B" flag.
15 % [whois.apnic.net]
16 % Whois data copyright terms http://www.apnic.net/db/dbcopyright.html
18 % Information related to '192.0.2.0 - 192.0.2.255'
20 % Abuse contact for '192.0.2.0 - 192.0.2.255' is 'bad@example.com'
22 inetnum: 192.0.2.0 - 192.0.2.255
23 netname: X
24 descr: X
25 descr: X
26 admin-c: ROLE-2
27 tech-c: ROLE-2
28 remarks: Email address for spam or abuse complaints: bad@example.com
29 country: X
30 mnt-by: X
31 mnt-lower: X
32 mnt-irt: IRT-2
33 status: X
34 last-modified: X
35 source: APNIC
37 irt: IRT-2
38 address: X
39 address: X
40 e-mail: bad@example.com
41 abuse-mailbox: bad@example.com
42 admin-c: ROLE-2
43 tech-c: ROLE-2
44 auth: # Filtered
45 remarks: X
46 mnt-by: X
47 last-modified: X
48 source: APNIC
50 role: X
51 address: X
52 address: X
53 address: X
54 country: X
55 phone: X
56 fax-no: X
57 e-mail: bad@example.com
58 admin-c: X
59 tech-c: X
60 nic-hdl: ROLE-2
61 mnt-by: X
62 last-modified: X
63 source: APNIC
65 % Information related to '192.0.2.0 - 192.0.2.255'
67 inetnum: 192.0.2.0 - 192.0.2.255
68 netname: X
69 descr: X
70 remarks: Email address for spam or abuse complaints : bad@example.com
71 country: X
72 admin-c: ROLE-3
73 tech-c: RILE-3
74 remarks: This information has been partially mirrored by APNIC from
75 remarks: JPNIC. To obtain more specific information, please use the
76 remarks: JPNIC WHOIS Gateway at
77 remarks: http://www.nic.ad.jp/en/db/whois/en-gateway.html or
78 remarks: whois.nic.ad.jp for WHOIS client. (The WHOIS client
79 remarks: defaults to Japanese output, use the /e switch for English
80 remarks: output)
81 last-modified: X
82 source: JPNIC
84 % This query was served by the APNIC Whois Service version 1.88.15-SNAPSHOT (WHOIS-JP3)
90 OUTPUT
92 'whois.apnic.net' => {
93 '192.0.2.0' => <<'OUTPUT',
94 % [whois.apnic.net]
95 % Whois data copyright terms http://www.apnic.net/db/dbcopyright.html
97 % Information related to '192.0.2.0 - 192.0.2.255'
99 % Abuse contact for '192.0.2.0 - 192.0.2.255' is 'bad@example.com'
101 inetnum: 192.0.2.0 - 192.0.2.255
102 netname: X
103 descr: X
104 descr: X
105 country: X
106 org: ORG-1
107 admin-c: ROLE-1
108 tech-c: ROLE-1
109 abuse-c: ROLE-2
110 status: ASSIGNED PORTABLE
111 mnt-by: X
112 mnt-routes: X
113 mnt-irt: IRT-1
114 last-modified: 1970-01-01T00:00:00Z
115 source: APNIC
117 irt: IRT-1
118 address: X
119 address: X
120 address: X
121 e-mail: bad@example.com
122 abuse-mailbox: bad@example.com
123 admin-c: ROLE-1
124 tech-c: ROLE-1
125 auth: # Filtered
126 remarks: X
127 mnt-by: X
128 last-modified: 1970-01-01T00:00:00Z
129 source: APNIC
131 organisation: ORG-1
132 org-name: X
133 country: X
134 address: X
135 e-mail: bad@example.com
136 mnt-ref: X
137 mnt-by: X
138 last-modified: 1970-01-01T00:00:00Z
139 source: APNIC
141 role: X
142 address: X
143 address: X
144 address: X
145 country: X
146 phone: X
147 e-mail: bad@example.com
148 admin-c: ROLE-1
149 tech-c: ROLE-1
150 nic-hdl: ROLE-2
151 remarks: X
152 abuse-mailbox: good@example.com
153 mnt-by: X
154 last-modified: 1970-01-01T00:00:00Z
155 source: APNIC
157 role: X
158 address: X
159 address: X
160 address: X
161 country: X
162 phone: X
163 fax-no: X
164 e-mail: bad@example.com
165 nic-hdl: ROLE-1
166 tech-c: X
167 admin-c: X
168 mnt-by: X
169 last-modified: 1970-01-01T00:00:00Z
170 source: APNIC
172 % This query was served by the APNIC Whois Service version 1.88.15-SNAPSHOT (WHOIS-UK4)
175 OUTPUT
176 '192.0.2.3' => <<'OUTPUT',
177 % [whois.apnic.net]
178 % Whois data copyright terms http://www.apnic.net/db/dbcopyright.html
180 % Information related to '192.0.2.0 - 192.0.2.255'
182 % Abuse contact for '192.0.2.0 - 192.0.2.255' is 'bad@example.com'
184 inetnum: 192.0.2.0 - 192.0.2.255
185 netname: X
186 descr: X
187 descr: X
188 admin-c: ROLE-2
189 tech-c: ROLE-2
190 remarks: Email address for spam or abuse complaints: bad@example.com
191 country: X
192 mnt-by: X
193 mnt-lower: X
194 mnt-irt: IRT-2
195 status: X
196 last-modified: X
197 source: APNIC
199 irt: IRT-2
200 address: X
201 address: X
202 e-mail: bad@example.com
203 abuse-mailbox: bad@example.com
204 admin-c: ROLE-2
205 tech-c: ROLE-2
206 auth: # Filtered
207 remarks: X
208 mnt-by: X
209 last-modified: X
210 source: APNIC
212 role: X
213 address: X
214 address: X
215 address: X
216 country: X
217 phone: X
218 fax-no: X
219 e-mail: bad@example.com
220 admin-c: X
221 tech-c: X
222 nic-hdl: ROLE-2
223 mnt-by: X
224 last-modified: X
225 source: APNIC
227 % Information related to '192.0.2.0 - 192.0.2.255'
229 inetnum: 192.0.2.0 - 192.0.2.255
230 netname: X
231 descr: X
232 remarks: Email address for spam or abuse complaints : bad@example.com
233 country: X
234 admin-c: ROLE-3
235 tech-c: ROLE-3
236 remarks: This information has been partially mirrored by APNIC from
237 remarks: JPNIC. To obtain more specific information, please use the
238 remarks: JPNIC WHOIS Gateway at
239 remarks: http://www.nic.ad.jp/en/db/whois/en-gateway.html or
240 remarks: whois.nic.ad.jp for WHOIS client. (The WHOIS client
241 remarks: defaults to Japanese output, use the /e switch for English
242 remarks: output)
243 last-modified: X
244 source: JPNIC
246 % This query was served by the APNIC Whois Service version 1.88.15-SNAPSHOT (WHOIS-JP3)
249 OUTPUT
250 '192.0.2.4' => <<'OUTPUT',
251 % [whois.apnic.net]
252 % Whois data copyright terms http://www.apnic.net/db/dbcopyright.html
254 % Information related to '192.0.2.0 - 192.0.2.255'
256 % Abuse contact for '192.0.2.0 - 192.0.2.255' is 'bad@example.com'
258 inetnum: 192.0.2.0 - 192.0.2.255
259 netname: X
260 descr: X
261 country: X
262 tech-c: person-2
263 admin-c: person-3
264 status: X
265 mnt-by: X
266 last-modified: X
267 source: APNIC
269 person: X
270 nic-hdl: PERSON-3
271 e-mail: bad@example.com
272 address: X
273 address: X
274 phone: X
275 fax-no: X
276 country: X
277 mnt-by: X
278 last-modified: X
279 source: APNIC
281 person: X
282 nic-hdl: PERSON-2
283 e-mail: good@example.com
284 address: X
285 address: X
286 phone: X
287 fax-no: X
288 country: X
289 mnt-by: X
290 last-modified: X
291 source: APNIC
293 % Information related to '192.0.2.0/24AS0002'
295 route: 192.0.2.0/24
296 descr: X
297 origin: AS0002
298 mnt-by: X
299 last-modified: X
300 source: APNIC
302 % This query was served by the APNIC Whois Service version 1.88.15-SNAPSHOT (WHOIS-JP3)
305 OUTPUT
306 '192.0.2.7' => <<'OUTPUT',
307 % [whois.apnic.net]
308 % Whois data copyright terms http://www.apnic.net/db/dbcopyright.html
310 % Information related to '192.0.2.0 - 192.0.2.255'
312 % Abuse contact for '192.0.2.0 - 192.0.2.255' is 'bad@example.com'
314 inetnum: 192.0.2.0 - 192.0.2.255
315 netname: X
316 descr: X
317 descr: X
318 country: X
319 admin-c: ROLE-5
320 tech-c: ROLE-5
321 status: X
322 remarks: X
323 mnt-by: X
324 mnt-irt: IRT-JPNIC-JP
325 mnt-lower: X
326 last-modified: X
327 source: APNIC
329 irt: IRT-JPNIC-JP
330 address: X
331 address: X
332 e-mail: bad@example.com
333 abuse-mailbox: bad@example.com
334 admin-c: ROLE-5
335 tech-c: ROLE-5
336 auth: X
337 remarks: X
338 mnt-by: X
339 last-modified: X
340 source: APNIC
342 role: X
343 address: X
344 address: X
345 address: X
346 country: X
347 phone: X
348 fax-no: X
349 e-mail: bad@example.com
350 admin-c: X
351 tech-c: X
352 nic-hdl: ROLE-5
353 mnt-by: X
354 last-modified: X
355 source: APNIC
357 % Information related to '192.0.2.0 - 192.0.2.255'
359 inetnum: 192.0.2.0 - 192.0.2.255
360 netname: X
361 descr: X
362 country: X
363 admin-c: ROLE-6
364 tech-c: ROLE-6
365 remarks: This information has been partially mirrored by APNIC from
366 remarks: JPNIC. To obtain more specific information, please use the
367 remarks: JPNIC WHOIS Gateway at
368 remarks: http://www.nic.ad.jp/en/db/whois/en-gateway.html or
369 remarks: whois.nic.ad.jp for WHOIS client. (The WHOIS client
370 remarks: defaults to Japanese output, use the /e switch for English
371 remarks: output)
372 last-modified: X
373 source: JPNIC
375 % This query was served by the APNIC Whois Service version 1.88.15-SNAPSHOT (WHOIS-UK3)
378 OUTPUT
380 'whois.arin.net' => {
382 'whois.iana.org' => {
383 '0.0.0.0' => <<'OUTPUT',
384 % IANA WHOIS server
385 % for more information on IANA, visit http://www.iana.org
386 % This query returned 1 object
388 inetnum: 0.0.0.0 - 0.255.255.255
389 organisation: IANA - Local Identification
390 status: RESERVED
392 remarks: 0.0.0.0/8 reserved for self-identification [RFC1122],
393 remarks: section 3.2.1.3. Reserved by protocol. For authoritative
394 remarks: registration, seeiana-ipv4-special-registry.
396 changed: 1981-09
397 source: IANA
399 OUTPUT
401 'whois.kisa.or.kr' => {
402 '192.0.2.3' => <<'OUTPUT',
403 query : 192.0.2.3
406 # KOREAN(UTF8)
408 조회하신 IPv4주소는 한국인터넷진흥원으로부터 아래의 관리대행자에게 할당되었으며, 할당 정보는 다음과 같습니다.
410 [ 네트워크 할당 정보 ]
411 IPv4주소 : 192.0.2.0 - 192.0.2.255 (/24)
412 기관명 : X
413 서비스명 : X
414 주소 : X
415 우편번호 : X
416 할당일자 : X
418 이름 : X
419 전화번호 : X
420 전자우편 : bad@example.com
422 조회하신 IPv4주소는 위의 관리대행자로부터 아래의 사용자에게 할당되었으며, 할당 정보는 다음과 같습니다.
423 --------------------------------------------------------------------------------
426 [ 네트워크 할당 정보 ]
427 IPv4주소 : 192.0.2.0 - 192.0.2.127 (/25)
428 기관명 : X
429 네트워크 구분 : X
430 주소 : X
431 우편번호 : X
432 할당내역 등록일 : X
434 이름 : X
435 전화번호 : X
436 전자우편 : good@example.com
439 # ENGLISH
441 KRNIC is not an ISP but a National Internet Registry similar to APNIC.
443 [ Network Information ]
444 IPv4 Address : 192.0.2.0 - 192.0.2.255 (/24)
445 Organization Name : X
446 Service Name : X
447 Address : X
448 Zip Code : X
449 Registration Date : X
451 Name : X
452 Phone : X
453 E-Mail : bad@example.com
455 --------------------------------------------------------------------------------
457 More specific assignment information is as follows.
459 [ Network Information ]
460 IPv4 Address : 192.0.2.0 - 192.0.2.127 (/25)
461 Organization Name : X
462 Network Type : X
463 Address : X
464 Zip Code : X
465 Registration Date : X
467 Name : X
468 Phone : X
469 E-Mail : good@example.com
472 - KISA/KRNIC WHOIS Service -
474 OUTPUT
476 'whois.lacnic.net' => {
477 '192.0.2.6' => <<'OUTPUT',
479 % Copyright (c) Nic.br
480 % The use of the data below is only permitted as described in
481 % full by the terms of use at https://registro.br/termo/en.html ,
482 % being prohibited its distribution, commercialization or
483 % reproduction, in particular, to use it for advertising or
484 % any similar purpose.
485 % 1970-01-01T00:00:00+00:00 - IP: 2001:db8::
487 inetnum: 192.0.2.0/24
488 aut-num: X
489 abuse-c: CONTACT-1
490 owner: X
491 ownerid: X
492 responsible: X
493 country: X
494 owner-c: CONTACT-1
495 tech-c: CONTACT-1
496 inetrev: X
497 nserver: X
498 nsstat: X
499 nslastaa: X
500 nserver: X
501 nsstat: X
502 nslastaa: X
503 created: X
504 changed: X
506 nic-hdl-br: CONTACT-1
507 person: X
508 e-mail: good@example.com
509 country: X
510 created: X
511 changed: X
513 % Security and mail abuse issues should also be addressed to
514 % cert.br, http://www.cert.br/ , respectivelly to bad@example.com
515 % and bad@example.com
517 % whois.registro.br accepts only direct match queries. Types
518 % of queries are: domain (.br), registrant (tax ID), ticket,
519 % provider, CIDR block, IP and ASN.
520 OUTPUT
522 'whois.nic.ad.jp' => {
523 '192.0.2.3' => <<'OUTPUT',
524 [ JPNIC database provides information regarding IP address and ASN. Its use ]
525 [ is restricted to network administration purposes. For further information, ]
526 [ use 'whois -h whois.nic.ad.jp help'. To only display English output, ]
527 [ add '/e' at the end of command, e.g. 'whois -h whois.nic.ad.jp xxx/e'. ]
529 Network Information:
530 a. [Network Number] 192.0.2.0/25
531 b. [Network Name] X
532 g. [Organization] X
533 m. [Administrative Contact] ROLE-3
534 n. [Technical Contact] ROLE-3
535 p. [Nameserver] X
536 p. [Nameserver] X
537 [Assigned Date] X
538 [Return Date]
539 [Last Update] X
541 Less Specific Info.
542 ----------
544 [Allocation] 192.0.2.0/24
546 More Specific Info.
547 ----------
548 No match!!
549 OUTPUT
550 'ROLE-3' => <<'OUTPUT',
551 [ JPNIC database provides information regarding IP address and ASN. Its use ]
552 [ is restricted to network administration purposes. For further information, ]
553 [ use 'whois -h whois.nic.ad.jp help'. To only display English output, ]
554 [ add '/e' at the end of command, e.g. 'whois -h whois.nic.ad.jp xxx/e'. ]
556 Group Contact Information:
557 [Group Handle] ROLE-3
558 [Group Name] X
559 [E-Mail] good@example.com
560 [Organization] X
561 [Division]
562 [TEL] X
563 [FAX]
564 [Last Update] X
565 bad@example.com
566 OUTPUT
567 '192.0.2.7' => <<'OUTPUT',
568 [ JPNIC database provides information regarding IP address and ASN. Its use ]
569 [ is restricted to network administration purposes. For further information, ]
570 [ use 'whois -h whois.nic.ad.jp help'. To only display English output, ]
571 [ add '/e' at the end of command, e.g. 'whois -h whois.nic.ad.jp xxx/e'. ]
573 Network Information:
574 a. [Network Number] 192.0.2.0/25
575 b. [Network Name] X
576 g. [Organization] X
577 m. [Administrative Contact] ROLE-6
578 n. [Technical Contact] ROLE-6
579 p. [Nameserver] X
580 [Assigned Date] X
581 [Return Date]
582 [Last Update] X
584 Less Specific Info.
585 ----------
587 [Allocation] 192.0.2.0/24
589 More Specific Info.
590 ----------
591 No match!!
592 OUTPUT
593 'ROLE-6' => <<'OUTPUT'
594 [ JPNIC database provides information regarding IP address and ASN. Its use ]
595 [ is restricted to network administration purposes. For further information, ]
596 [ use 'whois -h whois.nic.ad.jp help'. To only display English output, ]
597 [ add '/e' at the end of command, e.g. 'whois -h whois.nic.ad.jp xxx/e'. ]
599 Contact Information:
600 a. [JPNIC Handle] ROLE-6
601 c. [Last, First] X
602 d. [E-Mail] good@example.com
603 g. [Organization] X
604 l. [Division] X
605 n. [Title] X
606 o. [TEL] X
607 p. [FAX] X
608 y. [Reply Mail]
609 [Last Update] X
610 bad@example.com
611 OUTPUT
613 'whois.ripe.net' => {
614 '192.0.2.1' => <<'OUTPUT',
615 % This is the RIPE Database query service.
616 % The objects are in RPSL format.
618 % The RIPE Database is subject to Terms and Conditions.
619 % See http://www.ripe.net/db/support/db-terms-conditions.pdf
621 % Note: this output has been filtered.
622 % To receive output for a database update, use the "-B" flag.
624 % Information related to '192.0.2.0 - 192.0.2.255'
626 % Abuse contact for '192.0.2.0 - 192.0.2.255' is 'bad@example.com'
628 inetnum: 192.0.2.0 - 192.0.2.255
629 netname: X
630 descr: X
631 descr: X
632 country: X
633 org: ORG-2
634 admin-c: PERSON-1
635 tech-c: ROLE-1
636 status: X
637 mnt-by: X
638 remarks: X
639 created: X
640 last-modified: X
641 source: RIPE
643 organisation: ORG-2
644 org-name: X
645 org-type: X
646 address: X
647 address: X
648 address: X
649 address: X
650 phone: X
651 phone: X
652 admin-c: X
653 admin-c: X
654 tech-c: ROLE-1
655 abuse-c: ROLE-1
656 mnt-ref: X
657 mnt-ref: X
658 mnt-by: X
659 mnt-by: X
660 created: X
661 last-modified: X
662 source: RIPE # Filtered
664 role: X
665 address: X
666 address: X
667 address: X
668 address: X
669 address: X
670 phone: X
671 phone: X
672 abuse-mailbox: good@example.com
673 org: ORG-2
674 admin-c: X
675 tech-c: X
676 tech-c: X
677 nic-hdl: ROLE-1
678 mnt-by: X
679 created: X
680 last-modified: X
681 source: RIPE # Filtered
683 person: X
684 address: X
685 address: X
686 address: X
687 address: X
688 address: X
689 phone: X
690 nic-hdl: PERSON-1
691 mnt-by: X
692 created: X
693 last-modified: X
694 source: RIPE # Filtered
696 % Information related to '192.0.2.0/24AS0001'
698 route: 192.0.2.0/24
699 descr: X
700 origin: AS0001
701 mnt-by: X
702 remarks: X
703 created: X
704 last-modified: X
705 source: RIPE
707 % This query was served by the RIPE Database Query Service version 1.98 (WAGYU)
710 OUTPUT
711 '192.0.2.2' => <<'OUTPUT',
712 % This is the RIPE Database query service.
713 % The objects are in RPSL format.
715 % The RIPE Database is subject to Terms and Conditions.
716 % See http://www.ripe.net/db/support/db-terms-conditions.pdf
718 % Note: this output has been filtered.
719 % To receive output for a database update, use the "-B" flag.
721 % Information related to '192.0.2.0 - 192.0.2.255'
723 % Abuse contact for '192.0.2.0 - 192.0.2.255' is 'good@example.com'
725 inetnum: 192.0.2.0 - 192.0.2.255
726 netname: X
727 descr: X
728 country: X
729 admin-c: PERSON-1
730 tech-c: PERSON-2
731 status: X
732 mnt-by: X
733 mnt-domains: X
734 created: X
735 last-modified: X
736 source: RIPE
738 person: X
739 address: X
740 phone: X
741 nic-hdl: PERSON-1
742 mnt-by: X
743 created: X
744 last-modified: X
745 source: RIPE
747 person: X
748 address: X
749 phone: X
750 nic-hdl: PERSON-2
751 mnt-by: X
752 created: X
753 last-modified: X
754 source: RIPE
756 % Information related to '192.0.2.0/24AS00001'
758 route: 192.0.2.0/24
759 descr: X
760 origin: AS00001
761 mnt-by: X
762 created: X
763 last-modified: X
764 source: RIPE
766 % This query was served by the RIPE Database Query Service version 1.98 (ANGUS)
769 OUTPUT
770 '192.0.2.5' => <<'OUTPUT',
771 % This is the RIPE Database query service.
772 % The objects are in RPSL format.
774 % The RIPE Database is subject to Terms and Conditions.
775 % See http://www.ripe.net/db/support/db-terms-conditions.pdf
777 % Note: this output has been filtered.
778 % To receive output for a database update, use the "-B" flag.
780 % Information related to '192.0.2.0 - 192.0.2.255'
782 % Abuse contact for '192.0.2.0 - 192.0.2.255' is 'bad@example.com'
784 inetnum: 192.0.2.0 - 192.0.2.255
785 abuse-c: ROLE-4
786 netname: X
787 country: X
788 admin-c: PERSON-4
789 tech-c: PERSON-4
790 status: X
791 mnt-by: X
792 created: X
793 last-modified: X
794 source: RIPE
796 person: X
797 address: X
798 address: X
799 address: X
800 phone: X
801 nic-hdl: PERSON-4
802 mnt-by: X
803 created: X
804 last-modified: X
805 source: RIPE # Filtered
806 org: X
808 % This query was served by the RIPE Database Query Service version 1.98 (BLAARKOP)
811 OUTPUT
812 'ROLE-4' => <<'OUTPUT',
813 % This is the RIPE Database query service.
814 % The objects are in RPSL format.
816 % The RIPE Database is subject to Terms and Conditions.
817 % See http://www.ripe.net/db/support/db-terms-conditions.pdf
819 % Note: this output has been filtered.
820 % To receive output for a database update, use the "-B" flag.
822 % Information related to 'ROLE-4'
824 role: X
825 remarks: X
826 address: X
827 address: X
828 address: X
829 address: X
830 abuse-mailbox: good@example.com
831 nic-hdl: ROLE-4
832 mnt-by: X
833 created: X
834 last-modified: X
835 source: RIPE # Filtered
837 % This query was served by the RIPE Database Query Service version 1.98 (WAGYU)
840 OUTPUT
844 our $server = undef;
846 no warnings qw(once redefine);
848 *App::Abuser::address2rir = sub {
849 my ($ip) = @_;
850 if (!defined $ip) {
851 die "Missing an argument for App::Abuser::address2rir().\n";
853 if (!defined $server) {
854 die "You forgot to override WHOIS server with setting a \$Stub::server variable.\n";
856 return $server;
859 *App::Abuser::query = sub {
860 my ($self, @arguments) = @_;
862 my $key = $examples;
863 for my $arg (@arguments) {
864 if (ref $key eq '') {
865 die "Too many arguments: App::Abuser::query(" . join(', ', @arguments) . ")\n";
867 if (!exists $key->{$arg}) {
868 die "Unknown argument '$arg' in: App::Abuser::query(" . join(', ', @arguments) . ")\n";
870 $key = $key->{$arg};
873 if (ref $key ne '') {
874 die "Too few arguments: App::Abuser::query(" . join(', ', @arguments) . ")\n";
877 return $key;