Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed wsaa cryptography merge issues #58

Merged
merged 7 commits into from
Jun 12, 2021
Merged

Conversation

chazuttu
Copy link
Collaborator

Summary

Fixes issues that arose from merging of cryptography changes instead of M2crypto
in wsaa.py as per issue #15 and PR #25 and #53.

This also completes issue 13.

  • enabled inline passing of crt/key in wsaa.py
  • enabled passphrase support
  • added more unit tests for wsaa.py

Checklist

  • Classes, Variables, function and methods logic ok
  • Comments written explaining what the code does
  • All python code is PEP8 compliant (run black .)
  • No lint issues (run flake8)
  • Test coverage with pytest implemented
  • Reviewers assigned (at least 1 mentor)

Manual test evidence

$ python -m pyafipws.wsaa --debug --trace

Encodign in cp1252
Usando CRT=reingart.crt KEY=reingart.key URL=https://wsaahomo.afip.gov.ar/ws/services/LoginCms SERVICE=wsfe TTL=36000
WSAA Version 3.11c  False
Creando TRA...
Firmando TRA...
Conectando a WSAA...
Llamando WSAA...
--------------------------------------------------------------------------------
POST https://wsaahomo.afip.gov.ar/ws/services/LoginCms
Content-type: text/xml; charset="UTF-8"
Content-length: 2722
SOAPAction: "None"

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="https://wsaahomo.afip.gov.ar/ws/services/LoginCms">
<soapenv:Header/>
<soapenv:Body>
    <ser:loginCms>
    <in0>MIIG+.......
........./hxYPLb3RiAyBYaG6uftAmg5w

</in0></ser:loginCms>
</soapenv:Body>
</soapenv:Envelope>

date: Fri, 11 Jun 2021 14:02:28 GMT
content-type: text/xml;charset=utf-8
set-cookie: TS01b14f84=0145b27a97364573b480a490667be52c927711119deaebcd548a359bf9df9a52d14f212231; Path=/
transfer-encoding: chunked
status: 200
b'<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><loginCmsResponse xmlns="https://wsaahomo.afip.gov.ar/ws/services/LoginCms"><loginCmsReturn>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;yes&quot;?&gt;\n&lt;loginTicketResponse version=&quot;1.0&quot;&gt;\n    &lt;header&gt;\n        &lt;source&gt;CN=wsaahomo, O=AFIP, C=AR, SERIALNUMBER=CUIT 33693450239&lt;/source&gt;\n        &lt;destination&gt;SERIALNUMBER=CUIT 20267565393, CN=reingart2019pub&lt;/destination&gt;\n        &lt;uniqueId&gt;3561837960&lt;/uniqueId&gt;\n        &lt;generationTime&gt;2021-06-11T11:02:28.949-03:00&lt;/generationTime&gt;\n        &lt;expirationTime&gt;2021-06-11T23:02:28.949-03:00&lt;/expirationTime&gt;\n    &lt;/header&gt;\n    &lt;credentials&gt;\n        &lt;token&gt;PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/Pgo8c3NvIHZlcnNpb249IjIuMCI+CiAgICA8aWQgc3JjPSJDTj13c2FhaG9tbywgTz1BRklQLCBDPUFSLCBTRVJJQUxOVU1CRVI9Q1VJVCAzMzY5MzQ1MDIzOSIgZHN0PSJDTj13c2ZlLCBPPUFGSVAsIEM9QVIiIHVuaXF1ZV9pZD0iMTk1NDU2NDE2NCIgZ2VuX3RpbWU9IjE2MjM0MjAwODgiIGV4cF90aW1lPSIxNjIzNDYzMzQ4Ii8+CiAgICA8b3BlcmF0aW9uIHR5cGU9ImxvZ2luIiB2YWx1ZT0iZ3JhbnRlZCI+CiAgICAgICAgPGxvZ2luIGVudGl0eT0iMzM2OTM0NTAyMzkiIHNlcnZpY2U9IndzZmUiIHVpZD0iU0VSSUFMTlVNQkVSPUNVSVQgMjAyNjc1NjUzOTMsIENOPXJlaW5nYXJ0MjAxOXB1YiIgYXV0aG1ldGhvZD0iY21zIiByZWdtZXRob2Q9IjIyIj4KICAgICAgICAgICAgPHJlbGF0aW9ucz4KICAgICAgICAgICAgICAgIDxyZWxhdGlvbiBrZXk9IjIwMjY3NTY1MzkzIiByZWx0eXBlPSI0Ii8+CiAgICAgICAgICAgIDwvcmVsYXRpb25zPgogICAgICAgIDwvbG9naW4+CiAgICA8L29wZXJhdGlvbj4KPC9zc28+Cg==&lt;/token&gt;\n        &lt;sign&gt;TQEEM3Y77Uc5uCzXSM926a3pb3CLpN/p+7OMtvfoG7l3xK9XxjcpRhxDZpUWKKggpvVzYOGfqsqr6v6tWwE2mAzJqkyHxdsa4rS6GXXmB/Y8jmWXvhDaTVrGc9+s5yzJnh+rhs0IVivR1qHlCDTrkzNTe8br9oG2VAlOVf7A0SA=&lt;/sign&gt;\n    &lt;/credentials&gt;\n&lt;/loginTicketResponse&gt;\n</loginCmsReturn></loginCmsResponse></soapenv:Body></soapenv:Envelope>'
================================================================================
Grabando TA en C:\Users\shiva\OneDrive\Desktop\Pyafipaws_Utkarsh\pyafipws\venv\lib\site-packages\pyafipws-3.9.b_2457_-py3.9.egg\pyafipws\cache\TA-2b4277f5962bd2cb0265c0fac4b32304.xml...
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<loginTicketResponse version="1.0">
    <header>
        <source>CN=wsaahomo, O=AFIP, C=AR, SERIALNUMBER=CUIT 33693450239</source>
        <destination>SERIALNUMBER=CUIT 20267565393, CN=reingart2019pub</destination>
        <uniqueId>3561837960</uniqueId>
        <generationTime>2021-06-11T11:02:28.949-03:00</generationTime>
        <expirationTime>2021-06-11T23:02:28.949-03:00</expirationTime>
    </header>
    <credentials>
        <token>PD94bWw....28+Cg==</token>
        <sign>TQEE.......oG2VAlOVf7A0SA=</sign>
    </credentials>
