Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
472c776
config: Add configuration for GitHub Dependabot
jtrh Jul 7, 2020
e1aaf2b
Merge pull request #122 from fyntex/feature/add-dependabot
jtrh Jul 7, 2020
7e9e750
build(deps): bump tox from 3.14.6 to 3.16.1
dependabot[bot] Jul 7, 2020
06dca47
Merge pull request #124 from fyntex/dependabot/pip/tox-3.16.1
jtrh Jul 7, 2020
b56f0e5
config: Verify Python dependency compatibility in CI
jtrh Jul 10, 2020
ef83c8a
Merge pull request #127 from fyntex/feature/check-python-dep-version-…
jtrh Jul 10, 2020
d39151b
build(deps): bump virtualenv from 20.0.16 to 20.0.26
dependabot[bot] Jul 10, 2020
b98c5ae
Merge pull request #126 from fyntex/dependabot/pip/virtualenv-20.0.26
jtrh Jul 10, 2020
518c403
build(deps): bump six from 1.14.0 to 1.15.0
dependabot[bot] Jul 10, 2020
f425bee
Merge pull request #123 from fyntex/dependabot/pip/six-1.15.0
jtrh Jul 13, 2020
a1bc349
requirements: update 'signxml'
jtrh Jul 20, 2020
1b32d4b
Merge pull request #131 from fyntex/feature/update-signxml
jtrh Jul 22, 2020
861bc5c
Add sub-package `rtc`
jtrh Sep 10, 2020
58325a1
Merge pull request #134 from fyntex/feature/add-rtc
jtrh Sep 11, 2020
8d09960
build(deps): bump codecov from 2.0.22 to 2.1.9
dependabot[bot] Sep 14, 2020
e761c84
Merge pull request #133 from fyntex/dependabot/pip/codecov-2.1.9
jtrh Sep 14, 2020
e90e0e6
build(deps): bump toml from 0.10.0 to 0.10.1
dependabot[bot] Sep 14, 2020
8db0c00
Merge pull request #129 from fyntex/dependabot/pip/toml-0.10.1
jtrh Sep 14, 2020
0c5a0f9
rtc.constants: Add `RolContribuyenteEnCesion`
jtrh Sep 15, 2020
1675ade
rtc.constants: Add `TIPO_DTE_CEDIBLES`
jtrh Sep 15, 2020
73ccd65
Merge pull request #135 from fyntex/feature/rtc/add-constants
jtrh Sep 15, 2020
a0500a5
config: Add PyPI package uploading to CI
jtrh Sep 15, 2020
eeabce4
Merge pull request #138 from fyntex/feature/upload-to-pypi-from-ci
jtrh Sep 15, 2020
18abd31
HISTORY: update for new version
jtrh Sep 15, 2020
522aa23
Bump version: 0.10.1 → 0.11.0
jtrh Sep 15, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.10.1
current_version = 0.11.0
commit = True
tag = True

Expand Down
64 changes: 64 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@
#
version: "2.1"

# -----BEGIN Environment Variables-----

# Environment variables required for deployment:
#
# - PYPI_PASSWORD := PyPI password or API token.
# - PYPI_USERNAME := PyPI username. For API tokens, use "__token__".
# - TWINE_NON_INTERACTIVE := Do not interactively prompt for credentials if they are missing.
# - TWINE_REPOSITORY_URL := The repository (package index) URL to register the package to.

# x-deploy-environment := Deployment environment variables
x-deploy-environment: &x-deploy-environment
TWINE_NON_INTERACTIVE: "true"
TWINE_REPOSITORY_URL: https://upload.pypi.org/legacy/

# -----END Environment Variables-----

jobs:
test:
parameters:
Expand All @@ -34,6 +50,12 @@ jobs:
pip install --upgrade setuptools wheel
pip install -r requirements/test.txt

- run:
name: Check Dependencies
command: |
. venv/bin/activate
pip check

- run:
name: run tests
command: |
Expand Down Expand Up @@ -73,6 +95,12 @@ jobs:
pip install --upgrade setuptools wheel
pip install -r requirements/release.txt

- run:
name: Check Dependencies
command: |
. venv/bin/activate
pip check

- run:
name: make dist
command: |
Expand All @@ -83,6 +111,35 @@ jobs:
path: dist
destination: dist

- persist_to_workspace:
root: ~/repo
paths:
- dist
- venv

deploy:
docker:
- image: python:3.7.2
environment:
<<: *x-deploy-environment

working_directory: ~/repo

steps:
- checkout

