@@ -160,7 +160,11 @@ public function testGuzzleOverride()
160160 public function testGetMapURL ()
161161 {
162162 $ h = new IPinfo ();
163- $ url = $ h ->getMapUrl (file ("tests/map-ips.txt " ));
163+ $ url = $ h ->getMapUrl (file ("tests/map-ips.txt " , FILE_IGNORE_NEW_LINES ));
164+ if ($ url === null ) {
165+ // The Map endpoint is heavily rate limited
166+ $ this ->markTestSkipped ("Map API rate limit exceeded " );
167+ }
164168 $ this ->assertStringStartsWith ("https://ipinfo.io/tools/map/ " , $ url );
165169 }
166170
@@ -209,7 +213,7 @@ public function testGetBatchDetails()
209213 $ this ->assertNotNull ($ ipV4 ['region ' ]);
210214 $ this ->assertNotNull ($ ipV4 ['country ' ]);
211215 $ this ->assertNotNull ($ ipV4 ['loc ' ]);
212- $ this ->assertNull ($ ipV4 ['postal ' ]);
216+ $ this ->assertNotNull ($ ipV4 ['postal ' ]);
213217 $ this ->assertNotNull ($ ipV4 ['timezone ' ]);
214218 $ this ->assertEquals ($ ipV4 ['org ' ], 'AS3356 Level 3 Parent, LLC ' );
215219 }
@@ -405,4 +409,36 @@ public function testIPv6NotationsCaching()
405409 $ normalized_ip = inet_ntop (inet_pton ($ standard_ip ));
406410 $ h ->getDetails ($ normalized_ip );
407411 }
412+
413+ public function testResproxy ()
414+ {
415+ $ tok = getenv ('IPINFO_TOKEN ' );
416+ if (!$ tok ) {
417+ $ this ->markTestSkipped ('IPINFO_TOKEN env var required ' );
418+ }
419+
420+ $ h = new IPinfo ($ tok );
421+ $ ip = '175.107.211.204 ' ;
422+
423+ // test multiple times for cache hits
424+ for ($ i = 0 ; $ i < 5 ; $ i ++) {
425+ $ res = $ h ->getResproxy ($ ip );
426+ $ this ->assertEquals ($ res ['ip ' ], $ ip );
427+ $ this ->assertNotNull ($ res ['last_seen ' ]);
428+ $ this ->assertNotNull ($ res ['percent_days_seen ' ]);
429+ $ this ->assertNotNull ($ res ['service ' ]);
430+ }
431+ }
432+
433+ public function testResproxyEmpty ()
434+ {
435+ $ tok = getenv ("IPINFO_TOKEN " );
436+ if (!$ tok ) {
437+ $ this ->markTestSkipped ("IPINFO_TOKEN env var required " );
438+ }
439+
440+ $ h = new IPinfo ($ tok );
441+ $ res = $ h ->getResproxy ("8.8.8.8 " );
442+ $ this ->assertEquals ($ res , []);
443+ }
408444}
0 commit comments