text: import json
  import os
  import unittest
  from dateutil import parser
  
  from src.hanko_sdk import json_serializer
  from src.hanko_sdk.models.assertion import AuthenticatorAssertionResponse
  from src.hanko_sdk.models.attachment import UserVerificationRequirement, AuthenticatorAttachment
  from src.hanko_sdk.models.authenticator import AuthenticatorTransport
  from src.hanko_sdk.models.base64_entities import UrlEncodedBase64
  from src.hanko_sdk.models.challenge import Challenge
  from src.hanko_sdk.models.core import User, Credential, Authenticator
  from src.hanko_sdk.models.datetime_model import DateTime
  from src.hanko_sdk.models.options import AuthenticationInitializationRequestOptions, PublicKeyCredentialRequestOptions, \
      CredentialDescriptor, CredentialType
  from src.hanko_sdk.models.transaction_finalization import TransactionFinalizationRequest, \
      TransactionFinalizationResponse
  from src.hanko_sdk.models.transaction_initialization import TransactionInitializationRequest, \
      TransactionInitializationResponse
  
  
  class TransactionInitializationTest(unittest.TestCase):
  
      def test_transaction_initialization_request_is_correctly_deserialized(self):
          file_path = os.path.join("tests", "hanko_sdk", "serialization", "test_cases", "TransactionInitializationRequestTC1.json")
  
          with open(file_path, "r") as input_file:
              actual_object = json_serializer.deserialize_file(input_file, TransactionInitializationRequest)
  
              expected_object = TransactionInitializationRequest(
                  User(
                      "user1"
                  ),
                  "Pay 5$ to Bob?",
                  AuthenticationInitializationRequestOptions(
                      UserVerificationRequirement.DISCOURAGED,
                      AuthenticatorAttachment.CROSS_PLATFORM
                  )
              )
  
              self.assertEqual(expected_object, actual_object)
  
      def test_transaction_initialization_request_is_correctly_serialized(self):
          file_path = os.path.join("tests", "hanko_sdk", "serialization", "test_cases", "TransactionInitializationRequestTC1.json")
  
          with open(file_path, "r") as input_file:
              expected_object = json.dumps(json.load(input_file), sort_keys=True)
  
              actual_object = TransactionInitializationRequest(
                  User(
                      "user1"
                  ),
                  "Pay 5$ to Bob?",
                  AuthenticationInitializationRequestOptions(
                      UserVerificationRequirement.DISCOURAGED,
                      AuthenticatorAttachment.CROSS_PLATFORM
                  )
              )
  
              actual_object_json = json_serializer.serialize(actual_object, sort_keys=True)
  
              self.assertEqual(expected_object, actual_object_json)
  
      def test_transaction_initialization_response_is_correctly_deserialized(self):
          file_path = os.path.join("tests", "hanko_sdk", "serialization", "test_cases", "TransactionInitializationResponseTC1.json")
  
          with open(file_path, "r") as input_file:
              actual_object = json_serializer.deserialize_file(input_file, TransactionInitializationResponse)
  
              expected_object = TransactionInitializationResponse(
                  PublicKeyCredentialRequestOptions(
                      Challenge.from_utf8_string("challengeString"),
                      45678,
                      "testRpId",
                      [
                          CredentialDescriptor(
                              CredentialType.PUBLIC_KEY,
                              UrlEncodedBase64.from_utf8_string("credential1"),
                              [
                                  AuthenticatorTransport.NFC
                              ]
                          )
                      ],
                      UserVerificationRequirement.PREFERRED
                  )
              )
  
              self.assertEqual(expected_object, actual_object)
  
      def test_transaction_initialization_response_is_correctly_serialized(self):
          file_path = os.path.join("tests", "hanko_sdk", "serialization", "test_cases", "TransactionInitializationResponseTC1.json")
  
          with open(file_path, "r") as input_file:
              expected_object = json.dumps(json.load(input_file), sort_keys=True)
  
              actual_object = TransactionInitializationResponse(
                  PublicKeyCredentialRequestOptions(
                      Challenge.from_utf8_string("challengeString"),
                      45678,
                      "testRpId",
                      [
                          CredentialDescriptor(
                              CredentialType.PUBLIC_KEY,
                              UrlEncodedBase64.from_utf8_string("credential1"),
                              [
                                  AuthenticatorTransport.NFC
                              ]
                          )
                      ],
                      UserVerificationRequirement.PREFERRED
                  )
              )
  
              actual_object_json = json_serializer.serialize(actual_object, sort_keys=True)
  
              self.assertEqual(expected_object, actual_object_json)
  
  
  class TransactionFinalizationTest(unittest.TestCase):
  
      def test_transaction_finalization_request_is_correctly_deserialized(self):
          file_path = os.path.join("tests", "hanko_sdk", "serialization", "test_cases", "TransactionFinalizationRequestTC1.json")
  
          with open(file_path, "r") as input_file:
              actual_object = json_serializer.deserialize_file(input_file, TransactionFinalizationRequest)
  
              expected_object = TransactionFinalizationRequest(
                  "tId12345",
                  CredentialType.PUBLIC_KEY,
                  UrlEncodedBase64.from_utf8_string("tId12345"),
                  None,
                  AuthenticatorAssertionResponse(
                      UrlEncodedBase64.from_utf8_string("testData"),
                      UrlEncodedBase64.from_utf8_string("testAuthenticatorData"),
                      UrlEncodedBase64.from_utf8_string("testSignature"),
                      UrlEncodedBase64.from_utf8_string("testUserHandle")
                  )
              )
  
              self.assertEqual(expected_object, actual_object)
  
      def test_transaction_finalization_request_is_correctly_serialized(self):
          file_path = os.path.join("tests", "hanko_sdk", "serialization", "test_cases", "TransactionFinalizationRequestTC1.json")
  
          with open(file_path, "r") as input_file:
              expected_object = json.dumps(json.load(input_file), sort_keys=True)
  
              actual_object = TransactionFinalizationRequest(
                  "tId12345",
                  CredentialType.PUBLIC_KEY,
                  UrlEncodedBase64.from_utf8_string("tId12345"),
                  None,
                  AuthenticatorAssertionResponse(
                      UrlEncodedBase64.from_utf8_string("testData"),
                      UrlEncodedBase64.from_utf8_string("testAuthenticatorData"),
                      UrlEncodedBase64.from_utf8_string("testSignature"),
                      UrlEncodedBase64.from_utf8_string("testUserHandle")
                  )
              )
  
              actual_object_json = json_serializer.serialize(actual_object, sort_keys=True)
  
              self.assertEqual(expected_object, actual_object_json)
  
      def test_transaction_finalization_response_is_correctly_deserialized(self):
          file_path = os.path.join("tests", "hanko_sdk", "serialization", "test_cases", "TransactionFinalizationResponseTC1.json")
  
          with open(file_path, "r") as input_file:
              actual_object = json_serializer.deserialize_file(input_file, TransactionFinalizationResponse)
  
              expected_object = TransactionFinalizationResponse(
                  Credential(
                      "59b3a1a3-8550-43a1-8a85-59537e8c4332",
                      DateTime(parser.parse("2012-08-24T14:15:22Z")),
                      DateTime(parser.parse("2012-08-25T14:15:22Z")),
                      "Credential 1",
                      False,
                      False,
                      Authenticator(
                          "e263c88c-bd50-489e-aacd-e4ea31523281",
                          "Authenticator Model 2",
                          AuthenticatorAttachment.CROSS_PLATFORM
                      ),
                      User(
                         "e3be22a7-13cf-4235-a09c-380dfd44ac04"
                      )
                  )
              )
  
              self.assertEqual(expected_object, actual_object)
  
      def test_transaction_finalization_response_is_correctly_serialized(self):
          file_path = os.path.join("tests", "hanko_sdk", "serialization", "test_cases", "TransactionFinalizationResponseTC1.json")
  
          with open(file_path, "r") as input_file:
              expected_object = json.dumps(json.load(input_file), sort_keys=True)
  
              actual_object = TransactionFinalizationResponse(
                  Credential(
                      "59b3a1a3-8550-43a1-8a85-59537e8c4332",
                      DateTime(parser.parse("2012-08-24T14:15:22Z")),
                      DateTime(parser.parse("2012-08-25T14:15:22Z")),
                      "Credential 1",
                      False,
                      False,
                      Authenticator(
                          "e263c88c-bd50-489e-aacd-e4ea31523281",
                          "Authenticator Model 2",
                          AuthenticatorAttachment.CROSS_PLATFORM
                      ),
                      User(
                         "e3be22a7-13cf-4235-a09c-380dfd44ac04"
                      )
                  )
              )
  
              actual_object_json = json_serializer.serialize(actual_object, sort_keys=True)
  
              self.assertEqual(expected_object, actual_object_json)
  
  
  if __name__ == "__main__":
      unittest.main()
  