- attach_workspace:
at: ~/repo

- deploy:
name: Upload Artifacts to Repository
command: |
. venv/bin/activate

make upload-release \
TWINE_USERNAME="${PYPI_USERNAME:?}" \
TWINE_PASSWORD="${PYPI_PASSWORD:?}"

workflows:
version: 2
ci:
Expand All @@ -95,3 +152,10 @@ workflows:
- "3.7.6"
- "3.8.3"
- dist
- deploy:
requires:
- dist
filters:
branches:
only:
- master
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# GitHub Dependabot Configuration
#
# Documentation:
# https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2

updates:
- package-ecosystem: pip
directory: /
schedule:
interval: daily
time: "08:30"
timezone: America/Santiago
open-pull-requests-limit: 3
labels:
- dependencies
15 changes: 15 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
History
-------

0.11.0 (2020-09-15)
+++++++++++++++++++++++

* (PR #138, 2020-09-15) config: Add PyPI package uploading to CI
* (PR #135, 2020-09-15) rtc: Add constants
* (PR #129, 2020-09-14) build(deps): bump toml from 0.10.0 to 0.10.1
* (PR #133, 2020-09-14) build(deps): bump codecov from 2.0.22 to 2.1.9
* (PR #134, 2020-09-10) Add sub-package `rtc`
* (PR #131, 2020-07-22) requirements: update 'signxml'
* (PR #123, 2020-07-13) build(deps): bump six from 1.14.0 to 1.15.0
* (PR #126, 2020-07-10) build(deps): bump virtualenv from 20.0.16 to 20.0.26
* (PR #127, 2020-07-09) config: Verify Python dependency compatibility in CI
* (PR #124, 2020-07-07) build(deps): bump tox from 3.14.6 to 3.16.1
* (PR #122, 2020-07-07) config: Add configuration for GitHub Dependabot

0.10.1 (2020-06-08)
+++++++++++++++++++++++

Expand Down
2 changes: 1 addition & 1 deletion cl_sii/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"""


__version__ = '0.10.1'
__version__ = '0.11.0'
18 changes: 17 additions & 1 deletion cl_sii/libs/xml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,24 @@ def verify_xml_signature(
try:
# note: by passing 'x509_cert' we override any X.509 certificate information supplied
# by the signature itself.

# note: when an X509Data element is present in the signature and used for verification, but
# a KeyValue element is also present, there is an ambiguity and a security hazard because
# the public key used to sign the document is already encoded in the certificate (which is
# in X509Data), so the verifier must either ignore KeyValue or ensure that it matches what
# is in the certificate. SignXML does not perform that validation and throws an
# 'InvalidInput' error instead.
#
# SII's schema for XML signatures requires both elements to be present, which forces us to
# enable 'ignore_ambiguous_key_info' to bypass the error and validate the signature using
# X509Data only.
#
# Source:
# https://github.com/XML-Security/signxml/commit/ef15da8dbb904f1dedfdd210ae3e0df5da535612
result: signxml.VerifyResult = xml_verifier.verify(
data=tmp_bytes, require_x509=True, x509_cert=trusted_x509_cert_open_ssl)
data=tmp_bytes, require_x509=True, x509_cert=trusted_x509_cert_open_ssl,
ignore_ambiguous_key_info=True,
)

except signxml.exceptions.InvalidDigest as exc:
# warning: catch before 'InvalidSignature' (it is the parent of 'InvalidDigest').
Expand Down
10 changes: 10 additions & 0 deletions cl_sii/rtc/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""
SII RTC/RPETC
=============

Concepts and acronyms used interchangeably:

* "Registro Transferencia de Crédito" (RTC)
* "Registro Público Electrónico de Transferencia de Crédito" (RPETC)
* "Registro Electrónico de Cesión de Créditos"
"""
42 changes: 42 additions & 0 deletions cl_sii/rtc/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import enum
from typing import FrozenSet

from cl_sii.dte.constants import TipoDteEnum


# The collection of "tipo DTE" for which it is possible to "ceder" a "DTE".
# They are defined in a document and also an XML schema.
# - Document "Formato Archivo Electrónico de Cesión (AEC)"
# (http://www.sii.cl/factura_electronica/cesion.pdf) are:
# > Sólo códigos 33, 34, 46 y 43
# - XML element 'CesionDefType/DocumentoCesion/IdDTE/TipoDTE'
# - description: "Tipo de DTE"
# - XML type: 'SiiDte:DTEFacturasType'
# - source:
# https://github.com/fyntex/lib-cl-sii-python/blob/7e1c4b52/cl_sii/data/ref/factura_electronica/schemas-xml/Cesion_v10.xsd#L38-L42
# - XML type 'SiiDte:DTEFacturasType' in official schema 'SiiTypes_v10.xsd'
# - source:
# https://github.com/fyntex/lib-cl-sii-python/blob/7e1c4b52/cl_sii/data/ref/factura_electronica/schemas-xml/SiiTypes_v10.xsd#L100-L126
TIPO_DTE_CEDIBLES: FrozenSet[TipoDteEnum] = frozenset({
TipoDteEnum.FACTURA_ELECTRONICA,
TipoDteEnum.FACTURA_NO_AFECTA_O_EXENTA_ELECTRONICA,
TipoDteEnum.FACTURA_COMPRA_ELECTRONICA,
TipoDteEnum.LIQUIDACION_FACTURA_ELECTRONICA,
})


@enum.unique
class RolContribuyenteEnCesion(enum.Enum):

"""
"Rol" of "contribuyente" in a "cesion".
"""

CEDENTE = 'CEDENTE'
"""Cesiones en las que el contribuyente ha sido cedente i.e. ha cedido"""

CESIONARIO = 'CESIONARIO'
"""Cesiones en las que el contribuyente ha sido cesionario i.e. le han cedido"""

DEUDOR = 'DEUDOR'
"""Cesiones de DTEs en que el contribuyente es el deudor."""
3 changes: 3 additions & 0 deletions docs/project-maintenance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ Push commit ``abcd1234`` and tag ``vX.Y.Z`` automatically created by ``bumpversi
4) Publish to PyPI
+++++++++++++++++++

.. warning::
Only perform this step if the CI system failed to upload the package.

(local workstation)

Run::
Expand Down
7 changes: 2 additions & 5 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ lxml==4.5.0
marshmallow==2.19.5
pyOpenSSL==18.0.0
pytz==2019.3
signxml==2.6.0
signxml==2.8.0

# Packages dependencies:
# - cryptography:
Expand All @@ -24,16 +24,13 @@ signxml==2.6.0
# - setuptools
# - six
# - signxml:
# - asn1crypto
# - certifi
# - cryptography
# - defusedxml
# - eight
# - future
# - lxml
# - pyOpenSSL
# - six
asn1crypto==1.3.0
attrs==19.3.0
certifi==2020.4.5.1
cffi==1.14.0
Expand All @@ -43,5 +40,5 @@ importlib-metadata==1.6.0; python_version<'3.8'
pycparser==2.20
pyrsistent==0.16.0
# setuptools
six==1.14.0
six==1.15.0
zipp==3.1.0
8 changes: 4 additions & 4 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
-r extras.txt

# Required packages:
codecov==2.0.22
codecov==2.1.9
coverage==4.5.3
flake8==3.7.9
mypy==0.770
tox==3.14.6
tox==3.16.1

# Packages dependencies:
# - codecov:
Expand Down Expand Up @@ -60,9 +60,9 @@ pyflakes==2.1.1
# pyparsing
# requests
# six
toml==0.10.0
toml==0.10.1
typed-ast==1.4.1
typing-extensions==3.7.4.2
# urllib3
virtualenv==20.0.16
virtualenv==20.0.26
# zipp
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ def get_version(*file_paths: Sequence[str]) -> str:
'jsonschema>=3.1.1',
'lxml>=4.5.0,<5',
'marshmallow>=2.19.2,<3',
# TODO: remove upper-bound after a new release of 'signxml' drops the requirement 'pyOpenSSL<19'
'pyOpenSSL>=18.0.0,<19',
# TODO: remove upper-bound after a new release of 'signxml' drops the requirement 'pyOpenSSL<20'
'pyOpenSSL>=18.0.0,<20',
'pytz>=2019.3',
'signxml>=2.6.0',
'signxml>=2.8.0',
]

extras_requirements = {
Expand Down
15 changes: 15 additions & 0 deletions tests/test_rtc_constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import unittest

from cl_sii.rtc.constants import TIPO_DTE_CEDIBLES


class TipoDteCediblesTest(unittest.TestCase):

# For 'TIPO_DTE_CEDIBLES'

def test_all_are_factura(self) -> None:
for element in TIPO_DTE_CEDIBLES:
self.assertTrue(element.is_factura)

# TODO: implement test that check that the values correspond to those defined in
# XML type 'SiiDte:DTEFacturasType' in official schema 'SiiTypes_v10.xsd'.