Skip to content

Commit

Permalink
Add new fields to tests
Browse files Browse the repository at this point in the history
Add rawAttributes and policyId to tests
  • Loading branch information
edenalsant committed Nov 11, 2024
1 parent 37fc168 commit c7dcc99
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
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 c7dcc99

Please sign in to comment.