Skip to content

Commit

Permalink
Update tests after library refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
dvacca-onfido committed Dec 20, 2024
1 parent 5870fcc commit 87e5b48
Show file tree
Hide file tree
Showing 3 changed files with 336 additions and 0 deletions.
31 changes: 31 additions & 0 deletions media/studio_webhook_event_with_list_in_output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"payload": {
"resource_type": "workflow_task",
"action": "workflow_task.completed",
"object": {
"id": "document_photo_5c229",
"task_spec_id": "document_photo_5c229",
"task_def_id": "upload_document_photo",
"workflow_run_id": "b48fdff9-66a1-405d-9912-54780799bd68",
"status": "completed",
"completed_at_iso8601": "2024-12-18T18:13:10Z",
"href": "https://api.eu.onfido.com/v3.6/workflow_runs/b48fdff9-66a1-405d-9912-54780799bd68/tasks/document_photo_5c229"
},
"resource": {
"updated_at": "2024-12-18T18:13:10Z",
"output": [
{
"type": "document_photo",
"id": "7af75a3a-ba34-4aa5-9e3e-096c9f56256b",
"checksum_sha256": "hiwV2PLmeQZzeySPGGwVL48sxVXcyfpXy9LDl1u3lWU="
}
],
"created_at": "2024-12-18T18:12:44Z",
"task_def_id": "upload_document_photo",
"input": {},
"workflow_run_id": "b48fdff9-66a1-405d-9912-54780799bd68",
"task_def_version": null,
"id": "document_photo_5c229"
}
}
}
264 changes: 264 additions & 0 deletions media/studio_webhook_event_with_object_in_output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
{
"payload": {
"resource_type": "workflow_task",
"action": "workflow_task.completed",
"object": {
"id": "document_check_75329",
"task_spec_id": "document_check_75329",
"task_def_id": "document_check",
"workflow_run_id": "b48fdff9-66a1-405d-9912-54780799bd68",
"status": "completed",
"completed_at_iso8601": "2024-12-18T18:13:13Z",
"href": "https://api.eu.onfido.com/v3.6/workflow_runs/b48fdff9-66a1-405d-9912-54780799bd68/tasks/document_check_75329"
},
"resource": {
"task_def_version": null,
"task_def_id": "document_check",
"updated_at": "2024-12-18T18:13:13Z",
"id": "document_check_75329",
"output": {
"status": "complete",
"result": "clear",
"sub_result": "clear",
"uuid": "95c8cc09-db72-42ff-85ef-ee6c82020a24",
"properties": {
"date_of_birth": "1990-01-01",
"date_of_expiry": "2031-05-28",
"document_numbers": [
{
"type": "document_number",
"value": "999999999"
}
],
"document_type": "passport",
"first_name": "Jane",
"issuing_country": "GBR",
"last_name": "Doe",
"document_number": "999999999"
},
"breakdown": {
"data_validation": {
"result": "clear",
"breakdown": {
"mrz": {
"result": "clear",
"properties": {}
},
"expiry_date": {
"result": "clear",
"properties": {}
},
"document_expiration": {
"result": "clear",
"properties": {}
},
"document_numbers": {
"result": "clear",
"properties": {}
},
"date_of_birth": {
"result": "clear",
"properties": {}
},
"gender": {
"result": "clear",
"properties": {}
}
}
},
"visual_authenticity": {
"result": "clear",
"breakdown": {
"face_detection": {
"result": "clear",
"properties": {}
},
"other": {
"result": "clear",
"properties": {}
},
"digital_tampering": {
"result": "clear",
"properties": {}
},
"original_document_present": {
"result": "clear",
"properties": {}
},
"security_features": {
"result": "clear",
"properties": {}
},
"template": {
"result": "clear",
"properties": {}
},
"picture_face_integrity": {
"result": "clear",
"properties": {}
},
"fonts": {
"result": "clear",
"properties": {}
}
}
},
"compromised_document": {
"result": "clear",
"breakdown": {
"repeat_attempts": {
"result": "clear",
"properties": {}
},
"document_database": {
"result": "clear",
"properties": {}
}
}
},
"data_consistency": {
"result": "clear",
"breakdown": {
"nationality": {
"result": "clear",
"properties": {}
},
"last_name": {
"result": "clear",
"properties": {}
},
"first_name": {
"result": "clear",
"properties": {}
},
"multiple_data_sources_present": {
"result": "clear",
"properties": {}
},
"gender": {
"result": "clear",
"properties": {}
},
"date_of_birth": {
"result": "clear",
"properties": {}
},
"document_type": {
"result": "clear",
"properties": {}
},
"issuing_country": {
"result": "clear",
"properties": {}
},
"document_numbers": {
"result": "clear",
"properties": {}
},
"date_of_expiry": {
"result": "clear",
"properties": {}
}
}
},
"data_comparison": {
"result": "clear",
"breakdown": {
"date_of_birth": {
"result": "clear",
"properties": {}
},
"first_name": {
"result": "clear",
"properties": {}
},
"document_numbers": {
"result": "clear",
"properties": {}
},
"document_type": {
"result": "clear",
"properties": {}
},
"last_name": {
"result": "clear",
"properties": {}
},
"date_of_expiry": {
"result": "clear",
"properties": {}
},
"gender": {
"result": "clear",
"properties": {}
},
"issuing_country": {
"result": "clear",
"properties": {}
}
}
},
"image_integrity": {
"result": "clear",
"breakdown": {
"colour_picture": {
"result": "clear",
"properties": {}
},
"supported_document": {
"result": "clear",
"properties": {}
},
"conclusive_document_quality": {
"result": "clear",
"properties": {}
},
"image_quality": {
"result": "clear",
"properties": {}
}
}
},
"police_record": {
"result": "clear",
"breakdown": {
"document_has_not_been_recorded_as_lost,_stolen_or_compromised": {
"result": "clear",
"properties": {}
}
}
},
"age_validation": {
"result": "clear",
"breakdown": {
"minimum_accepted_age": {
"result": "clear",
"properties": {}
}
}
}
},
"repeat_attempts": {
"report_id": "00000000-0000-0000-0000-000000000000",
"repeat_attempts": [],
"attempts_count": 1,
"attempts_clear_rate": 0,
"unique_mismatches_count": 0
}
},
"workflow_run_id": "b48fdff9-66a1-405d-9912-54780799bd68",
"input": {
"document_ids": [
{
"checksum_sha256": "hiwV2PLmeQZzeySPGGwVL48sxVXcyfpXy9LDl1u3lWU=",
"id": "7af75a3a-ba34-4aa5-9e3e-096c9f56256b",
"type": "document_photo"
}
],
"first_name": "Jane",
"last_name": "Doe"
},
"created_at": "2024-12-18T18:13:11Z"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import com.onfido.model.WebhookEventPayloadResource;
import com.onfido.model.WebhookEventResourceType;
import com.onfido.model.WebhookEventType;
import java.io.File;
import java.nio.file.Files;
import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.UUID;
Expand Down Expand Up @@ -68,4 +70,43 @@ public void invalidSignatureTest() throws Exception {
OnfidoInvalidSignatureError.class,
() -> webhookEventVerifier.readPayload(rawEvent, signature));
}

@Test
public void validSignatureWithObjectInOutputTest() throws Exception {
final String signature = "e3e5565647f5ccf07b2fd8ac22eab94a0a0619413d981fb768295c820523f7d7";

String rawEventFromFile =
new String(
Files.readAllBytes(
new File("media/studio_webhook_event_with_object_in_output.json").toPath()));

WebhookEvent event = webhookEventVerifier.readPayload(rawEventFromFile, signature);

Assertions.assertTrue(
event
.getPayload()
.getResource()
.getOutput()
.toString()
.contains(
"properties={date_of_birth=1990-01-01, date_of_expiry=2031-05-28,"
+ " document_numbers=[{type=document_number, value=999999999}]"));
}

@Test
public void validSignatureWithListInOutputTest() throws Exception {
final String signature = "f3a5170acfcecf8c1bf6d9cb9995c0d9dec941af83056a721530f8de7af2c293";

String rawEventFromFile =
new String(
Files.readAllBytes(
new File("media/studio_webhook_event_with_list_in_output.json").toPath()));

WebhookEvent event = webhookEventVerifier.readPayload(rawEventFromFile, signature);

Assertions.assertEquals(
event.getPayload().getResource().getOutput().toString(),
"[{type=document_photo, id=7af75a3a-ba34-4aa5-9e3e-096c9f56256b,"
+ " checksum_sha256=hiwV2PLmeQZzeySPGGwVL48sxVXcyfpXy9LDl1u3lWU=}]");
}
}

0 comments on commit 87e5b48

Please sign in to comment.