</loginTicketResponse>

Source: CN=wsaahomo, O=AFIP, C=AR, SERIALNUMBER=CUIT 33693450239
UniqueID Time: 3561837960
Generation Time: 2021-06-11T11:02:28.949-03:00
Expiration Time: 2021-06-11T23:02:28.949-03:00
Expiro? False

Unit tests

pytest tests\test_wsaa_crypto.py

=============================================== test session starts ===============================================
platform win32 -- Python 3.9.2, pytest-6.2.3, py-1.10.0, pluggy-0.13.1
rootdir: C:\Users\shiva\OneDrive\Desktop\Pyafipaws_Utkarsh\pyafipws
plugins: html-3.1.1, metadata-1.11.0, vcr-1.0.2
collected 4 items

tests\test_wsaa_crypto.py ....                                                                               [100%]

================================================ warnings summary ================================================= 
venv\lib\site-packages\past\builtins\misc.py:45
  c:\users\shiva\onedrive\desktop\pyafipaws_utkarsh\pyafipws\venv\lib\site-packages\past\builtins\misc.py:45: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
    from imp import reload

venv\lib\site-packages\pysimplesoap\transport.py:140
  c:\users\shiva\onedrive\desktop\pyafipaws_utkarsh\pyafipws\venv\lib\site-packages\pysimplesoap\transport.py:140: DeprecationWarning: inspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()
    if 'timeout' in inspect.getargspec(httplib2.Http.__init__)[0]:

-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================== 4 passed, 2 warnings in 0.27s ========================================== 

chazuttu added 6 commits June 11, 2021 18:50
Signed-off-by: UTKARSH KUMAR <Utkarshdhsbgp@gmail.com>
Signed-off-by: UTKARSH KUMAR <Utkarshdhsbgp@gmail.com>
Signed-off-by: UTKARSH KUMAR <Utkarshdhsbgp@gmail.com>
Signed-off-by: UTKARSH KUMAR <Utkarshdhsbgp@gmail.com>
…encryption

Signed-off-by: UTKARSH KUMAR <Utkarshdhsbgp@gmail.com>
Signed-off-by: UTKARSH KUMAR <Utkarshdhsbgp@gmail.com>
@chazuttu chazuttu requested a review from reingart June 11, 2021 14:10
Copy link
Member

@reingart reingart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, it seems to have some merge issues (line ends in reqs?) but overall is ok

@reingart reingart merged commit 6bb40f8 into PyAr:main Jun 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants