Skip to content

Commit ec0330c

Browse files
authored
Merge pull request #31 from maxmind/greg/anonymizer
Update geoip2 to 2.10.0 and add anonymizer tests
2 parents 2bc5e85 + 2ab474b commit ec0330c

9 files changed

Lines changed: 42 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ CHANGELOG
1010
* `EMERCHANTPAY`
1111
* `HEARTLAND`
1212
* `PAYWAY`
13+
* Updated `geoip2` dependency to add support for GeoIP2 Precision
14+
Insights anonymizer fields.
15+
* Replaced use of deprecated `com.fasterxml.jackson.databind.util.ISO8601DateFormat`
16+
with `com.fasterxml.jackson.databind.util.StdDateFormat` where
17+
`withColonInTimeZone` is set to `true`.
1318

1419
1.6.0 (2017-09-08)
1520
------------------

pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,22 @@
4242
<dependency>
4343
<groupId>com.fasterxml.jackson.core</groupId>
4444
<artifactId>jackson-core</artifactId>
45-
<version>2.9.1</version>
45+
<version>2.9.2</version>
4646
</dependency>
4747
<dependency>
4848
<groupId>com.fasterxml.jackson.core</groupId>
4949
<artifactId>jackson-databind</artifactId>
50-
<version>2.9.1</version>
50+
<version>2.9.2</version>
5151
</dependency>
5252
<dependency>
5353
<groupId>com.fasterxml.jackson.core</groupId>
5454
<artifactId>jackson-annotations</artifactId>
55-
<version>2.9.1</version>
55+
<version>2.9.2</version>
5656
</dependency>
5757
<dependency>
5858
<groupId>com.maxmind.geoip2</groupId>
5959
<artifactId>geoip2</artifactId>
60-
<version>2.9.0</version>
60+
<version>2.10.0</version>
6161
</dependency>
6262
<dependency>
6363
<groupId>org.apache.httpcomponents</groupId>
@@ -78,7 +78,7 @@
7878
<dependency>
7979
<groupId>com.github.tomakehurst</groupId>
8080
<artifactId>wiremock</artifactId>
81-
<version>2.8.0</version>
81+
<version>2.10.1</version>
8282
<scope>test</scope>
8383
</dependency>
8484
<dependency>

src/main/java/com/maxmind/minfraud/AbstractModel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import com.fasterxml.jackson.databind.MapperFeature;
55
import com.fasterxml.jackson.databind.ObjectMapper;
66
import com.fasterxml.jackson.databind.SerializationFeature;
7-
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
7+
import com.fasterxml.jackson.databind.util.StdDateFormat;
88

99
import java.io.IOException;
1010

@@ -20,7 +20,7 @@ public final String toJson() throws IOException {
2020
mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
2121
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
2222
mapper.disable(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS);
23-
mapper.setDateFormat(new ISO8601DateFormat());
23+
mapper.setDateFormat(new StdDateFormat().withColonInTimeZone(true));
2424
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
2525

2626
return mapper.writeValueAsString(this);

src/main/java/com/maxmind/minfraud/WebServiceClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.fasterxml.jackson.databind.InjectableValues.Std;
77
import com.fasterxml.jackson.databind.MapperFeature;
88
import com.fasterxml.jackson.databind.ObjectMapper;
9-
import com.fasterxml.jackson.databind.util.ISO8601DateFormat;
9+
import com.fasterxml.jackson.databind.util.StdDateFormat;
1010
import com.maxmind.minfraud.exception.*;
1111
import com.maxmind.minfraud.request.Transaction;
1212
import com.maxmind.minfraud.response.FactorsResponse;
@@ -62,7 +62,7 @@ private WebServiceClient(WebServiceClient.Builder builder) {
6262
mapper = new ObjectMapper();
6363
mapper.disable(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS);
6464
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
65-
mapper.setDateFormat(new ISO8601DateFormat());
65+
mapper.setDateFormat(new StdDateFormat().withColonInTimeZone(true));
6666

6767
RequestConfig.Builder configBuilder = RequestConfig.custom()
6868
.setConnectTimeout(builder.connectTimeout)

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,26 @@ public void testIpAddress() throws Exception {
2424
.startObjectField("location")
2525
.put("local_time", time)
2626
.end()
27+
.startObjectField("traits")
28+
.put("ip_address", "1.2.3.4")
29+
.put("is_anonymous", true)
30+
.put("is_anonymous_vpn", true)
31+
.put("is_hosting_provider", true)
32+
.put("is_public_proxy", true)
33+
.put("is_tor_exit_node", true)
34+
.end()
2735
.end()
2836
.finish()
2937
);
3038

3139
assertEquals("IP risk", new Double(99), address.getRisk());
3240
assertEquals("correct local time", time, address.getLocation().getLocalTime());
3341
assertTrue("isHighRisk", address.getCountry().isHighRisk());
42+
assertTrue("isAnonymous", address.getTraits().isAnonymous());
43+
assertTrue("isAnonymousVpn", address.getTraits().isAnonymousVpn());
44+
assertTrue("isHostingProvider", address.getTraits().isHostingProvider());
45+
assertTrue("isPublicProxy", address.getTraits().isPublicProxy());
46+
assertTrue("isTorExitNode", address.getTraits().isTorExitNode());
47+
3448
}
3549
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@
8585
"traits": {
8686
"domain": "in-addr.arpa",
8787
"ip_address": "81.2.69.160",
88+
"is_anonymous": true,
89+
"is_anonymous_vpn": true,
90+
"is_hosting_provider": true,
91+
"is_public_proxy": true,
92+
"is_satellite_provider": true,
93+
"is_tor_exit_node": true,
8894
"isp": "Andrews & Arnold Ltd",
8995
"organization": "STONEHOUSE office network",
9096
"user_type": "government"

src/test/resources/test-data/full-request-email-md5.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"event": {
33
"transaction_id": "txn3134133",
44
"shop_id": "s2123",
5-
"time": "2012-04-12T23:20:50Z",
5+
"time": "2012-04-12T23:20:50.052+00:00",
66
"type": "purchase"
77
},
88
"account": {

src/test/resources/test-data/full-request.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"event": {
33
"transaction_id": "txn3134133",
44
"shop_id": "s2123",
5-
"time": "2012-04-12T23:20:50Z",
5+
"time": "2012-04-12T23:20:50.052+00:00",
66
"type": "purchase"
77
},
88
"account": {

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@
8585
"traits": {
8686
"domain": "in-addr.arpa",
8787
"ip_address": "81.2.69.160",
88+
"is_anonymous": true,
89+
"is_anonymous_vpn": true,
90+
"is_hosting_provider": true,
91+
"is_public_proxy": true,
92+
"is_satellite_provider": true,
93+
"is_tor_exit_node": true,
8894
"isp": "Andrews & Arnold Ltd",
8995
"organization": "STONEHOUSE office network",
9096
"user_type": "government"

0 commit comments

Comments
 (0)