Skip to content

Commit bcf8dd3

Browse files
committed
SDK-1098: Update tests for checking ApplicationProfile functionality and rename some internal variables to make it more clear which profile data is which
1 parent ba1fa71 commit bcf8dd3

File tree

3 files changed

+89
-6
lines changed

3 files changed

+89
-6
lines changed

yoti_python_sdk/client.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,20 @@ def get_activity_details(self, encrypted_request_token):
8484
return ActivityDetails(receipt)
8585

8686
unwrapped_key = self.__crypto.decrypt_token(receipt["wrapped_receipt_key"])
87-
decrypted_data = self.__crypto.decipher(
87+
88+
decrypted_profile_data = self.__crypto.decipher(
8889
unwrapped_key, encrypted_data.iv, encrypted_data.cipher_text
8990
)
9091
decrypted_application_data = self.__crypto.decipher(
9192
unwrapped_key, encrypted_application_profile.iv, encrypted_application_profile.cipher_text
9293
)
9394

94-
attribute_list = proto.attribute_list(decrypted_data)
95-
application_attribute_list = proto.attribute_list(decrypted_application_data)
96-
return ActivityDetails(receipt, attribute_list, decrypted_application_profile=application_attribute_list)
95+
user_profile_attribute_list = proto.attribute_list(decrypted_profile_data)
96+
application_profile_attribute_list = proto.attribute_list(decrypted_application_data)
97+
98+
return ActivityDetails(
99+
receipt, user_profile_attribute_list, decrypted_application_profile=application_profile_attribute_list
100+
)
97101

98102
def perform_aml_check(self, aml_profile):
99103
if aml_profile is None:

yoti_python_sdk/profile.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from yoti_python_sdk.image import Image
88
from yoti_python_sdk import document_details
99

10+
1011
class BaseProfile(object):
1112

1213
def __init__(self, profile_attributes):
@@ -45,7 +46,8 @@ def __init__(self, profile_attributes):
4546
)
4647

4748
def get_attribute(self, attribute_name):
48-
"""retrieves an attribute based on its name
49+
"""
50+
retrieves an attribute based on its name
4951
:param attribute_name:
5052
:return: Attribute
5153
"""
@@ -194,12 +196,24 @@ def application_name(self):
194196

195197
@property
196198
def application_url(self):
199+
"""
200+
application_url is the url of the application set in Yoti Hub
201+
:return: Attribute(str)
202+
"""
197203
return self.get_attribute(config.ATTRIBUTE_APPLICATION_URL)
198204

199205
@property
200206
def application_logo(self):
207+
"""
208+
application_logo is the Image of the application logo set in Yoti Hub
209+
:return: Attribute(str)
210+
"""
201211
return self.get_attribute(config.ATTRIBUTE_APPLICATION_LOGO)
202212

203213
@property
204214
def application_receipt_bg_color(self):
215+
"""
216+
application_receipt_bg_color is the background color of the application set in Yoti Hub
217+
:return: Attribute(str)
218+
"""
205219
return self.get_attribute(config.ATTRIBUTE_APPLICATION_RECEIPT_BGCOLOR)

yoti_python_sdk/tests/test_profile.py

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77

88
from yoti_python_sdk import config
99
from yoti_python_sdk.attribute import Attribute
10-
from yoti_python_sdk.profile import Profile
10+
from yoti_python_sdk.profile import Profile, ApplicationProfile
1111
from yoti_python_sdk.protobuf.protobuf import Protobuf
1212
from yoti_python_sdk.tests import attribute_fixture_parser, image_helper
1313
from yoti_python_sdk.tests.protobuf_attribute import ProtobufAttribute
14+
from yoti_python_sdk.image import Image
1415

1516
ADDRESS_FORMAT_KEY = "address_format"
1617
ADDRESS_FORMAT_VALUE = 1
@@ -92,6 +93,15 @@ def create_attribute_list_with_selfie_field():
9293
)
9394

9495

96+
def create_attribute_list_with_application_logo():
97+
return create_single_attribute_list(
98+
name=config.ATTRIBUTE_APPLICATION_LOGO,
99+
value="base64(┛ಠ_ಠ)┛彡┻━┻",
100+
anchors=None,
101+
content_type=Protobuf.CT_JPEG,
102+
)
103+
104+
95105
def create_attribute_list_with_email_field():
96106
return create_single_attribute_list(
97107
name=config.ATTRIBUTE_EMAIL_ADDRESS,
@@ -587,3 +597,58 @@ def test_get_document_details_india():
587597
assert document.issuing_country == INDIA_COUNTRY_ISO_VALUE
588598
assert document.document_number == IND_DRIVING_LICENCE_NUMBER
589599
assert document.expiration_date.isoformat() == EXPIRY_DATE
600+
601+
602+
def test_create_application_profile_with_name():
603+
attribute_list = create_single_attribute_list(
604+
name=config.ATTRIBUTE_APPLICATION_NAME,
605+
value="yoti-sdk-test",
606+
anchors=None,
607+
content_type=Protobuf.CT_STRING
608+
)
609+
610+
app_profile = ApplicationProfile(attribute_list)
611+
612+
assert (app_profile.get_attribute(config.ATTRIBUTE_APPLICATION_NAME) == app_profile.application_name)
613+
assert isinstance(app_profile, ApplicationProfile)
614+
615+
616+
def test_create_application_profile_with_url():
617+
attribute_list = create_single_attribute_list(
618+
name=config.ATTRIBUTE_APPLICATION_URL,
619+
value="https://yoti.com",
620+
anchors=None,
621+
content_type=Protobuf.CT_STRING
622+
)
623+
624+
app_profile = ApplicationProfile(attribute_list)
625+
626+
assert (app_profile.get_attribute(config.ATTRIBUTE_APPLICATION_URL) == app_profile.application_url)
627+
assert isinstance(app_profile, ApplicationProfile)
628+
629+
630+
def test_create_application_profile_with_receipt_bgcolor():
631+
attribute_list = create_single_attribute_list(
632+
name=config.ATTRIBUTE_APPLICATION_RECEIPT_BGCOLOR,
633+
value="#FFFFFF",
634+
anchors=None,
635+
content_type=Protobuf.CT_STRING
636+
)
637+
638+
app_profile = ApplicationProfile(attribute_list)
639+
640+
assert (app_profile.get_attribute(config.ATTRIBUTE_APPLICATION_RECEIPT_BGCOLOR) == app_profile.application_receipt_bg_color)
641+
assert isinstance(app_profile, ApplicationProfile)
642+
643+
644+
def test_create_application_profile_with_logo():
645+
attribute_list = create_attribute_list_with_application_logo()
646+
647+
app_profile = ApplicationProfile(attribute_list)
648+
app_logo = app_profile.application_logo
649+
650+
assert isinstance(app_logo.value, Image)
651+
assert (app_profile.get_attribute(config.ATTRIBUTE_APPLICATION_LOGO) == app_profile.application_logo)
652+
assert isinstance(app_profile, ApplicationProfile)
653+
654+

0 commit comments

Comments
 (0)