From cb2fe934ec55ded784fe1fbb65b3ebda9305e042 Mon Sep 17 00:00:00 2001 From: Omari Rodney Date: Sun, 19 Mar 2017 23:05:42 +0000 Subject: [PATCH] Do not try to fetch profiles if there is no content available --- .gitignore | 1 + CHANGELOG.md | 4 ++++ yoti_python_sdk/activity_details.py | 4 ++-- yoti_python_sdk/client.py | 3 +++ yoti_python_sdk/protobuf/v1/protobuf.py | 5 +++-- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index dc1006f6..46b0246e 100644 --- a/.gitignore +++ b/.gitignore @@ -92,3 +92,4 @@ ENV/ # IDE .idea/ *.un~ +.history/ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e8d5717..30b30756 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [1.1.0] - 2017-03-20 +### Changed +- Allow empty profiles + ## [0.1.2] - 2016-11-23 ### Fixed diff --git a/yoti_python_sdk/activity_details.py b/yoti_python_sdk/activity_details.py index 23160b64..92c9a733 100644 --- a/yoti_python_sdk/activity_details.py +++ b/yoti_python_sdk/activity_details.py @@ -3,11 +3,11 @@ class ActivityDetails: - def __init__(self, receipt, decrypted_profile): + def __init__(self, receipt, decrypted_profile = None): self.decrypted_profile = decrypted_profile self.user_profile = {} - if hasattr(decrypted_profile, 'attributes'): + if decrypted_profile and hasattr(decrypted_profile, 'attributes'): for field in decrypted_profile.attributes: value = Protobuf().value_based_on_content_type( field.value, diff --git a/yoti_python_sdk/client.py b/yoti_python_sdk/client.py index 84fd69c7..177af64e 100644 --- a/yoti_python_sdk/client.py +++ b/yoti_python_sdk/client.py @@ -57,6 +57,9 @@ def get_activity_details(self, encrypted_request_token): encrypted_data = protobuf.Protobuf().current_user(receipt) + if not encrypted_data: + return ActivityDetails(receipt) + unwrapped_key = self.__crypto.decrypt_token(receipt['wrapped_receipt_key']) decrypted_data = self.__crypto.decipher( unwrapped_key, diff --git a/yoti_python_sdk/protobuf/v1/protobuf.py b/yoti_python_sdk/protobuf/v1/protobuf.py index a952f631..6f0b4df1 100644 --- a/yoti_python_sdk/protobuf/v1/protobuf.py +++ b/yoti_python_sdk/protobuf/v1/protobuf.py @@ -15,8 +15,9 @@ class Protobuf(object): CT_PNG = 4 # standard .png image def current_user(self, receipt): - if receipt.get('other_party_profile_content') is None: - raise ValueError('The receipt has invalid data') + if receipt.get('other_party_profile_content') is None or receipt.get('other_party_profile_content') == '': + return None + profile_content = receipt['other_party_profile_content'] decoded_profile_content = base64.b64decode(profile_content)