22
33from datetime import datetime
44import os .path
5+ import base64
56
67from yoti_python_sdk .share .extra_data import ExtraData
78from yoti_python_sdk .tests import file_helper
@@ -24,7 +25,7 @@ def create_third_party_test_data(token_value, expiry_date, *definitions):
2425 issuing_attributes .definitions .extend ([name ])
2526
2627 attribute = ThirdPartyAttribute_pb2 .ThirdPartyAttribute ()
27- attribute .issuance_token = str ( token_value ) .encode ("utf-8" )
28+ attribute .issuance_token = token_value .encode ("utf-8" )
2829 attribute .issuing_attributes .MergeFrom (issuing_attributes )
2930
3031 data_entry = DataEntry_pb2 .DataEntry ()
@@ -66,7 +67,9 @@ def test_should_return_first_matching_third_party_attribute():
6667 create_extra_data ([thirdparty_attribute1 , thirdparty_attribute2 ])
6768 )
6869
69- assert parsed_extra_data .attribute_issuance_details .token == "tokenValue1"
70+ assert parsed_extra_data .attribute_issuance_details .token == base64 .b64encode (
71+ "tokenValue1" .encode ("utf-8" )
72+ )
7073 assert (
7174 parsed_extra_data .attribute_issuance_details .attributes [0 ].name
7275 == "attributeName1"
@@ -79,7 +82,7 @@ def test_should_parse_multiple_issuing_attributes():
7982
8083 result = extra_data .attribute_issuance_details
8184 assert result is not None
82- assert result .token == "someIssuanceToken"
85+ assert result .token == base64 . b64encode ( "someIssuanceToken" . encode ( "utf-8" ))
8386 assert result .expiry_date == datetime (2019 , 10 , 15 , 22 , 4 , 5 , 123000 )
8487 assert result .attributes [0 ].name == "com.thirdparty.id"
8588 assert result .attributes [1 ].name == "com.thirdparty.other_id"
@@ -103,7 +106,7 @@ def test_should_handle_no_issuing_attributes():
103106 extra_data = ExtraData (create_extra_data ([thirdparty_attribute ]))
104107
105108 result = extra_data .attribute_issuance_details
106- assert result .token == " tokenValue"
109+ assert result .token == base64 . b64encode ( tokenValue . encode ( "utf-8" ))
107110 assert len (result .attributes ) == 0
108111
109112
@@ -116,6 +119,6 @@ def test_should_handle_no_issuing_attribute_definitions():
116119 extra_data = ExtraData (create_extra_data ([thirdparty_attribute ]))
117120
118121 result = extra_data .attribute_issuance_details
119- assert result .token == tokenValue
122+ assert result .token == base64 . b64encode ( tokenValue . encode ( "utf-8" ))
120123 assert result .expiry_date == expiry_date
121124 assert len (result .attributes ) == 0
0 commit comments