# Path: esteid/constants.py
# OCSP_DEMO_URL = "http://demo.sk.ee/ocsp"
# 
# TSA_DEMO_URL = "http://demo.sk.ee/tsa/"
# 
# Path: esteid/exceptions.py
# class ActionInProgress(EsteidError):
#     """
#     Raised when a request to the service is still in pending status,
#     or when it is necessary to move on to the next step while passing some data on to the user
#     (like after successful auth, we initiate a signing request and display verification code)
#     """
# 
#     status = HTTPStatus.ACCEPTED
# 
#     default_message = _("Operation is in progress.")
# 
#     def __init__(self, message=None, data: dict = None):
#         super().__init__(message)
#         self.data = data or {}
# 
# Path: esteid/mobileid/types.py
# PHONE_NUMBER_REGEXP = settings.MOBILE_ID_PHONE_NUMBER_REGEXP
# class UserInput(PredictableDict):
# class MobileIdSessionData(InterimSessionData):
#     def is_valid(self, raise_exception=True):


from time import sleep, time
from esteid_certificates import get_certificate
from pyasice import Container, XmlSignature
from pyasice.ocsp import OCSP
from pyasice.tsa import TSA
from ...constants import OCSP_DEMO_URL, TSA_DEMO_URL
from ...exceptions import ActionInProgress
from ..types import SignResult, SignStatusResult
import pytest
    Note: This does a number of real connections to Smart-ID apis so it's marked as a slow test
    """
    file_name = "test.txt"
    data = b"Hello World!"
    mime_type = "text/plain"

    # Authenticate user
    user_cert = demo_mid_api.get_certificate(MID_DEMO_PIN_EE_OK, MID_DEMO_PHONE_EE_OK)

    # Generate a XAdES signature
    xs: XmlSignature = (
        XmlSignature.create().add_document(file_name, data, mime_type).set_certificate(user_cert).update_signed_info()
    )

    # Sign the XAdES structure
    sign_result = run_sign_flow(
        demo_mid_api,
        user_cert,
        id_number=MID_DEMO_PIN_EE_OK,
        phone_number=MID_DEMO_PHONE_EE_OK,
        signed_data=xs.signed_data(),
    )
    xs.set_signature_value(sign_result.signature)

    # prove that all went right
    xs.verify()

    # Get an OCSP status confirmation
    issuer_cert = get_certificate(xs.get_certificate_issuer_common_name())


# Path: esteid/constants.py
# OCSP_DEMO_URL = "http://demo.sk.ee/ocsp"
# 
# TSA_DEMO_URL = "http://demo.sk.ee/tsa/"
# 
# Path: esteid/exceptions.py
# class ActionInProgress(EsteidError):
#     """
#     Raised when a request to the service is still in pending status,
#     or when it is necessary to move on to the next step while passing some data on to the user
#     (like after successful auth, we initiate a signing request and display verification code)
#     """
# 
#     status = HTTPStatus.ACCEPTED
# 
#     default_message = _("Operation is in progress.")
# 
#     def __init__(self, message=None, data: dict = None):
#         super().__init__(message)
#         self.data = data or {}
# 
# Path: esteid/mobileid/types.py
# PHONE_NUMBER_REGEXP = settings.MOBILE_ID_PHONE_NUMBER_REGEXP
# class UserInput(PredictableDict):
# class MobileIdSessionData(InterimSessionData):
#     def is_valid(self, raise_exception=True):


# Path: esteid/mobileid/tests/test_signing.py
from time import sleep, time
from esteid_certificates import get_certificate
from pyasice import Container, XmlSignature
from pyasice.ocsp import OCSP
from pyasice.tsa import TSA
from ...constants import OCSP_DEMO_URL, TSA_DEMO_URL
from ...exceptions import ActionInProgress
from ..types import SignResult, SignStatusResult
import pytest

    Note: This does a number of real connections to Smart-ID apis so it's marked as a slow test
    """
    file_name = "test.txt"
    data = b"Hello World!"
    mime_type = "text/plain"

    # Authenticate user
    user_cert = demo_mid_api.get_certificate(MID_DEMO_PIN_EE_OK, MID_DEMO_PHONE_EE_OK)

    # Generate a XAdES signature
    xs: XmlSignature = (
        XmlSignature.create().add_document(file_name, data, mime_type).set_certificate(user_cert).update_signed_info()
    )

    # Sign the XAdES structure
    sign_result = run_sign_flow(
        demo_mid_api,
        user_cert,
        id_number=MID_DEMO_PIN_EE_OK,
        phone_number=MID_DEMO_PHONE_EE_OK,
        signed_data=xs.signed_data(),
    )
    xs.set_signature_value(sign_result.signature)

    # prove that all went right
    xs.verify()

    # Get an OCSP status confirmation
    issuer_cert = get_certificate(xs.get_certificate_issuer_common_name())


    ocsp = OCSP(url=OCSP_DEMO_URL)