GeoIP: ignore local addresses

This commit is contained in:
Gabriele C
2017-07-07 20:41:10 +02:00
parent 001e5d0376
commit cd4693eedf
3 changed files with 53 additions and 2 deletions
@@ -0,0 +1,22 @@
package fr.xephi.authme.util;
import org.junit.Test;
import static org.junit.Assert.assertThat;
import static org.hamcrest.Matchers.equalTo;
/**
* Test for {@link InternetProtocolUtils}
*/
public class InternetProtocolUtilsTest {
@Test
public void shouldCheckLocalAddress() {
assertThat(InternetProtocolUtils.isLocalAddress("127.0.0.1"), equalTo(true));
assertThat(InternetProtocolUtils.isLocalAddress("10.0.0.1"), equalTo(true));
assertThat(InternetProtocolUtils.isLocalAddress("172.0.0.1"), equalTo(false));
assertThat(InternetProtocolUtils.isLocalAddress("172.16.0.1"), equalTo(true));
assertThat(InternetProtocolUtils.isLocalAddress("192.168.0.1"), equalTo(true));
assertThat(InternetProtocolUtils.isLocalAddress("94.32.34.5"), equalTo(false));
}
}