Skip to content

Commit b2e7bd8

Browse files
LuborRodRodion Liuborets
andauthored
SDK-2080 Add identity profile report (#276)
Co-authored-by: Rodion Liuborets <[email protected]>
1 parent 8459a64 commit b2e7bd8

File tree

5 files changed

+169
-0
lines changed

5 files changed

+169
-0
lines changed

src/Profile/UserProfile.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class UserProfile extends BaseProfile
2727
public const ATTR_DOCUMENT_DETAILS = "document_details";
2828
public const ATTR_DOCUMENT_IMAGES = 'document_images';
2929
public const ATTR_STRUCTURED_POSTAL_ADDRESS = 'structured_postal_address';
30+
public const ATTR_IDENTITY_PROFILE_REPORT = 'identity_profile_report';
3031

3132
/** @var \Yoti\Profile\Attribute\AgeVerification[] */
3233
private $ageVerifications;
@@ -168,6 +169,17 @@ public function getDocumentImages(): ?Attribute
168169
return $this->getProfileAttribute(self::ATTR_DOCUMENT_IMAGES);
169170
}
170171

172+
/**
173+
* IdentityProfileReport represents the JSON object containing identity assertion and the
174+
* verification report. This will be null if not provided by Yoti.
175+
*
176+
* @return Attribute|null
177+
*/
178+
public function getIdentityProfileReport(): ?Attribute
179+
{
180+
return $this->getProfileAttribute(self::ATTR_IDENTITY_PROFILE_REPORT);
181+
}
182+
171183
/**
172184
* Return all derived attributes from the DOB e.g 'Age Over', 'Age Under'
173185
* As a list of AgeVerification

tests/Profile/UserProfileTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,25 @@ public function testGetDocumentImages()
218218
$this->assertSame($profileData['document_images'], $profile->getDocumentImages());
219219
}
220220

221+
/**
222+
* @covers ::getIdentityProfileReport
223+
*/
224+
public function testIdentityProfileReport()
225+
{
226+
$attributeName = 'identity_profile_report';
227+
228+
$someAttribute = $this->createMock(\Yoti\Profile\Attribute::class);
229+
$someAttribute
230+
->method('getName')
231+
->willReturn($attributeName);
232+
233+
$profileData = [
234+
$attributeName => $someAttribute,
235+
];
236+
$profile = new UserProfile($profileData);
237+
$this->assertSame($profileData['identity_profile_report'], $profile->getIdentityProfileReport());
238+
}
239+
221240
/**
222241
* @param string $anchorString
223242
*

tests/Profile/Util/Attribute/AttributeConverterTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Yoti\Media\Image;
1111
use Yoti\Profile\Attribute;
1212
use Yoti\Profile\Attribute\MultiValue;
13+
use Yoti\Profile\UserProfile;
1314
use Yoti\Profile\Util\Attribute\AttributeConverter;
1415
use Yoti\Test\TestCase;
1516
use Yoti\Test\TestData;
@@ -529,6 +530,24 @@ public function testThirdPartyAttribute()
529530
$this->assertEquals('orgName', $attr->getVerifiers()[0]->getSubType());
530531
}
531532

533+
/**
534+
* @covers ::convertToYotiAttribute
535+
*/
536+
public function testIdentityProfileReportAttributeShouldBeAddedToProfile()
537+
{
538+
$json = file_get_contents(TestData::IDENTITY_PROFILE_ATTRIBUTE);
539+
540+
$protobufAttribute = new \Yoti\Protobuf\Attrpubapi\Attribute([
541+
'name' => UserProfile::ATTR_IDENTITY_PROFILE_REPORT,
542+
'value' => $json,
543+
'content_type' => self::CONTENT_TYPE_JSON,
544+
]);
545+
546+
$attr = AttributeConverter::convertToYotiAttribute($protobufAttribute);
547+
548+
$this->assertEquals(json_decode($json, true), $attr->getValue());
549+
}
550+
532551
/**
533552
* Creates a nested MultiValue Value.
534553
*

tests/TestData.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class TestData
2020
public const YOTI_CONNECT_TOKEN_DECRYPTED = 'i79CctmY-22ad195c-d166-49a2-af16-8f356788c9dd' .
2121
'-be094d26-19b5-450d-afce-070101760f0b';
2222
public const MULTI_VALUE_ATTRIBUTE = __DIR__ . '/sample-data/attributes/multi-value.txt';
23+
public const IDENTITY_PROFILE_ATTRIBUTE = __DIR__ . '/sample-data/attributes/identity-profile-report.json';
2324
public const EXTRA_DATA_CONTENT = __DIR__ . '/sample-data/extra-data-content.txt';
2425
public const THIRD_PARTY_ATTRIBUTE = __DIR__ . '/sample-data/attributes/third-party-attribute.txt';
2526
public const PEM_AUTH_KEY = __DIR__ . '/sample-data/pem-auth-key.txt';
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
{
2+
"identity_assertion": {
3+
"current_name": {
4+
"given_names": "JOHN JIM FRED",
5+
"first_name": "JOHN",
6+
"middle_name": "JIM FRED",
7+
"family_name": "FOO",
8+
"full_name": "JOHN JIM FRED FOO"
9+
},
10+
"date_of_birth": "1979-01-01"
11+
},
12+
"verification_report": {
13+
"report_id": "61b99534-116d-4a25-9750-2d708c0fb168",
14+
"timestamp": "2022-01-02T15:04:05Z",
15+
"subject_id": "f0726cb6-97c1-4802-9feb-eb7c6cd07949",
16+
"trust_framework": "UK_TFIDA",
17+
"schemes_compliance": [
18+
{
19+
"scheme": {
20+
"type": "RTW"
21+
},
22+
"requirements_met": true
23+
}
24+
],
25+
"assurance_process": {
26+
"level_of_assurance": "MEDIUM",
27+
"policy": "GPG45",
28+
"procedure": "M1C",
29+
"assurance": [
30+
{
31+
"type": "EVIDENCE_STRENGTH",
32+
"classification": "4",
33+
"evidence_links": [
34+
"41960172-ca91-487c-8bb3-2c547f80fe54"
35+
]
36+
},
37+
{
38+
"type": "EVIDENCE_VALIDITY",
39+
"classification": "3",
40+
"evidence_links": [
41+
"41960172-ca91-487c-8bb3-2c547f80fe54"
42+
]
43+
},
44+
{
45+
"type": "VERIFICATION",
46+
"classification": "3",
47+
"evidence_links": [
48+
"41960172-ca91-487c-8bb3-2c547f80fe54",
49+
"fb0880ca-5dd5-4776-badb-17549123c50b"
50+
]
51+
}
52+
]
53+
},
54+
"evidence": {
55+
"documents": [
56+
{
57+
"evidence_id": "41960172-ca91-487c-8bb3-2c547f80fe54",
58+
"timestamp": "2022-01-02T15:04:05Z",
59+
"document_fields": {
60+
"full_name": "JOHN JIM FRED FOO",
61+
"date_of_birth": "1979-01-01",
62+
"nationality": "GBR",
63+
"given_names": "JOHN JIM FRED",
64+
"family_name": "FOO",
65+
"place_of_birth": "SAMPLETOWN",
66+
"gender": "MALE",
67+
"document_type": "PASSPORT",
68+
"issuing_country": "GBR",
69+
"document_number": "123456789",
70+
"expiration_date": "2030-01-01",
71+
"date_of_issue": "2020-01-01",
72+
"issuing_authority": "HMPO",
73+
"mrz": {
74+
"type": 2,
75+
"line1": "P<GBRFOO<<JOHN<JIM<FRED<<<<<<<<<<<<<<<<<<<<<",
76+
"line2": "1234567892GBR7901018M3001215<<<<<<<<<<<<<<02"
77+
}
78+
},
79+
"passed_checks": [
80+
{
81+
"check": "CHIP_DIGITAL_SIGNATURE"
82+
},
83+
{
84+
"check": "AUTOMATED_FACE_MATCH"
85+
},
86+
{
87+
"check": "FRAUD_DOCUMENTS_LIST"
88+
}
89+
],
90+
"verifying_org": "Yoti Ltd.",
91+
"user_activity_ids": [
92+
"d4764f67-2992-4a69-9ff4-55b0e77cb3d0"
93+
],
94+
"document_images_attribute_id": "f253c8ab-f07b-4aeb-9dd0-50e670c7ebaf"
95+
}
96+
],
97+
"face_capture": {
98+
"evidence_id": "fb0880ca-5dd5-4776-badb-17549123c50b",
99+
"initial_liveness": {
100+
"type": "ACTIVE",
101+
"timestamp": "2022-01-02T15:04:05Z"
102+
},
103+
"verifying_org": "Yoti Ltd.",
104+
"user_activity_ids": [
105+
"a8e41187-7f5b-4e83-83d5-dc471452f1a8"
106+
],
107+
"selfie_attribute_id": "cc507f84-f1aa-476a-877b-850e949e0fc8"
108+
}
109+
}
110+
},
111+
"authentication_report": {
112+
"report_id": "d7202b65-657e-47a7-9679-7596db617b8c",
113+
"timestamp": "2022-01-02T15:04:05Z",
114+
"policy": "GPG44",
115+
"level": "MEDIUM"
116+
},
117+
"proof": "<signature provided here>"
118+
}

0 commit comments

Comments
 (0)