Skip to content

Commit 90595d7

Browse files
Merge pull request #12 from ipdata/claude/verify-all-tests-G2MNU
Claude/verify all tests g2 mnu
2 parents af78129 + b5bd483 commit 90595d7

21 files changed

Lines changed: 635 additions & 55 deletions

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,15 @@ IpdataService ipdataService = Ipdata.builder().url(url)
4343
.key("MY_KEY").get();
4444
/.../
4545
```
46-
Optionally, you can configure a cache for faster access (less than 1ms latency on requests that hit the cache).
46+
47+
To use the EU endpoint for GDPR compliance, pass the EU API URL instead:
48+
```java
49+
URL url = new URL("https://eu-api.ipdata.co");
50+
IpdataService ipdataService = Ipdata.builder().url(url)
51+
.key("MY_KEY").get();
52+
```
53+
54+
Optionally, you can configure a cache for faster access (less than 1ms latency on requests that hit the cache).
4755

4856
The cache is configurable for time and space eviction policies:
4957

@@ -79,6 +87,7 @@ Output:
7987
"city": null,
8088
"region": null,
8189
"region_code": null,
90+
"region_type": null,
8291
"country_name": "Australia",
8392
"country_code": "AU",
8493
"continent_name": "Oceania",
@@ -97,6 +106,12 @@ Output:
97106
"route": "1.1.1.0/24",
98107
"type": "hosting"
99108
},
109+
"company": {
110+
"name": "Cloudflare, Inc.",
111+
"domain": "cloudflare.com",
112+
"network": "1.1.1.0/24",
113+
"type": "hosting"
114+
},
100115
"languages": [
101116
{
102117
"name": "English",
@@ -124,7 +139,9 @@ Output:
124139
"is_known_attacker": false,
125140
"is_known_abuser": false,
126141
"is_threat": false,
127-
"is_bogon": false
142+
"is_bogon": false,
143+
"is_icloud_relay": false,
144+
"is_datacenter": false
128145
},
129146
"count": "0"
130147
}

pom.xml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
</snapshotRepository>
3737
</distributionManagement>
3838
<properties>
39-
<maven.compiler.source>6</maven.compiler.source>
40-
<maven.compiler.target>6</maven.compiler.target>
39+
<maven.compiler.source>11</maven.compiler.source>
40+
<maven.compiler.target>11</maven.compiler.target>
4141
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4242
<sonar.coverage.jacoco.xmlReportPaths>${project.build.directory}/site/code-coverage/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
4343
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
@@ -48,10 +48,10 @@
4848
<sonar.projectKey>yassine_ipdata-java-client</sonar.projectKey>
4949
<sonar.projectName>ipdata-java-client</sonar.projectName>
5050
<sonar.projectVersion>${project.version}</sonar.projectVersion>
51-
<version.build.jacoco>0.8.4</version.build.jacoco>
52-
<version.build.sonar>3.7.0.1746</version.build.sonar>
53-
<version.build.surefire>3.0.0-M3</version.build.surefire>
54-
<version.client.feign>9.7.0</version.client.feign>
51+
<version.build.jacoco>0.8.14</version.build.jacoco>
52+
<version.build.sonar>3.11.0.3922</version.build.sonar>
53+
<version.build.surefire>3.5.5</version.build.surefire>
54+
<version.client.feign>11.10</version.client.feign>
5555
</properties>
5656
<dependencies>
5757
<dependency>
@@ -72,22 +72,22 @@
7272
<dependency>
7373
<groupId>com.google.guava</groupId>
7474
<artifactId>guava</artifactId>
75-
<version>20.0</version>
75+
<version>33.4.8-jre</version>
7676
</dependency>
7777
<dependency>
7878
<groupId>org.slf4j</groupId>
7979
<artifactId>slf4j-api</artifactId>
80-
<version>1.7.30</version>
80+
<version>1.7.36</version>
8181
</dependency>
8282
<dependency>
8383
<groupId>org.slf4j</groupId>
8484
<artifactId>slf4j-log4j12</artifactId>
85-
<version>1.7.30</version>
85+
<version>1.7.36</version>
8686
</dependency>
8787
<dependency>
8888
<groupId>org.projectlombok</groupId>
8989
<artifactId>lombok</artifactId>
90-
<version>1.18.10</version>
90+
<version>1.18.38</version>
9191
</dependency>
9292
<dependency>
9393
<groupId>org.hamcrest</groupId>
@@ -98,13 +98,13 @@
9898
<dependency>
9999
<groupId>junit</groupId>
100100
<artifactId>junit</artifactId>
101-
<version>4.13</version>
101+
<version>4.13.2</version>
102102
<scope>test</scope>
103103
</dependency>
104104
<dependency>
105105
<groupId>net.javacrumbs.json-unit</groupId>
106106
<artifactId>json-unit</artifactId>
107-
<version>2.17.0</version>
107+
<version>2.40.1</version>
108108
<scope>test</scope>
109109
</dependency>
110110
</dependencies>
@@ -121,7 +121,7 @@
121121
<plugins>
122122
<plugin>
123123
<artifactId>maven-resources-plugin</artifactId>
124-
<version>2.6</version>
124+
<version>3.3.1</version>
125125
<configuration>
126126
<encoding>${project.build.sourceEncoding}</encoding>
127127
</configuration>
@@ -175,7 +175,7 @@
175175
</plugin>
176176
<plugin>
177177
<artifactId>maven-source-plugin</artifactId>
178-
<version>3.2.1</version>
178+
<version>3.3.1</version>
179179
<executions>
180180
<execution>
181181
<goals>
@@ -186,7 +186,7 @@
186186
</plugin>
187187
<plugin>
188188
<artifactId>maven-javadoc-plugin</artifactId>
189-
<version>3.1.1</version>
189+
<version>3.12.0</version>
190190
<executions>
191191
<execution>
192192
<goals>
@@ -198,8 +198,8 @@
198198
<plugin>
199199
<groupId>org.sonatype.plugins</groupId>
200200
<artifactId>nexus-staging-maven-plugin</artifactId>
201-
<version>1.6.7</version>
202-
<extensions>true</extensions>
201+
<version>1.7.0</version>
202+
<extensions>false</extensions>
203203
<configuration>
204204
<serverId>maven-central-staging</serverId>
205205
<nexusUrl>https://oss.sonatype.org</nexusUrl>
@@ -208,7 +208,7 @@
208208
</plugin>
209209
<plugin>
210210
<artifactId>maven-gpg-plugin</artifactId>
211-
<version>1.6</version>
211+
<version>3.2.8</version>
212212
<configuration>
213213
<keyname>A143FB3D9A4D90CC76DE768495FD65EAEFC32F7E</keyname>
214214
</configuration>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package io.ipdata.client.model;
2+
3+
import lombok.Getter;
4+
import lombok.ToString;
5+
import lombok.experimental.Accessors;
6+
7+
@ToString @Getter @Accessors(fluent = true)
8+
public class Company {
9+
private String name;
10+
private String domain;
11+
private String network;
12+
private String type;
13+
}

src/main/java/io/ipdata/client/model/IpdataModel.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class IpdataModel {
2222

2323
private String region;
2424
private String regionCode;
25+
private String regionType;
2526
private String countryName;
2627
private String countryCode;
2728
private String continentName;
@@ -35,6 +36,7 @@ public class IpdataModel {
3536
private String emojiUnicode;
3637
private AsnModel asn;
3738
private Carrier carrier;
39+
private Company company;
3840
private List<Language> languages;
3941
private Currency currency;
4042
private TimeZone timeZone;

src/main/java/io/ipdata/client/model/ThreatModel.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,8 @@ public class ThreatModel {
2020
private boolean threat;
2121
@JsonProperty("is_bogon")
2222
private boolean bogon;
23+
@JsonProperty("is_icloud_relay")
24+
private boolean icloudRelay;
25+
@JsonProperty("is_datacenter")
26+
private boolean datacenter;
2327
}

src/main/java/io/ipdata/client/service/IpdataField.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@ public class IpdataField<T> {
1616
public static final IpdataField<Boolean> IS_EU = new IpdataField<Boolean>("is_eu", Boolean.class);
1717
public static final IpdataField<String> CITY = new IpdataField<String>("city", String.class);
1818
public static final IpdataField<String> REGION = new IpdataField<String>("region", String.class);
19+
public static final IpdataField<String> REGION_CODE = new IpdataField<String>("region_code", String.class);
20+
public static final IpdataField<String> REGION_TYPE = new IpdataField<String>("region_type", String.class);
1921
public static final IpdataField<String> COUNTRY_NAME = new IpdataField<String>("country_name", String.class);
2022
public static final IpdataField<String> COUNTRY_CODE = new IpdataField<String>("country_code", String.class);
2123
public static final IpdataField<String> CONTINENT_CODE = new IpdataField<String>("continent_code", String.class);
24+
public static final IpdataField<String> CONTINENT_NAME = new IpdataField<String>("continent_name", String.class);
2225
public static final IpdataField<Double> LATITUDE = new IpdataField<Double>("latitude", Double.class);
2326
public static final IpdataField<Double> LONGITUDE = new IpdataField<Double>("longitude", Double.class);
2427
public static final IpdataField<AsnModel> ASN = new IpdataField<AsnModel>("asn", AsnModel.class);
@@ -29,10 +32,11 @@ public class IpdataField<T> {
2932
public static final IpdataField<String> EMOJI_FLAG = new IpdataField<String>("emoji_flag", String.class);
3033
public static final IpdataField<String> EMOJI_UNICODE = new IpdataField<String>("emoji_unicode", String.class);
3134
public static final IpdataField<Carrier> CARRIER = new IpdataField<Carrier>("carrier", Carrier.class);
35+
public static final IpdataField<Company> COMPANY = new IpdataField<Company>("company", Company.class);
3236
public static final IpdataField<Language> LANGUAGES = new IpdataField<Language>("languages", Language.class);
3337
public static final IpdataField<Currency> CURRENCY = new IpdataField<Currency>("currency", Currency.class);
3438
public static final IpdataField<TimeZone> TIME_ZONE = new IpdataField<TimeZone>("time_zone", TimeZone.class);
35-
public static final IpdataField<TimeZone> THREAT = new IpdataField<TimeZone>("threat", TimeZone.class);
39+
public static final IpdataField<ThreatModel> THREAT = new IpdataField<ThreatModel>("threat", ThreatModel.class);
3640
public static final IpdataField<Integer> COUNT = new IpdataField<Integer>("count", Integer.class);
3741
private final String name;
3842
private final Class<T> type;

src/main/java/io/ipdata/client/service/IpdataInternalSingleFieldClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ interface IpdataInternalSingleFieldClient {
4040
@RequestLine("GET /{ip}/postal")
4141
String getPostal(@Param(value = "ip", encoded = true) String ip) throws IpdataException;
4242

43-
@RequestLine("GET /{ip}/asn")
43+
@RequestLine("GET /{ip}/calling_code")
4444
String getCallingCode(@Param(value = "ip", encoded = true) String ip) throws IpdataException;
4545

4646
@RequestLine("GET /{ip}/flag")

src/test/java/io/ipdata/client/AsnTest.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,19 @@
55
import io.ipdata.client.model.AsnModel;
66
import io.ipdata.client.service.IpdataService;
77
import lombok.SneakyThrows;
8-
import org.apache.http.conn.ssl.NoopHostnameVerifier;
98
import org.apache.http.impl.client.HttpClientBuilder;
109
import org.junit.Test;
1110
import org.junit.runner.RunWith;
1211
import org.junit.runners.Parameterized;
1312

14-
import java.net.URL;
1513
import java.util.concurrent.TimeUnit;
1614

1715
import static org.junit.Assert.assertNotNull;
1816

1917
@RunWith(Parameterized.class)
2018
public class AsnTest {
2119

22-
private static final TestContext TEST_CONTEXT = new TestContext("https://api.ipdata.co");
20+
private static final TestContext TEST_CONTEXT = new TestContext(MockIpdataServer.API_KEY, MockIpdataServer.getInstance().getUrl());
2321

2422
@Parameterized.Parameter
2523
public TestFixture fixture;
@@ -45,12 +43,11 @@ public void testASN() {
4543
@SneakyThrows
4644
@Test(expected = IpdataException.class)
4745
public void testAsnError() {
48-
URL url = new URL("https://api.ipdata.co");
49-
IpdataService serviceWithInvalidKey = Ipdata.builder().url(url)
46+
IpdataService serviceWithInvalidKey = Ipdata.builder().url(TEST_CONTEXT.url())
5047
.key("THIS_IS_AN_INVALID_KEY")
5148
.withDefaultCache()
5249
.feignClient(new ApacheHttpClient(HttpClientBuilder.create()
53-
.setSSLHostnameVerifier(new NoopHostnameVerifier()).setConnectionTimeToLive(10, TimeUnit.SECONDS)
50+
.setConnectionTimeToLive(10, TimeUnit.SECONDS)
5451
.build())
5552
).get();
5653
serviceWithInvalidKey.asn(fixture.target());

src/test/java/io/ipdata/client/BulkTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
@RunWith(Parameterized.class)
1616
public class BulkTest {
1717

18-
private static final TestContext TEST_CONTEXT = new TestContext("https://api.ipdata.co");
18+
private static final TestContext TEST_CONTEXT = new TestContext(MockIpdataServer.API_KEY, MockIpdataServer.getInstance().getUrl());
1919

2020
@Parameterized.Parameter
2121
public IpdataService ipdataService;

src/test/java/io/ipdata/client/CurrencyTest.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@
55
import io.ipdata.client.model.Currency;
66
import io.ipdata.client.service.IpdataService;
77
import lombok.SneakyThrows;
8-
import org.apache.http.conn.ssl.NoopHostnameVerifier;
98
import org.apache.http.impl.client.HttpClientBuilder;
109
import org.junit.Test;
1110
import org.junit.runner.RunWith;
1211
import org.junit.runners.Parameterized;
1312

14-
import java.net.URL;
1513
import java.util.concurrent.TimeUnit;
1614

1715
@RunWith(Parameterized.class)
1816
public class CurrencyTest {
1917

20-
private static final TestContext TEST_CONTEXT = new TestContext("https://api.ipdata.co");
18+
private static final TestContext TEST_CONTEXT = new TestContext(MockIpdataServer.API_KEY, MockIpdataServer.getInstance().getUrl());
2119

2220
@Parameterized.Parameter
2321
public TestFixture fixture;
@@ -41,12 +39,11 @@ public void testCurrency() {
4139
@SneakyThrows
4240
@Test(expected = IpdataException.class)
4341
public void testCurrencyError() {
44-
URL url = new URL("https://api.ipdata.co");
45-
IpdataService serviceWithInvalidKey = Ipdata.builder().url(url)
42+
IpdataService serviceWithInvalidKey = Ipdata.builder().url(TEST_CONTEXT.url())
4643
.key("THIS_IS_AN_INVALID_KEY")
4744
.withDefaultCache()
4845
.feignClient(new ApacheHttpClient(HttpClientBuilder.create()
49-
.setSSLHostnameVerifier(new NoopHostnameVerifier()).setConnectionTimeToLive(10, TimeUnit.SECONDS)
46+
.setConnectionTimeToLive(10, TimeUnit.SECONDS)
5047
.build())
5148
).get();
5249
serviceWithInvalidKey.currency(fixture.target());

0 commit comments

Comments
 (0)