From 28bb5baa5197cd23ad7f666cbb9223d1392e48b6 Mon Sep 17 00:00:00 2001 From: James Rosewell Date: Fri, 12 Jun 2026 16:24:35 +0100 Subject: [PATCH 1/3] Remove device detection leftovers from the port Cleans up naming and comments copied unchanged from the device-detection-java codebase. Internal identifiers are renamed to IP Intelligence terms (deviceMap to propertyMap and DEVICE_LIST_KEY to PROFILE_LIST_KEY in the cloud engine and MultiIPIDataCloud, the UserAgentGenerator test helper to IpAddressGenerator) and javadoc, log messages and README wording now describe IP Intelligence rather than device detection. Deletes dead test code from the port. Builder.java duplicated the existing BuilderTests.java, MetaDataTests.java in the shared module was an unreferenced helper without tests, and ClientHintsExampleTestBase only applied to User-Agent Client Hints. Public API names with device detection heritage, such as HardwareProfileCloudEngine and the TAC evidence constant, are part of the IP Intelligence cloud specification and are unchanged. --- README.md | 4 +- ci/README.md | 6 +- .../cloud/data/MultiIPIDataCloud.java | 21 ++-- .../HardwareProfileCloudEngine.java | 3 +- .../IPIntelligenceCloudEngine.java | 115 +++++++++--------- .../ipintelligence/cloud/TestsBase.java | 10 +- .../ipintelligence/cloud/ValueTests.java | 12 +- .../cloud/data/ValueCloudTests.java | 7 +- .../MissingPropertyHandlingTests.java | 18 ++- .../IPIntelligenceDataHashDefault.java | 8 -- .../IPIntelligenceOnPremiseEngine.java | 18 +-- .../IPIntelligenceOnPremiseEngineBuilder.java | 13 +- .../engine/onpremise/TestsBase.java | 10 +- .../engine/onpremise/data/ValueHashTests.java | 10 +- .../onpremise/flowelements/Builder.java | 49 -------- .../onpremise/flowelements/EngineTests.java | 8 +- .../flowelements/EvidenceKeysTests.java | 8 +- .../flowelements/TestProcessTests.java | 12 +- .../shared/testhelpers/FileUtils.java | 3 +- .../ipintelligence/shared/MetaDataTests.java | 93 -------------- .../ClientHintsExampleTestBase.java | 80 ------------ ...Generator.java => IpAddressGenerator.java} | 24 ++-- .../shared/testhelpers/data/ValueTests.java | 4 +- .../flowelements/ProcessTests.java | 2 +- .../IPIntelligenceCloudPipelineBuilder.java | 8 +- ...PIntelligenceOnPremisePipelineBuilder.java | 19 +-- .../IPIntelligencePipelineBuilder.java | 2 +- .../CloudRequestOriginTests.java | 8 +- ...elligenceOnPremisePipelineBuilderTest.java | 6 +- .../ipintelligence/IPIntelligenceTests.java | 45 ++----- 30 files changed, 182 insertions(+), 444 deletions(-) delete mode 100644 ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/flowelements/Builder.java delete mode 100644 ip-intelligence.shared/src/test/java/fiftyone/ipintelligence/shared/MetaDataTests.java delete mode 100644 ip-intelligence.shared/src/test/java/fiftyone/ipintelligence/shared/testhelpers/ClientHintsExampleTestBase.java rename ip-intelligence.shared/src/test/java/fiftyone/ipintelligence/shared/testhelpers/{UserAgentGenerator.java => IpAddressGenerator.java} (81%) diff --git a/README.md b/README.md index 4233d898..bdaea895 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,6 @@ For tests and examples that require a license key add the following option: ## Projects - **ip-intelligence** - Main package providing all IP Intelligence capabilities including both cloud and on-premise engines. -- **ip-intelligence.engine.on-premise** - On-premise detection engine using local data files for IP intelligence analysis. -- **ip-intelligence.cloud** - Cloud-based detection service for IP intelligence (coming soon). +- **ip-intelligence.engine.on-premise** - On-premise engine using local data files for IP intelligence analysis. +- **ip-intelligence.cloud** - Cloud-based IP intelligence engine (coming soon). - **ip-intelligence.shared** - Shared classes and utilities used across all IP intelligence engines. diff --git a/ci/README.md b/ci/README.md index f9800088..38eea431 100644 --- a/ci/README.md +++ b/ci/README.md @@ -22,8 +22,8 @@ The following secrets are required for publishing releases (this should only be * `CODE_SIGNING_CERT_PASSWORD` - Password for the `CODE_SIGNING_CERT` The following secrets are optional: -* `DEVICE_DETECTION_URL` - URL for downloading the enterprise TAC hash file - * Default: `https://distributor.51degrees.com/api/v2/download?LicenseKeys=DEVICE_DETECTION_KEY&Type=HashV41&Download=True&Product=V4TAC` +* `IPI_DATA_FILE_URL` - URL for downloading the enterprise IPI data file + * Default: the 51Degrees Distributor URL using the `DEVICE_DETECTION_KEY` license key ## Integration Tests @@ -48,7 +48,7 @@ graph TD It performs the following steps: 1. Clone Examples Repo: Clone the "ip-intelligence-java-examples" repository into the common-ci directory. -3. Set up test files: Move the 51Degrees-EnterpriseIpiV41.ipi file to the ip-intelligence-java-examples/ip-intelligence-data directory and download Evidence and User-Agent files into ip-intelligence-data directory. +3. Set up test files: Move the 51Degrees-EnterpriseIpiV41.ipi file to the ip-intelligence-java-examples/ip-intelligence-data directory and download Evidence files into ip-intelligence-data directory. 4. Enter ip-intelligence-examples directory: Changes the current working directory to the ip-intelligence-java-examples folder. 5. Set package dependency version: Sets the version of the ip-intelligence package dependency for the examples to the specified Version parameter. This will be the version installed in the local repository found in the .m2 folder. 6. Test Examples: Runs the Maven clean test command, passing the TestResourceKey, SuperResourceKey, and LicenseKey as parameters. diff --git a/ip-intelligence.cloud/src/main/java/fiftyone/ipintelligence/cloud/data/MultiIPIDataCloud.java b/ip-intelligence.cloud/src/main/java/fiftyone/ipintelligence/cloud/data/MultiIPIDataCloud.java index cf0dba4c..bd6d870b 100644 --- a/ip-intelligence.cloud/src/main/java/fiftyone/ipintelligence/cloud/data/MultiIPIDataCloud.java +++ b/ip-intelligence.cloud/src/main/java/fiftyone/ipintelligence/cloud/data/MultiIPIDataCloud.java @@ -38,12 +38,13 @@ /** * Encapsulates a list of {@link IPIntelligenceData} instances which can be returned - * by the 51Degrees Cloud service when certain evidence is provided (e.g. TAC) + * by the 51Degrees Cloud service when evidence matching multiple profiles is + * provided. */ public class MultiIPIDataCloud extends AspectDataBase implements MultiProfileData { - private static final String DEVICE_LIST_KEY = "profiles"; + private static final String PROFILE_LIST_KEY = "profiles"; /** * Constructs a new instance with a non-thread-safe, case-insensitive @@ -58,7 +59,7 @@ public MultiIPIDataCloud( FlowData flowData, AspectEngine engine) { super(logger, flowData, engine); - this.put(DEVICE_LIST_KEY, new ArrayList()); + this.put(PROFILE_LIST_KEY, new ArrayList()); } /** @@ -77,25 +78,25 @@ public MultiIPIDataCloud( AspectEngine engine, MissingPropertyService missingPropertyService) { super(logger, flowData, engine, missingPropertyService); - this.put(DEVICE_LIST_KEY, new ArrayList()); + this.put(PROFILE_LIST_KEY, new ArrayList()); } @Override public List getProfiles() { - return getDeviceList(); + return getProfileList(); } @Override public void addProfile(IPIntelligenceData profile) { - getDeviceList().add(profile); + getProfileList().add(profile); } /** - * Internal method to get the list of devices form the underlying data. - * @return the list of devices form the underlying data. + * Internal method to get the list of profiles from the underlying data. + * @return the list of profiles from the underlying data. */ @SuppressWarnings("unchecked") - private List getDeviceList() { - return (List)this.get(DEVICE_LIST_KEY); + private List getProfileList() { + return (List)this.get(PROFILE_LIST_KEY); } } diff --git a/ip-intelligence.cloud/src/main/java/fiftyone/ipintelligence/cloud/flowelements/HardwareProfileCloudEngine.java b/ip-intelligence.cloud/src/main/java/fiftyone/ipintelligence/cloud/flowelements/HardwareProfileCloudEngine.java index 35d7a581..bf288c8e 100644 --- a/ip-intelligence.cloud/src/main/java/fiftyone/ipintelligence/cloud/flowelements/HardwareProfileCloudEngine.java +++ b/ip-intelligence.cloud/src/main/java/fiftyone/ipintelligence/cloud/flowelements/HardwareProfileCloudEngine.java @@ -33,7 +33,8 @@ /** * Engine that takes the JSON response from the {@link CloudRequestEngine} and - * uses it populate a {@link MultiIPIDataCloud} instance for easier consumption. + * uses it to populate a {@link MultiIPIDataCloud} instance for easier + * consumption. * @see Specification */ public class HardwareProfileCloudEngine diff --git a/ip-intelligence.cloud/src/main/java/fiftyone/ipintelligence/cloud/flowelements/IPIntelligenceCloudEngine.java b/ip-intelligence.cloud/src/main/java/fiftyone/ipintelligence/cloud/flowelements/IPIntelligenceCloudEngine.java index 73c25c7e..c699ea8f 100644 --- a/ip-intelligence.cloud/src/main/java/fiftyone/ipintelligence/cloud/flowelements/IPIntelligenceCloudEngine.java +++ b/ip-intelligence.cloud/src/main/java/fiftyone/ipintelligence/cloud/flowelements/IPIntelligenceCloudEngine.java @@ -50,7 +50,8 @@ /** * Engine that takes the JSON response from the {@link CloudRequestEngine} and - * uses it populate a {@link IPIntelligenceDataCloud} instance for easier consumption. + * uses it to populate a {@link IPIntelligenceDataCloud} instance for easier + * consumption. * @see Specification */ public class IPIntelligenceCloudEngine @@ -62,13 +63,13 @@ public class IPIntelligenceCloudEngine /** * Construct a new instance of the {@link IPIntelligenceCloudEngine}. * @param logger logger instance to use for logging - * @param IPIDataFactory the factory to use when creating a + * @param ipiDataFactory the factory to use when creating a * {@link IPIntelligenceDataCloud} instance */ public IPIntelligenceCloudEngine( Logger logger, - ElementDataFactory IPIDataFactory) { - super(logger, IPIDataFactory); + ElementDataFactory ipiDataFactory) { + super(logger, ipiDataFactory); this.cloudRequestEngine = null; } @@ -111,71 +112,71 @@ protected void processEngine(FlowData data, IPIntelligenceDataCloud aspectData) // Extract data from json to the aspectData instance. JSONObject jsonObj = new JSONObject(json); - JSONObject deviceObj = jsonObj.getJSONObject("ip-intelligence"); + JSONObject ipiObj = jsonObj.getJSONObject("ip-intelligence"); - Map deviceMap = + Map propertyMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); for (AspectPropertyMetaData property : getProperties()) { String type = property.getType().getSimpleName(); switch(type) { case ("List"): - deviceMap.put( + propertyMap.put( property.getName(), - getListAspectPropertyValue(deviceObj, property)); + getListAspectPropertyValue(ipiObj, property)); break; case ("JavaScript"): - deviceMap.put( + propertyMap.put( property.getName(), - getJavaScriptAspectPropertyValue(deviceObj, property)); + getJavaScriptAspectPropertyValue(ipiObj, property)); break; case ("String"): - deviceMap.put( + propertyMap.put( property.getName(), - getStringAspectPropertyValue(deviceObj, property)); + getStringAspectPropertyValue(ipiObj, property)); break; case ("boolean"): - deviceMap.put( + propertyMap.put( property.getName(), - getBooleanAspectPropertyValue(deviceObj, property)); + getBooleanAspectPropertyValue(ipiObj, property)); break; case ("int"): - deviceMap.put( + propertyMap.put( property.getName(), - getIntegerAspectPropertyValue(deviceObj, property)); + getIntegerAspectPropertyValue(ipiObj, property)); break; case ("double"): - deviceMap.put( + propertyMap.put( property.getName(), - getDoubleAspectPropertyValue(deviceObj, property)); + getDoubleAspectPropertyValue(ipiObj, property)); break; default: - deviceMap.put( + propertyMap.put( property.getName(), - getStringAspectPropertyValue(deviceObj, property)); + getStringAspectPropertyValue(ipiObj, property)); break; } } // Add no value messages for any properties which have not yet been // populated. - for (String key : deviceObj.keySet()) { + for (String key : ipiObj.keySet()) { if (key.endsWith("nullreason")) { String actualKey = key .replace("nullreason", ""); - if (deviceMap.containsKey(actualKey) == false) { + if (propertyMap.containsKey(actualKey) == false) { AspectPropertyValue nullValue = new AspectPropertyValueDefault(); nullValue.setNoValueMessage( - deviceObj.optString(key, "Unknown")); - deviceMap.put( + ipiObj.optString(key, "Unknown")); + propertyMap.put( actualKey, nullValue); } } } - aspectData.populateFromMap(deviceMap); + aspectData.populateFromMap(propertyMap); } } @@ -237,33 +238,33 @@ private boolean loadAspectProperties(CloudRequestEngine engine) { /** * Get the integer representation of a value from the cloud engine's JSON * response, and wrap it in an {@link AspectPropertyValue}. - * @param deviceObj to get the value from + * @param ipiObj to get the value from * @param property to get the value of * @return {@link AspectPropertyValue} with a parsed value, or the reason * for the value not being present */ private AspectPropertyValue getIntegerAspectPropertyValue( - JSONObject deviceObj, + JSONObject ipiObj, AspectPropertyMetaData property) { String key = property.getName().toLowerCase(); AspectPropertyValue intValue = new AspectPropertyValueDefault<>(); - if(deviceObj.isNull(key)){ - intValue.setNoValueMessage(getNoValueReason(deviceObj, key)); + if(ipiObj.isNull(key)){ + intValue.setNoValueMessage(getNoValueReason(ipiObj, key)); } else { - intValue.setValue(deviceObj.getInt(key)); + intValue.setValue(ipiObj.getInt(key)); } return intValue; } - private AspectPropertyValue getDoubleAspectPropertyValue(JSONObject deviceObj, AspectPropertyMetaData property) { + private AspectPropertyValue getDoubleAspectPropertyValue(JSONObject ipiObj, AspectPropertyMetaData property) { String key = property.getName().toLowerCase(); AspectPropertyValue doubleValue = new AspectPropertyValueDefault<>(); - if(deviceObj.isNull(key)){ - doubleValue.setNoValueMessage(getNoValueReason(deviceObj, key)); + if(ipiObj.isNull(key)){ + doubleValue.setNoValueMessage(getNoValueReason(ipiObj, key)); } else { - doubleValue.setValue(deviceObj.getDouble(key)); + doubleValue.setValue(ipiObj.getDouble(key)); } return doubleValue; } @@ -271,21 +272,21 @@ private AspectPropertyValue getDoubleAspectPropertyValue(JSONObject devi /** * Get the boolean representation of a value from the cloud engine's JSON * response, and wrap it in an {@link AspectPropertyValue}. - * @param deviceObj to get the value from + * @param ipiObj to get the value from * @param property to get the value of * @return {@link AspectPropertyValue} with a parsed value, or the reason * for the value not being present */ private AspectPropertyValue getBooleanAspectPropertyValue( - JSONObject deviceObj, + JSONObject ipiObj, AspectPropertyMetaData property) { String key = property.getName().toLowerCase(); AspectPropertyValue booleanValue = new AspectPropertyValueDefault<>(); - if(deviceObj.isNull(key)){ - booleanValue.setNoValueMessage(getNoValueReason(deviceObj, key)); + if(ipiObj.isNull(key)){ + booleanValue.setNoValueMessage(getNoValueReason(ipiObj, key)); } else { - booleanValue.setValue(deviceObj.getBoolean(key)); + booleanValue.setValue(ipiObj.getBoolean(key)); } return booleanValue; } @@ -293,23 +294,23 @@ private AspectPropertyValue getBooleanAspectPropertyValue( /** * Get the string list representation of a value from the cloud engine's * JSON response, and wrap it in an {@link AspectPropertyValue}. - * @param deviceObj to get the value from + * @param ipiObj to get the value from * @param property to get the value of * @return {@link AspectPropertyValue} with a parsed value, or the reason * for the value not being present */ private AspectPropertyValue> getListAspectPropertyValue( - JSONObject deviceObj, + JSONObject ipiObj, AspectPropertyMetaData property){ String key = property.getName().toLowerCase(); AspectPropertyValue> listValue = new AspectPropertyValueDefault<>(); - if(deviceObj.isNull(key)) + if(ipiObj.isNull(key)) { - listValue.setNoValueMessage(getNoValueReason(deviceObj, key)); + listValue.setNoValueMessage(getNoValueReason(ipiObj, key)); } else { - JSONArray jsonArray = deviceObj.getJSONArray(key); + JSONArray jsonArray = ipiObj.getJSONArray(key); List strings = new ArrayList<>(jsonArray.length()); for (Object object : jsonArray.toList()) { strings.add(Objects.toString(object, null)); @@ -322,20 +323,20 @@ private AspectPropertyValue> getListAspectPropertyValue( /** * Get the JavaScript representation of a value from the cloud engine's JSON * response, and wrap it in an {@link AspectPropertyValue}. - * @param deviceObj to get the value from + * @param ipiObj to get the value from * @param property to get the value of * @return {@link AspectPropertyValue} with a parsed value, or the reason * for the value not being present */ private AspectPropertyValue getJavaScriptAspectPropertyValue( - JSONObject deviceObj, + JSONObject ipiObj, AspectPropertyMetaData property){ String key = property.getName().toLowerCase(); AspectPropertyValue jsValue = new AspectPropertyValueDefault<>(); - if(deviceObj.isNull(key)){ - jsValue.setNoValueMessage(getNoValueReason(deviceObj, key)); + if(ipiObj.isNull(key)){ + jsValue.setNoValueMessage(getNoValueReason(ipiObj, key)); } else { - jsValue.setValue(new JavaScript(deviceObj.getString(key))); + jsValue.setValue(new JavaScript(ipiObj.getString(key))); } return jsValue; } @@ -343,21 +344,21 @@ private AspectPropertyValue getJavaScriptAspectPropertyValue( /** * Get the string representation of a value from the cloud engine's JSON * response, and wrap it in an {@link AspectPropertyValue}. - * @param deviceObj to get the value from + * @param ipiObj to get the value from * @param property to get the value of * @return {@link AspectPropertyValue} with a parsed value, or the reason * for the value not being present */ private AspectPropertyValue getStringAspectPropertyValue( - JSONObject deviceObj, + JSONObject ipiObj, AspectPropertyMetaData property){ String key = property.getName().toLowerCase(); AspectPropertyValue stringValue = new AspectPropertyValueDefault<>(); - if(deviceObj.isNull(key)){ - stringValue.setNoValueMessage(getNoValueReason(deviceObj, key)); + if(ipiObj.isNull(key)){ + stringValue.setNoValueMessage(getNoValueReason(ipiObj, key)); } else { - stringValue.setValue(deviceObj.getString(key)); + stringValue.setValue(ipiObj.getString(key)); } return stringValue; } @@ -365,12 +366,12 @@ private AspectPropertyValue getStringAspectPropertyValue( /** * Get the reason for the value of a property not being present in the cloud * engine's JSON response. - * @param deviceObj to get the null reason from + * @param ipiObj to get the null reason from * @param key to get the null reason from * @return the reason for the missing property */ - private String getNoValueReason(JSONObject deviceObj, String key){ - Object reason = tryToGet(deviceObj, key + "nullreason"); + private String getNoValueReason(JSONObject ipiObj, String key){ + Object reason = tryToGet(ipiObj, key + "nullreason"); return reason == null ? null : reason.toString(); } diff --git a/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/TestsBase.java b/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/TestsBase.java index 2887e503..3bda7e26 100644 --- a/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/TestsBase.java +++ b/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/TestsBase.java @@ -22,7 +22,7 @@ package fiftyone.ipintelligence.cloud; -import fiftyone.ipintelligence.shared.testhelpers.UserAgentGenerator; +import fiftyone.ipintelligence.shared.testhelpers.IpAddressGenerator; import fiftyone.pipeline.util.FileFinder; import static fiftyone.ipintelligence.shared.testhelpers.FileUtils.IP_ADDRESSES_FILE_NAME; @@ -30,19 +30,19 @@ public class TestsBase { private WrapperCloud wrapper = null; - private UserAgentGenerator userAgents; + private IpAddressGenerator ipAddresses; protected WrapperCloud getWrapper() { return wrapper; } - protected UserAgentGenerator getUserAgents() { - return userAgents; + protected IpAddressGenerator getIpAddresses() { + return ipAddresses; } protected void testInitialize() throws Exception { wrapper = new WrapperCloud(); - userAgents = new UserAgentGenerator( + ipAddresses = new IpAddressGenerator( FileFinder.getFilePath(IP_ADDRESSES_FILE_NAME)); } diff --git a/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/ValueTests.java b/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/ValueTests.java index 6948c7aa..3b7ee8bb 100644 --- a/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/ValueTests.java +++ b/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/ValueTests.java @@ -41,16 +41,16 @@ public class ValueTests { - public static void deviceId(WrapperCloud wrapper) throws Exception { + public static void registeredName(WrapperCloud wrapper) throws Exception { try (FlowData data = wrapper.getPipeline().createFlowData()) { data.addEvidence("server.client-ip", Constants.IPV4_ADDRESS) .process(); ElementData elementData = data.get(wrapper.getEngine().getElementDataKey()); - IPIntelligenceData device = (IPIntelligenceData) elementData; - assertNotNull("The device id should not be null.", - device.getRegisteredName().getValue()); - assertFalse("The device id should not be empty.", - device.getRegisteredName().getValue().isEmpty()); + IPIntelligenceData ipiData = (IPIntelligenceData) elementData; + assertNotNull("The registered name should not be null.", + ipiData.getRegisteredName().getValue()); + assertFalse("The registered name should not be empty.", + ipiData.getRegisteredName().getValue().isEmpty()); } } diff --git a/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/data/ValueCloudTests.java b/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/data/ValueCloudTests.java index 3c70c65f..83cb2b82 100644 --- a/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/data/ValueCloudTests.java +++ b/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/data/ValueCloudTests.java @@ -24,7 +24,6 @@ import fiftyone.ipintelligence.cloud.TestsBase; import fiftyone.ipintelligence.cloud.ValueTests; -import fiftyone.ipintelligence.shared.testhelpers.UserAgentGenerator; import org.junit.After; import org.junit.Before; @@ -34,8 +33,6 @@ @Ignore public class ValueCloudTests extends TestsBase { - private UserAgentGenerator userAgents; - @Before public void init() throws Exception { testInitialize(); @@ -62,8 +59,8 @@ public void ValueTests_Cloud_TypedGetters() throws Exception { } @Test - public void ValueTests_Cloud_DeviceId() throws Exception { - ValueTests.deviceId(getWrapper()); + public void ValueTests_Cloud_RegisteredName() throws Exception { + ValueTests.registeredName(getWrapper()); } } diff --git a/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/flowelements/MissingPropertyHandlingTests.java b/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/flowelements/MissingPropertyHandlingTests.java index 220c2d6e..fa7ec56f 100644 --- a/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/flowelements/MissingPropertyHandlingTests.java +++ b/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/flowelements/MissingPropertyHandlingTests.java @@ -78,7 +78,6 @@ public void PropertyInResource_NullValue() throws Exception { engine.aspectProperties = properties; engine.processEngine(flowData, ipiData); - // TODO: Select fitting property. Was `getPriceBand` AspectPropertyValue latitude = ipiData.getLatitude(); assertNotNull(latitude); assertFalse(latitude.hasValue()); @@ -123,8 +122,7 @@ public void PropertyNotInResource() throws Exception { engine.processEngine(flowData, ipiData); try { - // TODO: Select fitting property. Was `getDeviceType` - AspectPropertyValue deviceType = ipiData.getLongitude(); + AspectPropertyValue longitude = ipiData.getLongitude(); fail("A PropertyMissingException should have been thrown"); } catch (PropertyMissingException e) { assertEquals( @@ -139,11 +137,11 @@ public void PropertyNotInResource() throws Exception { private static String nullValueJson = "{\n" + - " 'device': {\n" + - " 'platformname': 'Windows',\n" + - " 'platformversion': '10.0',\n" + - " 'priceband': null,\n" + - " 'pricebandnullreason': '" + expectedNullReason + "'\n" + + " 'ip-intelligence': {\n" + + " 'registeredname': 'Example Network',\n" + + " 'registeredcountry': 'US',\n" + + " 'latitude': null,\n" + + " 'latitudenullreason': '" + expectedNullReason + "'\n" + " },\n" + " 'javascriptProperties': []\n" + "}\n"; @@ -156,8 +154,8 @@ public void PropertyNotInResource() throws Exception { private static final long serialVersionUID = -819525441539357267L; { - add(new AspectPropertyMetaDataDefault("platformname", null, null, String.class, null, true)); - add(new AspectPropertyMetaDataDefault("platformversion", null, null, String.class, null, true)); + add(new AspectPropertyMetaDataDefault("registeredname", null, null, String.class, null, true)); + add(new AspectPropertyMetaDataDefault("registeredcountry", null, null, String.class, null, true)); } }; diff --git a/ip-intelligence.engine.on-premise/src/main/java/fiftyone/ipintelligence/engine/onpremise/flowelements/IPIntelligenceDataHashDefault.java b/ip-intelligence.engine.on-premise/src/main/java/fiftyone/ipintelligence/engine/onpremise/flowelements/IPIntelligenceDataHashDefault.java index 572d174d..6baf8af0 100644 --- a/ip-intelligence.engine.on-premise/src/main/java/fiftyone/ipintelligence/engine/onpremise/flowelements/IPIntelligenceDataHashDefault.java +++ b/ip-intelligence.engine.on-premise/src/main/java/fiftyone/ipintelligence/engine/onpremise/flowelements/IPIntelligenceDataHashDefault.java @@ -22,7 +22,6 @@ package fiftyone.ipintelligence.engine.onpremise.flowelements; -import fiftyone.ipintelligence.engine.onpremise.Enums; import fiftyone.ipintelligence.engine.onpremise.data.IPIntelligenceDataHash; import fiftyone.ipintelligence.engine.onpremise.interop.swig.*; import fiftyone.ipintelligence.shared.IPIntelligenceDataBaseOnPremise; @@ -63,13 +62,6 @@ public class IPIntelligenceDataHashDefault */ private boolean closed = false; - /** - * Pre-populated list of match methods. This to avoid calling the - * '.values()' method every time. - */ - private static final Enums.MatchMethods[] matchMethods = - Enums.MatchMethods.values(); - /** * List of native results which make up this result instance. Usually, this * will only be one. diff --git a/ip-intelligence.engine.on-premise/src/main/java/fiftyone/ipintelligence/engine/onpremise/flowelements/IPIntelligenceOnPremiseEngine.java b/ip-intelligence.engine.on-premise/src/main/java/fiftyone/ipintelligence/engine/onpremise/flowelements/IPIntelligenceOnPremiseEngine.java index 284749b5..debeda39 100644 --- a/ip-intelligence.engine.on-premise/src/main/java/fiftyone/ipintelligence/engine/onpremise/flowelements/IPIntelligenceOnPremiseEngine.java +++ b/ip-intelligence.engine.on-premise/src/main/java/fiftyone/ipintelligence/engine/onpremise/flowelements/IPIntelligenceOnPremiseEngine.java @@ -45,9 +45,9 @@ import static org.apache.commons.lang3.BooleanUtils.isFalse; /** - * On-premise IP Intelligence engine. This engine takes User-Agents and other - * relevant HTTP headers and returns properties about the device which produced - * them e.g. DeviceType or ReleaseDate. + * On-premise IP Intelligence engine. This engine takes an IP address as + * evidence and returns properties about the network and location associated + * with it e.g. RegisteredName or CountryCode. * @see Specification */ public class IPIntelligenceOnPremiseEngine @@ -70,7 +70,7 @@ public class IPIntelligenceOnPremiseEngine * @param properties native required properties configuration which define * the properties which the engine should be initialised * with - * @param IPIDataFactory the factory to use when creating a + * @param ipiDataFactory the factory to use when creating a * {@link IPIntelligenceDataHash} instance * @param tempDataFileDir the file where a temporary data file copy * will be stored if one is created @@ -80,9 +80,9 @@ public class IPIntelligenceOnPremiseEngine AspectEngineDataFile dataFile, ConfigIpiSwig config, RequiredPropertiesConfigSwig properties, - ElementDataFactory IPIDataFactory, + ElementDataFactory ipiDataFactory, String tempDataFileDir) { - super(logger, IPIDataFactory, tempDataFileDir); + super(logger, ipiDataFactory, tempDataFileDir); this.config = config; this.propertiesConfigSwig = properties; addDataFile(dataFile); @@ -293,7 +293,7 @@ public void refreshData(String dataFileIdentifier, byte[] data) { } @Override - protected void processEngine(FlowData flowData, IPIntelligenceDataHash IPIData) { + protected void processEngine(FlowData flowData, IPIntelligenceDataHash ipiData) { try (EvidenceIpiSwig relevantEvidence = new EvidenceIpiSwig()) { List keys = evidenceKeys; @@ -313,7 +313,7 @@ protected void processEngine(FlowData flowData, IPIntelligenceDataHash IPIData) evidenceItem.getValue().toString()); } } - ((IPIntelligenceDataHashDefault) IPIData).setResults( + ((IPIntelligenceDataHashDefault) ipiData).setResults( engine.process(relevantEvidence)); } } @@ -366,7 +366,7 @@ public void addDataFile(AspectEngineDataFile dataFile) { super.addDataFile(dataFile); if (dataFile instanceof FiftyOneDataFile) { FiftyOneDataFile fiftyOneDataFile = (FiftyOneDataFile)dataFile; - fiftyOneDataFile.setDataUpdateDownloadType("HashV41"); + fiftyOneDataFile.setDataUpdateDownloadType("IPIV41"); } } diff --git a/ip-intelligence.engine.on-premise/src/main/java/fiftyone/ipintelligence/engine/onpremise/flowelements/IPIntelligenceOnPremiseEngineBuilder.java b/ip-intelligence.engine.on-premise/src/main/java/fiftyone/ipintelligence/engine/onpremise/flowelements/IPIntelligenceOnPremiseEngineBuilder.java index 5dd86d47..ff6cf2d3 100644 --- a/ip-intelligence.engine.on-premise/src/main/java/fiftyone/ipintelligence/engine/onpremise/flowelements/IPIntelligenceOnPremiseEngineBuilder.java +++ b/ip-intelligence.engine.on-premise/src/main/java/fiftyone/ipintelligence/engine/onpremise/flowelements/IPIntelligenceOnPremiseEngineBuilder.java @@ -51,7 +51,7 @@ * Builder for the {@link IPIntelligenceOnPremiseEngine}. All options for the engine * should be set here. *

