Skip to content

Commit 639e33a

Browse files
authored
Merge pull request #34 from maxmind/horgh/is-in-eu
Update geoip2 dependency and add support for is_in_european_union
2 parents e242b85 + a3f77a6 commit 639e33a

9 files changed

Lines changed: 154 additions & 86 deletions

File tree

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ language: java
1515
jdk:
1616
- openjdk7
1717
- oraclejdk8
18+
- oraclejdk9
1819
env:
1920
global:
2021
- secure: ExeU8coyJzkKuZwLjeVUl8y0PgEWQ7xl3JBFcJcYyweVQbid0Av2ZDEdOrJDTiT7Vb7/Gmny0sUOCyclPDOH8RS+0ENerhA/JDgsrU8KfSDLvPDjBXPX7sEnLVbCmM0SESjRNZ8apVgZexcbODQRfv6FRgpue0TomVb35c/Jdeu577DdEhXUr3PYbgluKhayZlRoJgdEYRKGolbstlkA4Zx6hUDoq2+Wzt782bQ7SOZD/Xi4VG/X7T8sUNjbg8JpxoN2rf/1Jsa3+HGVIaArda6KQu03iNQ/nqgRMB5Q9lOMXIwoLjEFVWHrJd7mBaHaHI0AJnCem/DP7amTsyv6vjgXHTHlPS2Cf6X/127ljry1+oOwLLe7o3ofsZkKB1+0+VhalHXFM60KHwAdsgYP1wS2uP8ITfNG3GGkVp8boS586Kkd0LfGxXEnqhiKYlJlChqlCJTnHwzo/eIQGymGcAxLXQo5vYiK/CwkXyewIbeR+u1yRuXTudwXE6bQaDUTQhl4EPut4MDlovrE61quk3OtBLtS085k9gggU9M0Av8VX+LXdPke+39Z/fAFjdVoGSOkmvAKDftlaqR79TQ/ALN/dhl9d9umVd1xcxig+uQxrXR+HSdXz2ISNnacEP0ejrbOYLJbb5ph7ftZmkC/fsk8BcSt7eAncHXbASJeaM4=

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ CHANGELOG
44
1.8.0
55
------------------
66

7+
* Updated `geoip2` dependency. This version adds the `isInEuropeanUnion()`
8+
method to `com.maxmind.geoip2.record.Country` and
9+
`com.maxmind.minfraud.response.GeoIp2Country`. This returns `true` if the
10+
country is a member state of the European Union.
711
* The web service client now correctly handles a proxy of `Proxy.NO_PROXY`.
812
PR by Ernest Sadykov. GitHub #32.
913
* The following payment processors were added to the `Payment.Processor` enum:

README.dev.md

