Skip to content

Commit

Permalink
Merge pull request #255 from inloco/feat/add-raw-attributes
Browse files Browse the repository at this point in the history
Add policyId and rawAttributes to SignUpAssessment and TransactionAssessment
  • Loading branch information
edenalsant authored Nov 13, 2024
2 parents fecefc4 + a77fe75 commit ab32d9c
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 16 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ And then add the artifact `incognia-api-client` **or** `incognia-api-client-shad
<dependency>
<groupId>com.incognia</groupId>
<artifactId>incognia-api-client</artifactId>
<version>2.11.0</version>
<version>2.12.0</version>
</dependency>
```
```xml
<dependency>
<groupId>com.incognia</groupId>
<artifactId>incognia-api-client-shaded</artifactId>
<version>2.11.0</version>
<version>2.12.0</version>
</dependency>
```

Expand All @@ -48,13 +48,13 @@ repositories {
And then add the dependency
```gradle
dependencies {
implementation 'com.incognia:incognia-api-client:2.11.0'
implementation 'com.incognia:incognia-api-client:2.12.0'
}
```
OR
```gradle
dependencies {
implementation 'com.incognia:incognia-api-client-shaded:2.11.0'
implementation 'com.incognia:incognia-api-client-shaded:2.12.0'
}
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = "com.incognia"
version = "2.11.0"
version = "2.12.0"

task createProjectVersionFile {
def projectVersionDir = "$projectDir/src/main/java/com/incognia/api"
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/incognia/onboarding/SignupAssessment.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ public class SignupAssessment {
Map<String, Object> evidence;
String deviceId;
String installationId;
String policyId;
Map<String, Object> rawAttributes;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ public class TransactionAssessment {
Map<String, Object> evidence;
String deviceId;
String installationId;
String policyId;
Map<String, Object> rawAttributes;
}
44 changes: 33 additions & 11 deletions src/test/java/com/incognia/api/IncogniaAPITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void testRegisterSignup_whenDataIsValid() {
String token = TokenCreationFixture.createToken();
String requestToken = "request-token";
String accountId = "my-account";
String policyId = UUID.randomUUID().toString();
String policyId = "3549270d-cd0f-494a-97ee-97af3d5add04";
String externalId = "external-id";
Address address = AddressFixture.ADDRESS_ADDRESS_LINE;
Map<String, Object> map = new HashMap<>();
Expand All @@ -96,12 +96,13 @@ void testRegisterSignup_whenDataIsValid() {
.build();
SignupAssessment signupAssessment = client.registerSignup(registerSignupRequest);
assertThat(signupAssessment)
.extracting("id", "requestId", "riskAssessment", "deviceId")
.extracting("id", "requestId", "riskAssessment", "deviceId", "policyId")
.containsExactly(
UUID.fromString("5e76a7ca-577c-4f47-a752-9e1e0cee9e49"),
UUID.fromString("8afc84a7-f1d4-488d-bd69-36d9a37168b7"),
Assessment.LOW_RISK,
"1df6d999-556d-42c3-8c63-357e5d08d95b");
"1df6d999-556d-42c3-8c63-357e5d08d95b",
"3549270d-cd0f-494a-97ee-97af3d5add04");
Map<String, Object> locationServices = new HashMap<>();
locationServices.put("location_permission_enabled", true);
locationServices.put("location_sensors_enabled", true);
Expand Down Expand Up @@ -129,6 +130,12 @@ void testRegisterSignup_whenDataIsValid() {
.source(ReasonSource.LOCAL.getSource())
.build();
assertThat(signupAssessment.getReasons()).containsExactly(expectedReason);

Map<String, Object> expectedRawAttributes = new HashMap<>();
expectedRawAttributes.put("random_attribute", 0);

assertThat(signupAssessment.getRawAttributes())
.containsExactlyInAnyOrderEntriesOf(expectedRawAttributes);
}

@Test
Expand All @@ -138,7 +145,7 @@ void testRegisterSignup_withEmptyAddress() {
String token = TokenCreationFixture.createToken();
String requestToken = "request-token";
String accountId = "my-account";
String policyId = UUID.randomUUID().toString();
String policyId = "3549270d-cd0f-494a-97ee-97af3d5add04";
String externalId = "external-id";

TokenAwareDispatcher dispatcher = new TokenAwareDispatcher(token, CLIENT_ID, CLIENT_SECRET);
Expand All @@ -159,12 +166,13 @@ void testRegisterSignup_withEmptyAddress() {
.build();
SignupAssessment signupAssessment = client.registerSignup(registerSignupRequest);
assertThat(signupAssessment)
.extracting("id", "requestId", "riskAssessment", "deviceId")
.extracting("id", "requestId", "riskAssessment", "deviceId", "policyId")
.containsExactly(
UUID.fromString("5e76a7ca-577c-4f47-a752-9e1e0cee9e49"),
UUID.fromString("8afc84a7-f1d4-488d-bd69-36d9a37168b7"),
Assessment.HIGH_RISK,
"1df6d999-556d-42c3-8c63-357e5d08d95b");
"1df6d999-556d-42c3-8c63-357e5d08d95b",
"3549270d-cd0f-494a-97ee-97af3d5add04");
Map<String, Object> locationServices = new HashMap<>();
locationServices.put("location_permission_enabled", true);
locationServices.put("location_sensors_enabled", true);
Expand Down Expand Up @@ -196,7 +204,7 @@ void testRegisterWebSignup_whenDataIsValid() {
String token = TokenCreationFixture.createToken();
String requestToken = "request-token-web-signup";
String accountId = "my-account";
String policyId = UUID.randomUUID().toString();
String policyId = "3549270d-cd0f-494a-97ee-97af3d5add04";
String externalId = "external-id";

TokenAwareDispatcher dispatcher = new TokenAwareDispatcher(token, CLIENT_ID, CLIENT_SECRET);
Expand All @@ -214,12 +222,13 @@ void testRegisterWebSignup_whenDataIsValid() {
.build();
SignupAssessment webSignupAssessment = client.registerWebSignup(registerSignupRequest);
assertThat(webSignupAssessment)
.extracting("id", "requestId", "riskAssessment", "deviceId")
.extracting("id", "requestId", "riskAssessment", "deviceId", "policyId")
.containsExactly(
UUID.fromString("5e76a7ca-577c-4f47-a752-9e1e0cee9e49"),
UUID.fromString("8afc84a7-f1d4-488d-bd69-36d9a37168b7"),
Assessment.LOW_RISK,
"1df6d999-556d-42c3-8c63-357e5d08d95b");
"1df6d999-556d-42c3-8c63-357e5d08d95b",
"3549270d-cd0f-494a-97ee-97af3d5add04");
Map<String, Object> locationServices = new HashMap<>();
locationServices.put("location_permission_enabled", true);
locationServices.put("location_sensors_enabled", true);
Expand Down Expand Up @@ -248,6 +257,12 @@ void testRegisterWebSignup_whenDataIsValid() {
.source(ReasonSource.LOCAL.getSource())
.build();
assertThat(webSignupAssessment.getReasons()).containsExactly(expectedReason);

Map<String, Object> expectedRawAttributes = new HashMap<>();
expectedRawAttributes.put("random_attribute", 0);

assertThat(webSignupAssessment.getRawAttributes())
.containsExactlyInAnyOrderEntriesOf(expectedRawAttributes);
}

@Test
Expand Down Expand Up @@ -674,11 +689,12 @@ void testRegisterLogin_whenAccountIdIsNotValid() {

private void assertTransactionAssessment(TransactionAssessment transactionAssessment) {
assertThat(transactionAssessment)
.extracting("id", "riskAssessment", "deviceId")
.extracting("id", "riskAssessment", "deviceId", "policyId")
.containsExactly(
UUID.fromString("dfe1f2ff-8f0d-4ce8-aed1-af8435143044"),
Assessment.LOW_RISK,
"1df6d999-556d-42c3-8c63-357e5d08d95b");
"1df6d999-556d-42c3-8c63-357e5d08d95b",
"3549270d-cd0f-494a-97ee-97af3d5add04");
Map<String, Object> locationServices = new HashMap<>();
locationServices.put("location_permission_enabled", true);
locationServices.put("location_sensors_enabled", true);
Expand Down Expand Up @@ -706,5 +722,11 @@ private void assertTransactionAssessment(TransactionAssessment transactionAssess
.source(ReasonSource.LOCAL.getSource())
.build();
assertThat(transactionAssessment.getReasons()).containsExactly(expectedReason);

Map<String, Object> expectedRawAttributes = new HashMap<>();
expectedRawAttributes.put("random_attribute", 0);

assertThat(transactionAssessment.getRawAttributes())
.containsExactlyInAnyOrderEntriesOf(expectedRawAttributes);
}
}
4 changes: 4 additions & 0 deletions src/test/resources/post_onboarding_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"request_id": "8afc84a7-f1d4-488d-bd69-36d9a37168b7",
"risk_assessment": "low_risk",
"device_id": "1df6d999-556d-42c3-8c63-357e5d08d95b",
"policy_id": "3549270d-cd0f-494a-97ee-97af3d5add04",
"reasons": [
{
"code": "trusted_location",
Expand All @@ -26,5 +27,8 @@
"gps_spoofing": false,
"from_official_store": true
}
},
"raw_attributes": {
"random_attribute": 0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"request_id": "8afc84a7-f1d4-488d-bd69-36d9a37168b7",
"risk_assessment": "high_risk",
"device_id": "1df6d999-556d-42c3-8c63-357e5d08d95b",
"policy_id": "3549270d-cd0f-494a-97ee-97af3d5add04",
"reasons": [
{
"code": "device_integrity",
Expand Down
4 changes: 4 additions & 0 deletions src/test/resources/post_transaction_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"risk_assessment": "low_risk",
"device_id": "1df6d999-556d-42c3-8c63-357e5d08d95b",
"unknown_field": "unknown_value",
"policy_id": "3549270d-cd0f-494a-97ee-97af3d5add04",
"reasons": [
{
"code": "trusted_location",
Expand Down Expand Up @@ -36,5 +37,8 @@
}
],
"location_events_quantity": 62
},
"raw_attributes": {
"random_attribute": 0
}
}

0 comments on commit ab32d9c

Please sign in to comment.