Add test signartime - timezone America/Bogota

This commit is contained in:
cosmos 2024-08-23 11:03:38 -05:00
parent fb44498e53
commit 30773e042b
4 changed files with 22 additions and 1 deletions

1
.gitignore vendored
View File

@ -215,3 +215,4 @@ tags
pyvenv.cfg
.venv
pip-selfcheck.json
invoice.xml

View File

@ -1,6 +1,9 @@
# DERIVADO DE https://alextereshenkov.github.io/run-python-tests-with-tox-in-docker.html
FROM ubuntu:24.04
ENV TZ=America/Bogota
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get -qq update
RUN apt install software-properties-common -y \

View File

@ -18,7 +18,7 @@ requirements = ['Click>=8.1.7',
'lxml==5.2.2',
'cryptography==42.0.8',
'pyOpenSSL==24.1.0',
'xmlsig==1.0.1',
'xmlsig==0.1.7',
'xades==1.0.0',
'xmlsec==1.3.14',
# usamos esta dependencia en runtime

View File

@ -116,3 +116,20 @@ def test_xml_sign_dian_using_bytes(monkeypatch):
xmlsigned = signer.sign_xml_string(xmlstring)
assert "Signature" in xmlsigned
def test_xml_signature_timestamp(monkeypatch):
xml = fe.FeXML(
'Invoice',
'http://www.dian.gov.co/contratos/facturaelectronica/v1')
xml.find_or_create_element(
'/fe:Invoice/ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent')
ublextension = xml.fragment(
'/fe:Invoice/ext:UBLExtensions/ext:UBLExtension', append=True)
ublextension.find_or_create_element(
'/ext:UBLExtension/ext:ExtensionContent')
xmlstring = xml.tostring()
signer = fe.DianXMLExtensionSigner('./tests/example.p12')
xmlsigned = signer.sign_xml_string(xmlstring)
with open('invoice.xml', 'w') as file_:
file_.write(xmlsigned)