2
2
3
3
from datetime import datetime
4
4
import os .path
5
+ import base64
5
6
6
7
from yoti_python_sdk .share .extra_data import ExtraData
7
8
from yoti_python_sdk .tests import file_helper
@@ -24,7 +25,7 @@ def create_third_party_test_data(token_value, expiry_date, *definitions):
24
25
issuing_attributes .definitions .extend ([name ])
25
26
26
27
attribute = ThirdPartyAttribute_pb2 .ThirdPartyAttribute ()
27
- attribute .issuance_token = str ( token_value ) .encode ("utf-8" )
28
+ attribute .issuance_token = token_value .encode ("utf-8" )
28
29
attribute .issuing_attributes .MergeFrom (issuing_attributes )
29
30
30
31
data_entry = DataEntry_pb2 .DataEntry ()
@@ -66,7 +67,9 @@ def test_should_return_first_matching_third_party_attribute():
66
67
create_extra_data ([thirdparty_attribute1 , thirdparty_attribute2 ])
67
68
)
68
69
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
+ )
70
73
assert (
71
74
parsed_extra_data .attribute_issuance_details .attributes [0 ].name
72
75
== "attributeName1"
@@ -79,7 +82,7 @@ def test_should_parse_multiple_issuing_attributes():
79
82
80
83
result = extra_data .attribute_issuance_details
81
84
assert result is not None
82
- assert result .token == "someIssuanceToken"
85
+ assert result .token == base64 . b64encode ( "someIssuanceToken" . encode ( "utf-8" ))
83
86
assert result .expiry_date == datetime (2019 , 10 , 15 , 22 , 4 , 5 , 123000 )
84
87
assert result .attributes [0 ].name == "com.thirdparty.id"
85
88
assert result .attributes [1 ].name == "com.thirdparty.other_id"
@@ -103,7 +106,7 @@ def test_should_handle_no_issuing_attributes():
103
106
extra_data = ExtraData (create_extra_data ([thirdparty_attribute ]))
104
107
105
108
result = extra_data .attribute_issuance_details
106
- assert result .token == " tokenValue"
109
+ assert result .token == base64 . b64encode ( tokenValue . encode ( "utf-8" ))
107
110
assert len (result .attributes ) == 0
108
111
109
112
@@ -116,6 +119,6 @@ def test_should_handle_no_issuing_attribute_definitions():
116
119
extra_data = ExtraData (create_extra_data ([thirdparty_attribute ]))
117
120
118
121
result = extra_data .attribute_issuance_details
119
- assert result .token == tokenValue
122
+ assert result .token == base64 . b64encode ( tokenValue . encode ( "utf-8" ))
120
123
assert result .expiry_date == expiry_date
121
124
assert len (result .attributes ) == 0
0 commit comments