Skip to content

Commit 7067f03

Browse files
authored
Merge pull request #81 from maxmind/greg/network
Update geoip2 and add network tests
2 parents 3e638ba + b1c771f commit 7067f03

6 files changed

Lines changed: 19 additions & 3 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<dependency>
5858
<groupId>com.maxmind.geoip2</groupId>
5959
<artifactId>geoip2</artifactId>
60-
<version>2.12.0</version>
60+
<version>2.13.0</version>
6161
</dependency>
6262
<dependency>
6363
<groupId>org.apache.httpcomponents</groupId>

src/test/java/com/maxmind/minfraud/WebServiceClientTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ public void testFullInsightsTransaction() throws Exception {
8080
assertTrue(
8181
"response.getIpAddress().getRepresentedCountry().isInEuropeanUnion() does not return true",
8282
response.getIpAddress().getRepresentedCountry().isInEuropeanUnion());
83-
assertEquals(response.getDevice().getLocalTime(),
84-
"2018-04-05T15:34:40-07:00");
83+
assertEquals("2018-04-05T15:34:40-07:00", response.getDevice().getLocalTime());
84+
85+
assertEquals("81.2.69.160", response.getIpAddress().getTraits().getIpAddress() );
86+
assertEquals("81.2.69.0/24", response.getIpAddress().getTraits().getNetwork().toString());
8587

8688
assertTrue(response.getCreditCard().isVirtual());
8789
}
@@ -108,6 +110,10 @@ public void testFullFactorsTransaction() throws Exception {
108110
assertFalse(
109111
"response.getIpAddress().getRepresentedCountry().isInEuropeanUnion() does not return false",
110112
response.getIpAddress().getRepresentedCountry().isInEuropeanUnion());
113+
114+
115+
assertEquals("81.2.69.160", response.getIpAddress().getTraits().getIpAddress() );
116+
assertEquals("81.2.69.0/24", response.getIpAddress().getTraits().getNetwork().toString());
111117
}
112118
}
113119

src/test/java/com/maxmind/minfraud/response/InsightsResponseTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ public void testInsights() throws Exception {
2525
.startObjectField("country")
2626
.put("iso_code", "US")
2727
.end()
28+
.startObjectField("traits")
29+
.put("ip_address", "81.2.69.160")
30+
.put("network", "81.2.69.0/24")
31+
.end()
2832
.end()
2933
.startObjectField("credit_card")
3034
.put("is_prepaid", true)
@@ -58,5 +62,7 @@ public void testInsights() throws Exception {
5862
assertEquals("correct queries remaining", Integer.valueOf(123), insights.getQueriesRemaining());
5963
assertEquals("correct risk score", Double.valueOf(0.01), insights.getRiskScore());
6064
assertEquals("correct warning code", "INVALID_INPUT", insights.getWarnings().get(0).getCode());
65+
assertEquals("81.2.69.160", insights.getIpAddress().getTraits().getIpAddress());
66+
assertEquals("81.2.69.0/24", insights.getIpAddress().getTraits().getNetwork().toString());
6167
}
6268
}

src/test/java/com/maxmind/minfraud/response/IpAddressTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ public void testIpAddress() throws Exception {
3131
.put("is_hosting_provider", true)
3232
.put("is_public_proxy", true)
3333
.put("is_tor_exit_node", true)
34+
.put("network", "1.2.0.0/16")
3435
.end()
3536
.end()
3637
.finish()
3738
);
3839

3940
assertEquals("IP risk", new Double(99), address.getRisk());
4041
assertEquals("correct local time", time, address.getLocation().getLocalTime());
42+
assertEquals("1.2.0.0/16", address.getTraits().getNetwork().toString());
4143
assertTrue("isHighRisk", address.getCountry().isHighRisk());
4244
assertTrue("isAnonymous", address.getTraits().isAnonymous());
4345
assertTrue("isAnonymousVpn", address.getTraits().isAnonymousVpn());

src/test/resources/test-data/factors-response.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
"is_satellite_provider": true,
9595
"is_tor_exit_node": true,
9696
"isp": "Andrews & Arnold Ltd",
97+
"network": "81.2.69.0/24",
9798
"organization": "STONEHOUSE office network",
9899
"user_type": "government"
99100
}

src/test/resources/test-data/insights-response.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
"is_satellite_provider": true,
109109
"is_tor_exit_node": true,
110110
"isp": "Andrews & Arnold Ltd",
111+
"network": "81.2.69.0/24",
111112
"organization": "STONEHOUSE office network",
112113
"user_type": "government"
113114
}

0 commit comments

Comments
 (0)