- * Default values are taken from ip-intelligence-cxx/src/hash/hash.c + * Default values are taken from ip-intelligence-cxx/src/ipi.c */ @ElementBuilder(alternateName = "HashIPIntelligence") public class IPIntelligenceOnPremiseEngineBuilder @@ -59,7 +59,7 @@ public class IPIntelligenceOnPremiseEngineBuilder IPIntelligenceOnPremiseEngineBuilder, IPIntelligenceOnPremiseEngine> { - private final String dataDownloadType = "HashV41"; + private final String dataDownloadType = "IPIV41"; /** * Native configuration instance for this engine. @@ -171,8 +171,7 @@ public IPIntelligenceOnPremiseEngineBuilder setPerformanceProfile( /** * Provide a hint as to how many threads will access the pipeline simultaneously *

- * Default is the result of {@link Runtime#getRuntime()#getAvailableProcessors()} - * @see Concurrent processing + * Default is the result of {@link Runtime#availableProcessors()} * @param concurrency expected concurrent accesses * @return this builder */ @@ -239,16 +238,16 @@ protected IPIntelligenceOnPremiseEngine newEngine(List properties) { dataFile, config, requiredProperties, - new HashDataFactory(loggerFactory), + new IpiDataFactory(loggerFactory), tempDir); } - private static class HashDataFactory implements + private static class IpiDataFactory implements ElementDataFactory { private final ILoggerFactory loggerFactory; - public HashDataFactory(ILoggerFactory loggerFactory) { + public IpiDataFactory(ILoggerFactory loggerFactory) { this.loggerFactory = loggerFactory; } diff --git a/ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/TestsBase.java b/ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/TestsBase.java index aa3dbf19..a9820e48 100644 --- a/ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/TestsBase.java +++ b/ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/TestsBase.java @@ -22,7 +22,7 @@ package fiftyone.ipintelligence.engine.onpremise; -import fiftyone.ipintelligence.shared.testhelpers.UserAgentGenerator; +import fiftyone.ipintelligence.shared.testhelpers.IpAddressGenerator; import fiftyone.ipintelligence.shared.testhelpers.FileUtils; import fiftyone.pipeline.engines.Constants; @@ -32,21 +32,21 @@ public class TestsBase { private WrapperHash wrapper = null; - private UserAgentGenerator userAgents; + private IpAddressGenerator ipAddresses; protected WrapperHash getWrapper() { return wrapper; } - protected UserAgentGenerator getUserAgents() { - return userAgents; + protected IpAddressGenerator getIpAddresses() { + return ipAddresses; } protected void testInitialize(Constants.PerformanceProfiles profile) throws Exception { wrapper = new WrapperHash( FileUtils.getHashFile(), profile); - userAgents = new UserAgentGenerator( + ipAddresses = new IpAddressGenerator( getFilePath(IP_ADDRESSES_FILE_NAME)); } diff --git a/ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/data/ValueHashTests.java b/ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/data/ValueHashTests.java index cb15f026..0fc9cbbe 100644 --- a/ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/data/ValueHashTests.java +++ b/ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/data/ValueHashTests.java @@ -43,22 +43,22 @@ public void cleanup() { } @Test - public void Values_Hash_ValueTypes() throws Exception { + public void Values_Ipi_ValueTypes() throws Exception { ValueTests.valueTypes(getWrapper()); } @Test - public void Values_Hash_AvailableProperties() throws Exception { + public void Values_Ipi_AvailableProperties() throws Exception { ValueTests.availableProperties(getWrapper()); } @Test - public void Values_Hash_TypedGetters() throws Exception { + public void Values_Ipi_TypedGetters() throws Exception { ValueTests.typedGetters(getWrapper()); } @Test - public void Values_Hash_DeviceId() throws Exception { - ValueTests.deviceId(getWrapper()); + public void Values_Ipi_RegisteredName() throws Exception { + ValueTests.registeredName(getWrapper()); } } diff --git a/ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/flowelements/Builder.java b/ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/flowelements/Builder.java deleted file mode 100644 index 512de54a..00000000 --- a/ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/flowelements/Builder.java +++ /dev/null @@ -1,49 +0,0 @@ -/* ********************************************************************* - * This Original Work is copyright of 51 Degrees Mobile Experts Limited. - * Copyright 2026 51 Degrees Mobile Experts Limited, Davidson House, - * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU. - * - * This Original Work is licensed under the European Union Public Licence - * (EUPL) v.1.2 and is subject to its terms as set out below. - * - * If a copy of the EUPL was not distributed with this file, You can obtain - * one at https://opensource.org/licenses/EUPL-1.2. - * - * The 'Compatible Licences' set out in the Appendix to the EUPL (as may be - * amended by the European Commission) shall be deemed incompatible for - * the purposes of the Work and the provisions of the compatibility - * clause in Article 5 of the EUPL shall not apply. - * - * If using the Work as, or as part of, a network application, by - * including the attribution notice(s) required under Article 5 of the EUPL - * in the end user terms of the application under an appropriate heading, - * such notice(s) shall fulfill the requirements of that article. - * ********************************************************************* */ - -package fiftyone.ipintelligence.engine.onpremise.flowelements; - -import fiftyone.pipeline.engines.configuration.CacheConfiguration; -import org.junit.Before; -import org.junit.Test; -import org.slf4j.ILoggerFactory; -import org.slf4j.LoggerFactory; - -public class Builder { - protected static final ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory(); - - private IPIntelligenceOnPremiseEngineBuilder builder; - - @Before - public void init() { - builder = new IPIntelligenceOnPremiseEngineBuilder(loggerFactory); - } - - /** - * Check that an exception is thrown when attempting to add a cache to the - * on-premise engine. - */ - @Test(expected = UnsupportedOperationException.class) - public void Builder_CacheDisabled() { - builder.setCache(new CacheConfiguration(1000)); - } -} diff --git a/ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/flowelements/EngineTests.java b/ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/flowelements/EngineTests.java index 3edf1706..4f0d9005 100644 --- a/ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/flowelements/EngineTests.java +++ b/ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/flowelements/EngineTests.java @@ -32,7 +32,6 @@ import org.slf4j.ILoggerFactory; import org.slf4j.LoggerFactory; -import fiftyone.ipintelligence.shared.testhelpers.FileUtils; import fiftyone.pipeline.engines.Constants; import static fiftyone.ipintelligence.shared.testhelpers.FileUtils.LITE_IPI_DATA_FILE_NAME; import static fiftyone.ipintelligence.shared.testhelpers.FileUtils.ENTERPRISE_IPI_V41_DATA_FILE_NAME; @@ -71,8 +70,7 @@ private void testDataSourceTier(String fileName) throws Exception { assertEquals("Lite", tier); } else { - assertTrue(tier.equalsIgnoreCase("Enterprise") || - tier.equalsIgnoreCase("TAC")); + assertTrue(tier.equalsIgnoreCase("Enterprise")); } } @@ -81,7 +79,7 @@ private void testDataSourceTier(String fileName) throws Exception { * @throws Exception */ @Test - public void Engine_Hash_GetDataSourceTier_Lite() throws Exception { + public void Engine_Ipi_GetDataSourceTier_Lite() throws Exception { testDataSourceTier(LITE_IPI_DATA_FILE_NAME); } @@ -91,7 +89,7 @@ public void Engine_Hash_GetDataSourceTier_Lite() throws Exception { * @throws Exception */ @Test - public void Engine_Hash_GetDataSourceTier_Enterprise() throws Exception { + public void Engine_Ipi_GetDataSourceTier_Enterprise() throws Exception { testDataSourceTier(ENTERPRISE_IPI_V41_DATA_FILE_NAME); } diff --git a/ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/flowelements/EvidenceKeysTests.java b/ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/flowelements/EvidenceKeysTests.java index 94a0b805..0b8017b9 100644 --- a/ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/flowelements/EvidenceKeysTests.java +++ b/ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/flowelements/EvidenceKeysTests.java @@ -44,24 +44,24 @@ public void cleanup() { } @Test - public void EvidenceKeys_Hash_ContainsClientIP() { + public void EvidenceKeys_Ipi_ContainsClientIP() { EvidenceKeyTests.containsClientIP(getWrapper()); } @Test - public void EvidenceKeys_Hash_ContainsQueryParams() { + public void EvidenceKeys_Ipi_ContainsQueryParams() { EvidenceKeyTests.containsQueryParams(getWrapper()); } @Test - public void EvidenceKeys_Hash_ContainsOverrides() { + public void EvidenceKeys_Ipi_ContainsOverrides() { assumeFalse("Need to run test with Enterprise data", getWrapper().getEngine().getDataSourceTier().equals("Lite")); EvidenceKeyTests.containsOverrides(getWrapper()); } @Test - public void EvidenceKeys_Hash_CaseInsensitiveKeys() { + public void EvidenceKeys_Ipi_CaseInsensitiveKeys() { EvidenceKeyTests.caseInsensitiveKeys(getWrapper()); } } diff --git a/ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/flowelements/TestProcessTests.java b/ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/flowelements/TestProcessTests.java index e234c9ec..45d7f244 100644 --- a/ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/flowelements/TestProcessTests.java +++ b/ip-intelligence.engine.on-premise/src/test/java/fiftyone/ipintelligence/engine/onpremise/flowelements/TestProcessTests.java @@ -43,27 +43,27 @@ public void cleanup() { } @Test - public void Process_Hash_NoEvidence() throws Exception { + public void Process_Ipi_NoEvidence() throws Exception { ProcessTests.noEvidence(getWrapper(), new DataValidatorHash(getWrapper().getEngine())); } @Test - public void Process_Hash_EmptyUserAgent() throws Exception { - ProcessTests.emptyUserAgent(getWrapper(), new DataValidatorHash(getWrapper().getEngine())); + public void Process_Ipi_EmptyIpAddress() throws Exception { + ProcessTests.emptyIpAddress(getWrapper(), new DataValidatorHash(getWrapper().getEngine())); } @Test - public void Process_Hash_NoHeaders() throws Exception { + public void Process_Ipi_NoHeaders() throws Exception { ProcessTests.noHeaders(getWrapper(), new DataValidatorHash(getWrapper().getEngine())); } @Test - public void Process_Hash_NoUsefulHeaders() throws Exception { + public void Process_Ipi_NoUsefulHeaders() throws Exception { ProcessTests.noUsefulHeaders(getWrapper(), new DataValidatorHash(getWrapper().getEngine())); } @Test - public void Process_Hash_CaseInsensitiveKeys() throws Exception { + public void Process_Ipi_CaseInsensitiveKeys() throws Exception { ProcessTests.caseInsensitiveEvidenceKeys(getWrapper(), new DataValidatorHash(getWrapper().getEngine())); } } diff --git a/ip-intelligence.shared/src/main/java/fiftyone/ipintelligence/shared/testhelpers/FileUtils.java b/ip-intelligence.shared/src/main/java/fiftyone/ipintelligence/shared/testhelpers/FileUtils.java index 41cd5794..e556faae 100644 --- a/ip-intelligence.shared/src/main/java/fiftyone/ipintelligence/shared/testhelpers/FileUtils.java +++ b/ip-intelligence.shared/src/main/java/fiftyone/ipintelligence/shared/testhelpers/FileUtils.java @@ -44,7 +44,6 @@ public class FileUtils { public static final String LITE_IPI_DATA_FILE_NAME = "51Degrees-LiteV41.ipi"; private static Optional IPI_DATA_FILE; public static final String IP_ADDRESSES_FILE_NAME = "evidence.csv"; - private static File UA_FILE; public static final String EVIDENCE_FILE_NAME = "evidence.yml"; private static Optional EVIDENCE_FILE; @@ -104,7 +103,7 @@ public static File getEvidenceFile() { /** * Prefix for temp files that are created by {@link #jarFileHelper(String)} **/ - public static String TEMP_FILE_PREFIX = "DDTempFile"; + public static String TEMP_FILE_PREFIX = "IPITempFile"; /** * Search the classpath for a resource. If it doesn't exist throw an exception. diff --git a/ip-intelligence.shared/src/test/java/fiftyone/ipintelligence/shared/MetaDataTests.java b/ip-intelligence.shared/src/test/java/fiftyone/ipintelligence/shared/MetaDataTests.java deleted file mode 100644 index d211a221..00000000 --- a/ip-intelligence.shared/src/test/java/fiftyone/ipintelligence/shared/MetaDataTests.java +++ /dev/null @@ -1,93 +0,0 @@ -/* ********************************************************************* - * This Original Work is copyright of 51 Degrees Mobile Experts Limited. - * Copyright 2026 51 Degrees Mobile Experts Limited, Davidson House, - * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU. - * - * This Original Work is licensed under the European Union Public Licence - * (EUPL) v.1.2 and is subject to its terms as set out below. - * - * If a copy of the EUPL was not distributed with this file, You can obtain - * one at https://opensource.org/licenses/EUPL-1.2. - * - * The 'Compatible Licences' set out in the Appendix to the EUPL (as may be - * amended by the European Commission) shall be deemed incompatible for - * the purposes of the Work and the provisions of the compatibility - * clause in Article 5 of the EUPL shall not apply. - * - * If using the Work as, or as part of, a network application, by - * including the attribution notice(s) required under Article 5 of the EUPL - * in the end user terms of the application under an appropriate heading, - * such notice(s) shall fulfill the requirements of that article. - * ********************************************************************* */ - -package fiftyone.ipintelligence.shared; - -import fiftyone.ipintelligence.shared.testhelpers.Wrapper; -import fiftyone.ipintelligence.shared.testhelpers.data.MetaDataHasher; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; -import java.util.concurrent.atomic.AtomicBoolean; - -public class MetaDataTests { - - private static List> startHashingThreads( - int threadCount, - final Wrapper wrapper, - final MetaDataHasher hasher, - ExecutorService executorService) throws InterruptedException { - - List> callables = new ArrayList<>(threadCount); - for (int i = 0; i < threadCount; i++) { - callables.add(new Callable() { - @Override - public Integer call() throws Exception { - - int hash = 0; - hash = hasher.hashProperties(hash, wrapper); - hash = hasher.hashValues(hash, wrapper); - hash = hasher.hashComponents(hash, wrapper); - hash = hasher.hashProfiles(hash, wrapper); - return hash; - } - }); - } - return executorService.invokeAll(callables); - } - - public static List reload( - final Wrapper wrapper, - MetaDataHasher hasher, - ExecutorService executorService) throws InterruptedException, ExecutionException { - int threadCount = 4; - final int[] refreshes = {0}; - final AtomicBoolean done = new AtomicBoolean(false); - Future reloader = executorService.submit(new Runnable() { - @Override - public void run() { - synchronized(done){ - while (done.get() == false) { - wrapper.getEngine().refreshData(wrapper.getEngine().getDataFileMetaData().getIdentifier()); - refreshes[0]++; - } - } - } - }); - List> threads = startHashingThreads( - threadCount, - wrapper, - hasher, - executorService); - List hashes = new ArrayList<>(threadCount); - for (int i = 0; i < threadCount; i++) { - hashes.add(threads.get(i).get()); - } - done.set(true); - reloader.wait(); - return hashes; - } -} diff --git a/ip-intelligence.shared/src/test/java/fiftyone/ipintelligence/shared/testhelpers/ClientHintsExampleTestBase.java b/ip-intelligence.shared/src/test/java/fiftyone/ipintelligence/shared/testhelpers/ClientHintsExampleTestBase.java deleted file mode 100644 index d027cb23..00000000 --- a/ip-intelligence.shared/src/test/java/fiftyone/ipintelligence/shared/testhelpers/ClientHintsExampleTestBase.java +++ /dev/null @@ -1,80 +0,0 @@ -/* ********************************************************************* - * This Original Work is copyright of 51 Degrees Mobile Experts Limited. - * Copyright 2026 51 Degrees Mobile Experts Limited, Davidson House, - * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU. - * - * This Original Work is licensed under the European Union Public Licence - * (EUPL) v.1.2 and is subject to its terms as set out below. - * - * If a copy of the EUPL was not distributed with this file, You can obtain - * one at https://opensource.org/licenses/EUPL-1.2. - * - * The 'Compatible Licences' set out in the Appendix to the EUPL (as may be - * amended by the European Commission) shall be deemed incompatible for - * the purposes of the Work and the provisions of the compatibility - * clause in Article 5 of the EUPL shall not apply. - * - * If using the Work as, or as part of, a network application, by - * including the attribution notice(s) required under Article 5 of the EUPL - * in the end user terms of the application under an appropriate heading, - * such notice(s) shall fulfill the requirements of that article. - * ********************************************************************* */ - -package fiftyone.ipintelligence.shared.testhelpers; - -import static fiftyone.ipintelligence.shared.testhelpers.Constants.*; -import static org.junit.Assert.fail; - -public class ClientHintsExampleTestBase { - - public static String ALL_PROPERTIES = null; - public static String BASE_PROPERTIES = "HardwareVendor,HardwareName,DeviceType,PlatformVendor,PlatformName,PlatformVersion,BrowserVendor,BrowserName,BrowserVersion"; - public static String PLATFORM_PROPERTIES = BASE_PROPERTIES + ",SetHeaderPlatformAccept-CH"; - public static String HARDWARE_PROPERTIES = BASE_PROPERTIES + ",SetHeaderHardwareAccept-CH"; - public static String BROWSER_PROPERTIES = BASE_PROPERTIES + ",SetHeaderBrowserAccept-CH"; - - public static String CHROME_UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " - + "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36"; - public static String EDGE_UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " - + "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36 " - + "Edg/95.0.1020.44"; - public static String FIREFOX_UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64;" - + " rv:94.0) Gecko/20100101 Firefox/94.0"; - public static String SAFARI_UA = "Mozilla/5.0 (iPhone; CPU iPhone OS 15_1 " - + "like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.0 " - + "Mobile/15E148 Safari/604.1"; - public static String CURL_UA = "curl/7.80.0"; - - public static String SUPER_ACCEPT_CH = "SEC-CH-UA-Platform,SEC-CH-UA-Platform-Version,SEC-CH-UA-Model," - + "SEC-CH-UA-Mobile,SEC-CH-UA-Arch,SEC-CH-UA,SEC-CH-UA-Full-Version"; - public static String PLATFORM_ACCEPT_CH = "SEC-CH-UA-Platform,SEC-CH-UA-Platform-Version"; - public static String HARDWARE_ACCEPT_CH = "SEC-CH-UA-Model,SEC-CH-UA-Mobile,SEC-CH-UA-Arch"; - public static String BROWSER_ACCEPT_CH = "SEC-CH-UA,SEC-CH-UA-Full-Version"; - - public static int TEST_PORT_NUMBER = 8080; - public static String BASE_URL = "http://localhost:"+ TEST_PORT_NUMBER + "/"; - public static String CLOUD_URL = BASE_URL + "pipeline.uachmanual.cloud.examples.servlet"; - public static String HASH_URL = BASE_URL + "pipeline.uachmanual.examples.servlet"; - - - /* - * Function to get environment variable value. - */ - private static String getEnvVar(String name, String description) { - String resourceKey = null; - String envResourceKey = System.getenv(name); - String propertyResourceKey = System.getProperty(name); - - if(envResourceKey == null || envResourceKey.isEmpty()) { - if (propertyResourceKey == null || propertyResourceKey.isEmpty()) - fail(description + " needs to be set in " + name + " environment variable to run Cloud tests."); - else { - resourceKey = propertyResourceKey; - } - } - else { - resourceKey = envResourceKey; - } - return resourceKey; - } -} diff --git a/ip-intelligence.shared/src/test/java/fiftyone/ipintelligence/shared/testhelpers/UserAgentGenerator.java b/ip-intelligence.shared/src/test/java/fiftyone/ipintelligence/shared/testhelpers/IpAddressGenerator.java similarity index 81% rename from ip-intelligence.shared/src/test/java/fiftyone/ipintelligence/shared/testhelpers/UserAgentGenerator.java rename to ip-intelligence.shared/src/test/java/fiftyone/ipintelligence/shared/testhelpers/IpAddressGenerator.java index d57d8e05..3ff14e37 100644 --- a/ip-intelligence.shared/src/test/java/fiftyone/ipintelligence/shared/testhelpers/UserAgentGenerator.java +++ b/ip-intelligence.shared/src/test/java/fiftyone/ipintelligence/shared/testhelpers/IpAddressGenerator.java @@ -32,20 +32,20 @@ import java.util.Random; import java.util.regex.Pattern; -public class UserAgentGenerator { +public class IpAddressGenerator { - private final List userAgents; + private final List ipAddresses; private Random random = new Random(); - public UserAgentGenerator(File userAgentFile) throws IOException { - userAgents = Files.readAllLines( - userAgentFile.toPath(), + public IpAddressGenerator(File ipAddressFile) throws IOException { + ipAddresses = Files.readAllLines( + ipAddressFile.toPath(), Charset.defaultCharset()); } - public String getRandomUserAgent(int randomness) { - String value = userAgents.get(random.nextInt(userAgents.size())); + public String getRandomIpAddress(int randomness) { + String value = ipAddresses.get(random.nextInt(ipAddresses.size())); if (randomness > 0) { byte[] bytes = value.getBytes(StandardCharsets.US_ASCII); for (int i = 0; i < randomness; i++) { @@ -63,7 +63,7 @@ public String getRandomUserAgent(int randomness) { public Iterable getIterable(int count, int randomness) { List result = new ArrayList<>(count); for (int i = 0; i < count; i++) { - result.add(getRandomUserAgent(randomness)); + result.add(getRandomIpAddress(randomness)); } return result; } @@ -73,9 +73,9 @@ public Iterable getIterable(int count, String pattern) { int index = 0; List result = new ArrayList<>(); Pattern regex = Pattern.compile(pattern); - while (counter < count && index < userAgents.size()) { - if (regex.matcher(userAgents.get(index)).matches()) { - result.add(userAgents.get(index)); + while (counter < count && index < ipAddresses.size()) { + if (regex.matcher(ipAddresses.get(index)).matches()) { + result.add(ipAddresses.get(index)); counter++; } index++; @@ -87,7 +87,7 @@ public Iterable getIterable(int count) { return getIterable(count, "(.*?)"); } - public Iterable getRandomUserAgents(int count) { + public Iterable getRandomIpAddresses(int count) { return getIterable(count); } } diff --git a/ip-intelligence.shared/src/test/java/fiftyone/ipintelligence/shared/testhelpers/data/ValueTests.java b/ip-intelligence.shared/src/test/java/fiftyone/ipintelligence/shared/testhelpers/data/ValueTests.java index 52541273..bc033403 100644 --- a/ip-intelligence.shared/src/test/java/fiftyone/ipintelligence/shared/testhelpers/data/ValueTests.java +++ b/ip-intelligence.shared/src/test/java/fiftyone/ipintelligence/shared/testhelpers/data/ValueTests.java @@ -40,7 +40,7 @@ public class ValueTests { - public static void deviceId(Wrapper wrapper) throws Exception { + public static void registeredName(Wrapper wrapper) throws Exception { try (FlowData data = wrapper.getPipeline().createFlowData()) { data.addEvidence("server.client-ip", Constants.IPV4_ADDRESS) .process(); @@ -48,7 +48,7 @@ public static void deviceId(Wrapper wrapper) throws Exception { IPIntelligenceData ipiData = (IPIntelligenceData) elementData; assertNotNull("The registered name should not be null.", ipiData.getRegisteredName().getValue()); - assertFalse("The ipiData id should not be empty.", + assertFalse("The registered name should not be empty.", ipiData.getRegisteredName().getValue().isEmpty()); } } diff --git a/ip-intelligence.shared/src/test/java/fiftyone/ipintelligence/shared/testhelpers/flowelements/ProcessTests.java b/ip-intelligence.shared/src/test/java/fiftyone/ipintelligence/shared/testhelpers/flowelements/ProcessTests.java index 95ea6446..c2d0fbb7 100644 --- a/ip-intelligence.shared/src/test/java/fiftyone/ipintelligence/shared/testhelpers/flowelements/ProcessTests.java +++ b/ip-intelligence.shared/src/test/java/fiftyone/ipintelligence/shared/testhelpers/flowelements/ProcessTests.java @@ -43,7 +43,7 @@ public static void noEvidence( } } - public static void emptyUserAgent( + public static void emptyIpAddress( Wrapper wrapper, DataValidator validator) throws Exception { try (FlowData data = wrapper.getPipeline().createFlowData()) { diff --git a/ip-intelligence/src/main/java/fiftyone/ipintelligence/IPIntelligenceCloudPipelineBuilder.java b/ip-intelligence/src/main/java/fiftyone/ipintelligence/IPIntelligenceCloudPipelineBuilder.java index 38e1d79c..b19e90a0 100644 --- a/ip-intelligence/src/main/java/fiftyone/ipintelligence/IPIntelligenceCloudPipelineBuilder.java +++ b/ip-intelligence/src/main/java/fiftyone/ipintelligence/IPIntelligenceCloudPipelineBuilder.java @@ -33,7 +33,7 @@ import org.slf4j.ILoggerFactory; /** - * Builder used to create pipelines with an cloud-based + * Builder used to create pipelines with a cloud-based * IP Intelligence engine. */ public class IPIntelligenceCloudPipelineBuilder @@ -99,16 +99,16 @@ public Pipeline build() throws Exception { CloudRequestEngine cloudRequestEngine = cloudRequestEngineBuilder.build(); // Configure and build the IP Intelligence engine - IPIntelligenceCloudEngineBuilder IPIntelligenceEngineBuilder = + IPIntelligenceCloudEngineBuilder ipIntelligenceEngineBuilder = new IPIntelligenceCloudEngineBuilder(loggerFactory); if (lazyLoading) { - IPIntelligenceEngineBuilder.setLazyLoading(new LazyLoadingConfiguration( + ipIntelligenceEngineBuilder.setLazyLoading(new LazyLoadingConfiguration( (int) lazyLoadingTimeoutMillis)); } // Add the elements to the list flowElements.add(cloudRequestEngine); - flowElements.add(IPIntelligenceEngineBuilder.build()); + flowElements.add(ipIntelligenceEngineBuilder.build()); // Build and return the pipeline return super.build(); diff --git a/ip-intelligence/src/main/java/fiftyone/ipintelligence/IPIntelligenceOnPremisePipelineBuilder.java b/ip-intelligence/src/main/java/fiftyone/ipintelligence/IPIntelligenceOnPremisePipelineBuilder.java index cbf715c6..59042020 100644 --- a/ip-intelligence/src/main/java/fiftyone/ipintelligence/IPIntelligenceOnPremisePipelineBuilder.java +++ b/ip-intelligence/src/main/java/fiftyone/ipintelligence/IPIntelligenceOnPremisePipelineBuilder.java @@ -87,7 +87,8 @@ public class IPIntelligenceOnPremisePipelineBuilder * Set the filename of the IP Intelligence data file that the * engine should use. * @param filename The data file. - * @param createTempDataCopy + * @param createTempDataCopy If true, the engine will create a temporary + * copy of the data file rather than using the data file directly. * @return This builder instance. * @throws Exception Thrown if the filename has an unknown extension. */ @@ -240,7 +241,7 @@ public IPIntelligenceOnPremisePipelineBuilder setDataUpdateLicenseKey( /** * Set the performance profile for the IP Intelligence engine. - * Defaults to balanced. + * Defaults to MaxPerformance. * @param profile The performance profile to use. * @return This builder instance. */ @@ -323,20 +324,20 @@ public IPIntelligenceOnPremisePipelineBuilder setDataUpdateUrlFormatter(DataUpda */ @Override public Pipeline build() throws Exception { - AspectEngine IPIntelligenceEngine; + AspectEngine ipIntelligenceEngine; - IPIntelligenceOnPremiseEngineBuilder hashBuilder = + IPIntelligenceOnPremiseEngineBuilder engineBuilder = new IPIntelligenceOnPremiseEngineBuilder(loggerFactory, dataUpdateService); - IPIntelligenceEngine = configureAndBuild(hashBuilder); + ipIntelligenceEngine = configureAndBuild(engineBuilder); - if (IPIntelligenceEngine != null) { + if (ipIntelligenceEngine != null) { // Add the share usage element to the list if enabled if (shareUsageEnabled) { getFlowElements().add( new ShareUsageBuilder(loggerFactory).build()); } // Add the IP Intelligence engine to the list - getFlowElements().add(IPIntelligenceEngine); + getFlowElements().add(ipIntelligenceEngine); } else { throw new RuntimeException("Unexpected error creating IP Intelligence engine."); } @@ -348,8 +349,8 @@ public Pipeline build() throws Exception { } /** - * Private method used to set configuration options common to - * both hash and pattern engines and build the engine. + * Private method used to set configuration options on the + * engine builder and build the engine. * @param builder The builder to configure. * @return A new IP Intelligence engine instance. * @throws Exception diff --git a/ip-intelligence/src/main/java/fiftyone/ipintelligence/IPIntelligencePipelineBuilder.java b/ip-intelligence/src/main/java/fiftyone/ipintelligence/IPIntelligencePipelineBuilder.java index edc3861d..defaaca8 100644 --- a/ip-intelligence/src/main/java/fiftyone/ipintelligence/IPIntelligencePipelineBuilder.java +++ b/ip-intelligence/src/main/java/fiftyone/ipintelligence/IPIntelligencePipelineBuilder.java @@ -93,7 +93,7 @@ public IPIntelligencePipelineBuilder( * @param createTempDataCopy If true, the engine will create a temporary * copy of the data file rather than using the data file directly. * @return A builder that can be used to configure and build a pipeline - * that will use the on-premise detection engine. + * that will use the on-premise IP intelligence engine. * @throws Exception Thrown if a required parameter is null. */ public IPIntelligenceOnPremisePipelineBuilder useOnPremise( diff --git a/ip-intelligence/src/test/java/fiftyone/ipintelligence/CloudRequestOriginTests.java b/ip-intelligence/src/test/java/fiftyone/ipintelligence/CloudRequestOriginTests.java index aaabebd8..c4d13d29 100644 --- a/ip-intelligence/src/test/java/fiftyone/ipintelligence/CloudRequestOriginTests.java +++ b/ip-intelligence/src/test/java/fiftyone/ipintelligence/CloudRequestOriginTests.java @@ -93,12 +93,8 @@ public void ResourceKeyWithOrigin() throws Exception { .setCloudRequestOrigin(this.origin) .build(); - try(FlowData data = pipeline.createFlowData()) { - data.addEvidence("query.client-ip", - "Mozilla/5.0 (Linux; Android 8.0.0; Pixel 2 XL " + - "Build/OPD1.170816.004) AppleWebKit/537.36 " + - "(KHTML, like Gecko) Chrome/80.0.3987.106 " + - "Mobile Safari/537.36") + try(FlowData data = pipeline.createFlowData()) { + data.addEvidence("query.client-ip", "8.8.8.8") .process(); } } diff --git a/ip-intelligence/src/test/java/fiftyone/ipintelligence/IPIntelligenceOnPremisePipelineBuilderTest.java b/ip-intelligence/src/test/java/fiftyone/ipintelligence/IPIntelligenceOnPremisePipelineBuilderTest.java index 0d4b4c31..dd745168 100644 --- a/ip-intelligence/src/test/java/fiftyone/ipintelligence/IPIntelligenceOnPremisePipelineBuilderTest.java +++ b/ip-intelligence/src/test/java/fiftyone/ipintelligence/IPIntelligenceOnPremisePipelineBuilderTest.java @@ -100,17 +100,17 @@ public void setFilename_PropertyPropagatedToDataFileConfiguration() throws Excep @Test public void setFilename_DatExtension_ExceptionThrown() { try { - builder.setFilename(IPI_DATA_FILE_NAME.replace(".hash", ".dat"), true); + builder.setFilename(IPI_DATA_FILE_NAME.replace(".ipi", ".dat"), true); fail(); } catch (Exception e) { - assertTrue(e.getMessage().contains("The Pattern data format data")); + assertTrue(e.getMessage().contains("Unrecognised filename.")); } } @Test public void setFilename_OtherExtension_ExceptionThrown() { try { - builder.setFilename(IPI_DATA_FILE_NAME.replace(".hash", ".any"), true); + builder.setFilename(IPI_DATA_FILE_NAME.replace(".ipi", ".any"), true); fail(); } catch (Exception e) { assertTrue(e.getMessage().contains("Unrecognised filename.")); diff --git a/ip-intelligence/src/test/java/fiftyone/ipintelligence/IPIntelligenceTests.java b/ip-intelligence/src/test/java/fiftyone/ipintelligence/IPIntelligenceTests.java index 132ddaab..b40f3c62 100644 --- a/ip-intelligence/src/test/java/fiftyone/ipintelligence/IPIntelligenceTests.java +++ b/ip-intelligence/src/test/java/fiftyone/ipintelligence/IPIntelligenceTests.java @@ -24,7 +24,7 @@ import fiftyone.ipintelligence.engine.onpremise.flowelements.IPIntelligenceOnPremiseEngine; import fiftyone.ipintelligence.shared.IPIntelligenceData; -import fiftyone.ipintelligence.shared.testhelpers.UserAgentGenerator; +import fiftyone.ipintelligence.shared.testhelpers.IpAddressGenerator; import fiftyone.ipintelligence.shared.testhelpers.FileUtils; import fiftyone.pipeline.core.data.FlowData; import fiftyone.pipeline.core.data.FlowError; @@ -54,8 +54,6 @@ import java.util.concurrent.Future; import static fiftyone.ipintelligence.shared.testhelpers.FileUtils.IP_ADDRESSES_FILE_NAME; -import static fiftyone.pipeline.core.Constants.EVIDENCE_HTTPHEADER_PREFIX; -import static fiftyone.pipeline.core.Constants.EVIDENCE_SEPERATOR; import static fiftyone.pipeline.engines.Constants.PerformanceProfiles.*; import static org.junit.Assert.assertEquals; import static org.junit.Assume.assumeTrue; @@ -71,39 +69,19 @@ public class IPIntelligenceTests { private static final String IPI_DATA_FILE_NAME = FileUtils.getHashFileName(); - private static UserAgentGenerator userAgents; + private static IpAddressGenerator ipAddresses; TestConfig[] ipiConfigs = { // ******** IPI with a single thread ********* new TestConfig(IPI_DATA_FILE_NAME, MaxPerformance, false, false, "IPI-MaxPerformance-NoCache-SingleThread"), -// new TestConfig(IPI_DATA_FILE_NAME, HighPerformance, false, false, "Hash-HighPerformance-NoCache-SingleThread"), -// new TestConfig(IPI_DATA_FILE_NAME, LowMemory, false, false, "Hash-LowMemory-NoCache-SingleThread"), -// new TestConfig(IPI_DATA_FILE_NAME, Balanced, false, false, "Hash-Balanced-NoCache-SingleThread"), -// new TestConfig(IPI_DATA_FILE_NAME, BalancedTemp, false, false, "Hash-HighPerformance-NoCache-SingleThread"), new TestConfig(IPI_DATA_FILE_NAME, MaxPerformance, true, false, "IPI-MaxPerformance-Cache-SingleThread"), -// new TestConfig(IPI_DATA_FILE_NAME, HighPerformance, true, false, "Hash-HighPerformance-Cache-SingleThread"), -// new TestConfig(IPI_DATA_FILE_NAME, LowMemory, true, false, "Hash-LowMemory-Cache-SingleThread"), -// new TestConfig(IPI_DATA_FILE_NAME, Balanced, true, false, "Hash-Balanced-Cache-SingleThread"), -// new TestConfig(IPI_DATA_FILE_NAME, BalancedTemp, true, false, "Hash-BalancedTemp-Cache-SingleThread"), -// new TestConfig(IPI_DATA_FILE_NAME, BalancedTemp, true, false, "Hash-BalancedTemp-Cache-SingleThread"), -// new TestConfig(IPI_DATA_FILE_NAME, BalancedTemp, true, false, "Hash-BalancedTemp-Cache-SingleThread"), // ******** IPI with multiple threads ********* new TestConfig(IPI_DATA_FILE_NAME, MaxPerformance, false, true, "IPI-MaxPerformance-NoCache-MultiThread"), -// new TestConfig(IPI_DATA_FILE_NAME, HighPerformance, false, true, "Hash-HighPerformance-NoCache-MultiThread"), -// new TestConfig(IPI_DATA_FILE_NAME, LowMemory, false, true, "Hash-LowMemory-NoCache-MultiThread"), -// new TestConfig(IPI_DATA_FILE_NAME, Balanced, false, true, "Hash-Balanced-NoCache-MultiThread"), -// new TestConfig(IPI_DATA_FILE_NAME, BalancedTemp, false, true, "Hash-HighPerformance-NoCache-MultiThread"), new TestConfig(IPI_DATA_FILE_NAME, MaxPerformance, true, true, "IPI-MaxPerformance-Cache-MultiThread"), -// new TestConfig(IPI_DATA_FILE_NAME, HighPerformance, true, true, "Hash-HighPerformance-Cache-MultiThread"), -// new TestConfig(IPI_DATA_FILE_NAME, LowMemory, true, true, "Hash-LowMemory-Cache-MultiThread"), -// new TestConfig(IPI_DATA_FILE_NAME, Balanced, true, true, "Hash-Balanced-Cache-MultiThread"), -// new TestConfig(IPI_DATA_FILE_NAME, BalancedTemp, true, true, "Hash-BalancedTemp-Cache-MultiThread"), -// new TestConfig(IPI_DATA_FILE_NAME, BalancedTemp, true, true, "Hash-BalancedTemp-Cache-MultiThread"), -// new TestConfig(IPI_DATA_FILE_NAME, BalancedTemp, true, true, "Hash-BalancedTemp-Cache-MultiThread") }; @BeforeClass public static void initClass() throws IOException { - userAgents = new UserAgentGenerator( + ipAddresses = new IpAddressGenerator( FileFinder.getFilePath(IP_ADDRESSES_FILE_NAME)); } @@ -136,10 +114,10 @@ private static void AddToMessage(StringBuilder message, String textToAdd, int de } @Test - public void IPI_AllConfigurations_100_UserAgents() throws Exception { + public void IPI_AllConfigurations_100_IpAddresses() throws Exception { for (TestConfig config : ipiConfigs) { logger.info("Testing '" + config.name + "'"); - TestOnPremise_AllConfigurations_100_UserAgents( + TestOnPremise_AllConfigurations_100_IpAddresses( config.dataFileName, config.performanceProfile, config.useCache, @@ -147,7 +125,7 @@ public void IPI_AllConfigurations_100_UserAgents() throws Exception { } } - public void TestOnPremise_AllConfigurations_100_UserAgents( + public void TestOnPremise_AllConfigurations_100_IpAddresses( String datafileName, Constants.PerformanceProfiles performanceProfile, boolean useCache, @@ -177,12 +155,11 @@ public void TestOnPremise_AllConfigurations_100_UserAgents( callables.add(new Callable() { @Override public Void call() throws Exception { - for (String userAgent : userAgents.getRandomUserAgents(100)) { + for (String ipAddress : ipAddresses.getRandomIpAddresses(100)) { try (FlowData flowData = pipeline.createFlowData()) { flowData.addEvidence( - EVIDENCE_HTTPHEADER_PREFIX + - EVIDENCE_SEPERATOR + "User-Agent", - userAgent) + "server.client-ip", + ipAddress) .process(); if (flowData.getErrors() != null) { assertEquals( @@ -249,9 +226,9 @@ public void TestOnPremiseBuilder_CreateTempFile() throws Exception { .setAutoUpdate(false); try (Pipeline pipeline = builder.build()) { assertEquals(1, pipeline.getServices().size()); - IPIntelligenceOnPremiseEngine ddhe = + IPIntelligenceOnPremiseEngine engine = pipeline.getElement(IPIntelligenceOnPremiseEngine.class); - String tempDir = ddhe.getTempDataDirPath(); + String tempDir = engine.getTempDataDirPath(); Path tempPath = Paths.get(tempDir); } } From c98e1c3e9c6077b000b06f141fda7f70b722a05c Mon Sep 17 00:00:00 2001 From: James Rosewell Date: Sat, 13 Jun 2026 00:33:19 +0100 Subject: [PATCH 2/3] Link the CI Lite data file under the name tests look for ci/fetch-assets.ps1 symlinked the fetched Lite asset under its blob name 51Degrees-LiteIpiV41.ipi, but the FileUtils test helper searches for the unpacked name 51Degrees-LiteV41.ipi, the same name the data repo scripts produce, so tests could never find the fetched file. The -Assets entry keeps the blob name because the shared common-ci steps/fetch-assets.ps1 resolves assets through a fixed switch over known names and errors on anything else. That switch is also where the stale Lite blob URL lives, common-ci needs the equivalent of ip-intelligence-data PR #31 to fetch the current 4.5 build published as 51Degrees-IPIV4LiteIpiV41.ipi.gz. --- ci/fetch-assets.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ci/fetch-assets.ps1 b/ci/fetch-assets.ps1 index fa5bef23..af55e1a6 100644 --- a/ci/fetch-assets.ps1 +++ b/ci/fetch-assets.ps1 @@ -7,7 +7,9 @@ $ipIntelligenceData = "$PSSCriptRoot/../ip-intelligence.engine.on-premise/src/ma ./steps/fetch-assets.ps1 -IpIntelligenceUrl $IpIntelligenceUrl -Assets '51Degrees-EnterpriseIpiV41.ipi', '51Degrees-LiteIpiV41.ipi' New-Item -ItemType SymbolicLink -Force -Target "$PWD/assets/51Degrees-EnterpriseIpiV41.ipi" -Path "$ipIntelligenceData/51Degrees-EnterpriseIpiV41.ipi" -New-Item -ItemType SymbolicLink -Force -Target "$PWD/assets/51Degrees-LiteIpiV41.ipi" -Path "$ipIntelligenceData/51Degrees-LiteIpiV41.ipi" +# The asset is fetched under the blob name, but FileUtils and the data repo +# scripts use the unpacked name 51Degrees-LiteV41.ipi, so link it as that. +New-Item -ItemType SymbolicLink -Force -Target "$PWD/assets/51Degrees-LiteIpiV41.ipi" -Path "$ipIntelligenceData/51Degrees-LiteV41.ipi" Write-Host "Assets hashes:" Get-FileHash -Algorithm MD5 -Path assets/* From e8e488432b71d800c1193fedd69f245d05123c15 Mon Sep 17 00:00:00 2001 From: James Rosewell Date: Sat, 13 Jun 2026 10:03:52 +0100 Subject: [PATCH 3/3] Auto-detect the Windows toolset and SDK for the native build The on-premise native build forced platform toolset v142 and Windows SDK 10.0.18362.0 by default, so anyone on a newer Visual Studio had to pass -DplatformToolsetVersion and -DwindowsSDKVersion overrides and CI was pinned to an old toolset. The pom default for both is now "auto", and PreBuild.bat omits the corresponding CMake flag for an "auto" or empty value. CMake then picks the toolset and SDK from the installed Visual Studio, the latest each version supports, so the build uses v143 on a VS 2022 runner and v145 on a VS 2026 machine with no override. Explicit overrides still apply when the properties are set. PreBuild.sh already let CMake choose, so it is unchanged. --- ip-intelligence.engine.on-premise/pom.xml | 4 ++-- .../src/main/cxx/PreBuild.bat | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ip-intelligence.engine.on-premise/pom.xml b/ip-intelligence.engine.on-premise/pom.xml index 496abbf1..139cd5bf 100644 --- a/ip-intelligence.engine.on-premise/pom.xml +++ b/ip-intelligence.engine.on-premise/pom.xml @@ -64,7 +64,7 @@ - v142 + auto @@ -78,7 +78,7 @@ - 10.0.18362.0 + auto diff --git a/ip-intelligence.engine.on-premise/src/main/cxx/PreBuild.bat b/ip-intelligence.engine.on-premise/src/main/cxx/PreBuild.bat index 68f5b6ce..23b20dce 100644 --- a/ip-intelligence.engine.on-premise/src/main/cxx/PreBuild.bat +++ b/ip-intelligence.engine.on-premise/src/main/cxx/PreBuild.bat @@ -37,19 +37,21 @@ if %count% lss %argCount% ( goto while ) -rem Construct build flags +rem Construct build flags. A value of "auto" (the pom default) or an empty +rem value means let CMake pick the toolset and SDK from the installed Visual +rem Studio, so the corresponding flag is omitted. set additionalFlags= -if %toolsetVersion% neq "" ( +if /I not "%toolsetVersion%"=="auto" if not "%toolsetVersion%"=="" ( set additionalFlags=%additionalFlags% -DCMAKE_GENERATOR_TOOLSET=%toolsetVersion% ) -if %winSDKVersion% neq "" ( +if /I not "%winSDKVersion%"=="auto" if not "%winSDKVersion%"=="" ( set additionalFlags=%additionalFlags% -DCMAKE_SYSTEM_VERSION=%winSDKVersion% ) rem Build binaries :build -if %additionalFlags neq "" ( +if not "%additionalFlags%"=="" ( echo Build additional options: "%additionalFlags%" )