Lines changed: 73 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# Preparing your environment for a release
2-
- Ensure you have access to publish to the repository on
3-
[Sonatype](https://oss.sonatype.org).
4-
- See the section about Sonatype access.
5-
- You need a GPG secret key. You need to publish it as well.
6-
- See the section about setting up GPG.
7-
- Ensure the SSH key you use on GitHub.com is available.
8-
- e.g., `~/.ssh/id_rsa`.
9-
- Ensure an appropriate `~/.gitconfig` is set up.
10-
- The release process generates commits.
11-
- Ensure you have the necessary dependencies available:
12-
- e.g., `apt-get install maven openjdk-8-jdk git-core gpg`
13-
- Ensure [hub](https://github.com/github.com/hub) is set up and in your
14-
`PATH`.
15-
- An easy way to do this is get a release tarball and run `./install`.
2+
- Ensure you have access to publish to the repository on
3+
[Sonatype](https://oss.sonatype.org).
4+
- See the section about Sonatype access.
5+
- You need a GPG secret key. You need to publish it as well.
6+
- See the section about setting up GPG.
7+
- Ensure the SSH key you use on GitHub.com is available.
8+
- e.g., `~/.ssh/id_rsa`.
9+
- Ensure an appropriate `~/.gitconfig` is set up.
10+
- The release process generates commits.
11+
- Ensure you have the necessary dependencies available:
12+
- e.g., `apt-get install maven openjdk-8-jdk git-core gpg`
13+
- Ensure [hub](https://github.com/github.com/hub) is set up and in your
14+
`PATH`.
15+
- An easy way to do this is get a release tarball and run `./install`.
1616

1717

1818
## Setting up Sonatype access
@@ -51,9 +51,9 @@ Put this information into `~/.m2/settings.xml` (Maven settings). Your
5151

5252
Some links about Sonatype:
5353

54-
* http://central.sonatype.org/pages/ossrh-guide.html
55-
* http://central.sonatype.org/pages/releasing-the-deployment.html
56-
* http://central.sonatype.org/pages/apache-maven.html
54+
* http://central.sonatype.org/pages/ossrh-guide.html
55+
* http://central.sonatype.org/pages/releasing-the-deployment.html
56+
* http://central.sonatype.org/pages/apache-maven.html
5757

5858

5959
## Setting up GPG
@@ -94,47 +94,57 @@ Add this to ~/.gnupg/gpg-agent.conf:
9494
# Releasing
9595

9696
## Steps
97-
- Ensure you can run `mvn test` and `mvn package` successfully. Run
98-
`mvn clean` after.
99-
- Ensure you have a clean checkout of `master` and that the subdirectory
100-
`.gh-pages` either does not exist or is a clean checkout.
101-
- We'll be generating commits.
102-
- Set a version and a date in `CHANGELOG.md` and commit that.
103-
- It gets used in the release process.
104-
- Run `./dev-bin/release.sh`
105-
- This will prompt you several times. Generally you need to say `y` or
106-
`n`.
107-
- You'll be prompted for your ssh key password, GPG key password, and
108-
GitHub.com username and password several times depending on your
109-
workspace.
110-
- You may be prompted about "what is the next development version?". Hit
111-
enter to use the default which should be fine.
112-
- You may be prompted about "The following dependencies in Dependencies
113-
have newer versions". See the section about updating dependencies if so.
114-
- If you get HTTP 401 errors from Sonatype, you probably don't have a
115-
correct `settings.xml`. Refer to the Sonatype section.
116-
- If this happened, there are most likely pushed commits on GitHub.com.
117-
You can potentially rebase and drop the commits and force push and
118-
start over (you might want to talk about this before doing it). Note
119-
you'll need to delete the release tag too:
120-
`git push origin :refs/tags/vx.y.z && git tag -d vx.y.z`.
121-
- If you get to this point, then a release is on GitHub.com and in the
122-
staging repository on [Sonatype](https://oss.sonatype.org).
123-
- Go to [Sonatype](https://oss.sonatype.org) and log in.
124-
- On the left hand side, choose Staging repositories.
125-
- At the bottom you should see your staged release. It will be something
126-
like "commmaxmind-xxxx". Click on that.
127-
- Near the top of the page there is a "Close" button. Click it.
128-
- You have to close a staging release before you can release it.
129-
- Wait around 30 seconds. Click Refresh near the top of the page while
130-
you wait. Eventually you should see the "Activity" line in the info
131-
about your repository say something like it is complete.
132-
- Click Release near the top.
133-
- You're done!
134-
- If you want to check things over, look at the commits on GitHub.com,
135-
including to the `gh-pages` branch and release tags, and do an artifact
136-
search on [Sonatype](https://oss.sonatype.org) to see the version is as
137-
you expect.
97+
- Ensure you can run `mvn test` and `mvn package` successfully. Run
98+
`mvn clean` after.
99+
- Ensure you have a clean checkout of `master` and that the subdirectory
100+
`.gh-pages` either does not exist or is a clean checkout.
101+
- We'll be generating commits.
102+
- Review open issues and PRs to see if any can easily be fixed, closed, or
103+
merged.
104+
- Review `CHANGELOG.md` for completeness and correctness.
105+
- Set a version and a date in `CHANGELOG.md` and commit that.
106+
- It gets used in the release process.
107+
- Bump copyright year in `README.md` if appropriate.
108+
- You don't need to update the version. `./dev-bin/release.sh` does this.
109+
- Run `./dev-bin/release.sh`
110+
- This will package the release, update the gh-pages branch, bump the
111+
version to the next development release, upload the release to GitHub
112+
and tag it, and upload to Sonatype.
113+
- This will prompt you several times. Generally you need to say `y` or `n`.
114+
- You'll be prompted for your ssh key password, GPG key password, and
115+
GitHub.com username and password several times depending on your
116+
workspace.
117+
- You may be prompted about "what is the next development version?". Hit
118+
enter to use the default which should be fine.
119+
- You may be prompted about "The following dependencies in Dependencies
120+
have newer versions". See the section about updating dependencies if so.
121+
- If you get HTTP 401 errors from Sonatype, you probably don't have a
122+
correct `settings.xml`. Refer to the Sonatype section.
123+
- If this happened, there are most likely pushed commits on GitHub.com.
124+
You can potentially rebase and drop the commits and force push and
125+
start over (you might want to talk about this before doing it). Note
126+
you'll need to delete the release tag too:
127+
`git push origin :refs/tags/vx.y.z && git tag -d vx.y.z`.
128+
- If you get to this point, then a release is on GitHub.com and in the
129+
staging repository on [Sonatype](https://oss.sonatype.org).
130+
- Go to [Sonatype](https://oss.sonatype.org) and log in.
131+
- On the left hand side, choose Staging repositories.
132+
- At the bottom you should see your staged release. It will be something
133+
like "commmaxmind-xxxx". Click on that.
134+
- Near the top of the page there is a "Close" button. Click it.
135+
- You have to close a staging release before you can release it.
136+
- Wait around 30 seconds. Click Refresh near the top of the page while
137+
you wait. Eventually you should see the "Activity" line in the info
138+
about your repository say something like it is complete.
139+
- Click Release near the top.
140+
- This also takes a moment (you will see "operation in progress" again).
141+
Refresh as usual. When it's done, you won't see the "commmaxmind-xxxx"
142+
entry in the staging repositories any more.
143+
- You're done!
144+
- If you want to check things over, look at the commits on GitHub.com,
145+
including to the `gh-pages` branch and release tags, and do an artifact
146+
search on [Sonatype](https://oss.sonatype.org) to see the version is as
147+
you expect.
138148

139149

140150
## Updating dependencies
@@ -144,11 +154,11 @@ process (say `n` or ctrl-c out).
144154

145155
To update them:
146156

147-
- Make a branch
148-
- Update `pom.xml` to have the new versions you want
149-
- Run `mvn test` and fix any errors
150-
- Push and ensure Travis completes successfully
151-
- Merge
157+
- Make a branch
158+
- Update `pom.xml` to have the new versions you want
159+
- Run `mvn test` and fix any errors
160+
- Push and ensure Travis completes successfully
161+
- Merge
152162

153163
If you did this in the middle of releasing, you'll have to start that
154164
process over.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ Transaction request = new Transaction.Builder(
169169
.amount(new BigDecimal(Double.toString(1.1)))
170170
.currency("USD")
171171
.discountCode("10OFF")
172-
.referrerUri(new URI("http://www.google.com/"))
172+
.referrerUri(new URI("https://www.google.com/"))
173173
.subaffiliateId("saf9")
174174
.build()
175175
).payment(
@@ -240,10 +240,10 @@ Patches and pull requests are encouraged. Please include unit tests whenever pos
240240

241241
## Versioning ##
242242

243-
This API uses [Semantic Versioning](http://semver.org/).
243+
This API uses [Semantic Versioning](https://semver.org/).
244244

245245
## Copyright and License ##
246246

247-
This software is Copyright (c) 2015-2017 by MaxMind, Inc.
247+
This software is Copyright (c) 2015-2018 by MaxMind, Inc.
248248

249249
This is free software, licensed under the Apache License, Version 2.0.

pom.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,27 @@
4242
<dependency>
4343
<groupId>com.fasterxml.jackson.core</groupId>
4444
<artifactId>jackson-core</artifactId>
45-
<version>2.9.2</version>
45+
<version>2.9.3</version>
4646
</dependency>
4747
<dependency>
4848
<groupId>com.fasterxml.jackson.core</groupId>
4949
<artifactId>jackson-databind</artifactId>
50-
<version>2.9.2</version>
50+
<version>2.9.3</version>
5151
</dependency>
5252
<dependency>
5353
<groupId>com.fasterxml.jackson.core</groupId>
5454
<artifactId>jackson-annotations</artifactId>
55-
<version>2.9.2</version>
55+
<version>2.9.3</version>
5656
</dependency>
5757
<dependency>
5858
<groupId>com.maxmind.geoip2</groupId>
5959
<artifactId>geoip2</artifactId>
60-
<version>2.10.0</version>
60+
<version>2.11.0</version>
6161
</dependency>
6262
<dependency>
6363
<groupId>org.apache.httpcomponents</groupId>
6464
<artifactId>httpclient</artifactId>
65-
<version>4.5.3</version>
65+
<version>4.5.4</version>
6666
</dependency>
6767
<dependency>
6868
<groupId>commons-validator</groupId>
@@ -78,7 +78,7 @@
7878
<dependency>
7979
<groupId>com.github.tomakehurst</groupId>
8080
<artifactId>wiremock</artifactId>
81-
<version>2.10.1</version>
81+
<version>2.14.0</version>
8282
<scope>test</scope>
8383
</dependency>
8484
<dependency>
@@ -96,13 +96,13 @@
9696
<dependency>
9797
<groupId>com.fasterxml.jackson.jr</groupId>
9898
<artifactId>jackson-jr-objects</artifactId>
99-
<version>2.9.2</version>
99+
<version>2.9.3</version>
100100
<scope>test</scope>
101101
</dependency>
102102
<dependency>
103103
<groupId>pl.pragmatists</groupId>
104104
<artifactId>JUnitParams</artifactId>
105-
<version>1.1.0</version>
105+
<version>1.1.1</version>
106106
<scope>test</scope>
107107
</dependency>
108108
<dependency>

src/main/java/com/maxmind/minfraud/response/GeoIp2Country.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,35 @@
1414
public final class GeoIp2Country extends Country {
1515
private final boolean isHighRisk;
1616

17+
// This method is for backwards compatibility. We should remove it when we
18+
// do a major release.
19+
public GeoIp2Country(
20+
List<String> locales,
21+
Integer confidence,
22+
Integer geoNameId,
23+
boolean isHighRisk,
24+
String isoCode,
25+
Map<String, String> names
26+
) {
27+
this(locales, confidence, geoNameId, isHighRisk, false, isoCode, names);
28+
}
29+
1730
public GeoIp2Country(
1831
@JacksonInject("locales") List<String> locales,
1932
@JsonProperty("confidence") Integer confidence,
2033
@JsonProperty("geoname_id") Integer geoNameId,
2134
@JsonProperty("is_high_risk") boolean isHighRisk,
35+
@JsonProperty("is_in_european_union") boolean isInEuropeanUnion,
2236
@JsonProperty("iso_code") String isoCode,
2337
@JsonProperty("names") Map<String, String> names
2438
) {
25-
super(locales, confidence, geoNameId, isoCode, names);
39+
super(locales, confidence, geoNameId, isInEuropeanUnion, isoCode,
40+
names);
2641
this.isHighRisk = isHighRisk;
2742
}
2843

2944
public GeoIp2Country() {
30-
this(null, null, null, false, null, null);
45+
this(null, null, null, false, false, null, null);
3146
}
3247

3348
/**

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import static com.jcabi.matchers.RegexMatchers.matchesPattern;
2323
import static com.maxmind.minfraud.request.RequestTestHelper.*;
2424
import static org.hamcrest.core.StringStartsWith.startsWith;
25+
import static org.junit.Assert.assertFalse;
26+
import static org.junit.Assert.assertTrue;
2527

2628
@RunWith(JUnitParamsRunner.class)
2729
public class WebServiceClientTest {
@@ -68,6 +70,15 @@ public void testFullInsightsTransaction() throws Exception {
6870
// We cannot change this as it would be a breaking change to the GeoIP2 API.
6971
JSONAssert.assertEquals(responseContent, response.toJson(), false);
7072
verifyRequestFor("insights", "full-request");
73+
assertTrue(
74+
"response.getIpAddress().getCountry().isInEuropeanUnion() does not return true",
75+
response.getIpAddress().getCountry().isInEuropeanUnion());
76+
assertFalse(
77+
"response.getIpAddress().getRegisteredCountry().isInEuropeanUnion() does not return false",
78+
response.getIpAddress().getRegisteredCountry().isInEuropeanUnion());
79+
assertTrue(
80+
"response.getIpAddress().getRepresentedCountry().isInEuropeanUnion() does not return true",
81+
response.getIpAddress().getRepresentedCountry().isInEuropeanUnion());
7182
}
7283
}
7384

@@ -83,6 +94,15 @@ public void testFullFactorsTransaction() throws Exception {
8394
// We cannot change this as it would be a breaking change to the GeoIP2 API.
8495
JSONAssert.assertEquals(responseContent, response.toJson(), false);
8596
verifyRequestFor("factors", "full-request");
97+
assertTrue(
98+
"response.getIpAddress().getCountry().isInEuropeanUnion() does not return true",
99+
response.getIpAddress().getCountry().isInEuropeanUnion());
100+
assertTrue(
101+
"response.getIpAddress().getRegisteredCountry().isInEuropeanUnion() does not return true",
102+
response.getIpAddress().getRegisteredCountry().isInEuropeanUnion());
103+
assertFalse(
104+
"response.getIpAddress().getRepresentedCountry().isInEuropeanUnion() does not return false",
105+
response.getIpAddress().getRepresentedCountry().isInEuropeanUnion());
86106
}
87107
}
88108

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"confidence": 99,
3737
"geoname_id": 2635167,
3838
"is_high_risk": false,
39+
"is_in_european_union": true,
3940
"iso_code": "GB",
4041
"names": {
4142
"de": "Vereinigtes K\u00f6nigreich",
@@ -56,17 +57,18 @@
5657
"time_zone": "Europe\/London"
5758
},
5859
"registered_country": {
59-
"geoname_id": 6252001,
60-
"iso_code": "US",
60+
"geoname_id": 2635167,
61+
"is_in_european_union": true,
62+
"iso_code": "GB",
6163
"names": {
62-
"de": "USA",
63-
"en": "United States",
64-
"es": "Estados Unidos",
65-
"fr": "\u00c9tats-Unis",
66-
"ja": "\u30a2\u30e1\u30ea\u30ab\u5408\u8846\u56fd",
67-
"pt-BR": "Estados Unidos",
68-
"ru": "\u0421\u0428\u0410",
69-
"zh-CN": "\u7f8e\u56fd"
64+
"de": "Vereinigtes K\u00f6nigreich",
65+
"en": "United Kingdom",
66+
"es": "Reino Unido",
67+
"fr": "Royaume-Uni",
68+
"ja": "\u30a4\u30ae\u30ea\u30b9",
69+
"pt-BR": "Reino Unido",
70+
"ru": "\u0412\u0435\u043b\u0438\u043a\u043e\u0431\u0440\u0438\u0442\u0430\u043d\u0438\u044f",
71+
"zh-CN": "\u82f1\u56fd"
7072
}
7173
},
7274
"subdivisions": [

0 commit comments

Comments
 (0)