diff --git a/.gitignore b/.gitignore
index c68ee63..0eebbfe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -102,6 +102,9 @@ venv.bak/
# mypy
.mypy_cache/
+/.dmypy.json
+
+*.pdf
# pycharm
.idea/
@@ -118,3 +121,4 @@ venv.bak/
# others
.DS_Store
+
diff --git a/.travis.yml b/.travis.yml
index c699fd4..119fb36 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -28,3 +28,17 @@ jobs:
- export PYTHONPATH=`pwd`
- pytest --vcr-record=none
- coveralls
+ - stage: PyPI Upload
+ python: 3.7
+ dist: xenial
+ sudo: true
+ script: echo "Uploading packages to PyPI"
+ deploy:
+ provider: pypi
+ user: cuenca
+ password:
+ secure: "I5xOa610g2M0rG6I+lm3V0ROyDdfb9738OnY+Z3IZzUDo4KvTO3aIBZatMw58rW4hNAAvAyjWE0Je0ABybmcBKLf42CbR+XgRnYoKhYECVgpdWuZsIWAKGf1dmbOo/AE+LEjSSaLNuLea7+x+586uECOFB5YYyKnC5QnLj19481SdS27l4UcUOQ8JFNEMKmPhZgAAXfptsC52/pxkoMC9xdk8sVf/WHOavnB4vzcrlLIYsbOdbU2HXaUxR42TUs7k5ETEnwG3pU1Ic9EPHkFVsh/2DJEHN8fCTnEig84xopZwnlnSYI2FqBB6xp8by5D5rpfTrFY6GZ4oUYwH9u8sOVs0SVTCBDQMht2qKuKA367wQcAvHRQ60OlL6UaOKu4G4sBrEEdNMpm9XewdrMeymkJMXP1+3Rlq+qbv0QxXe12NpK53Svvm7laMC1uGZ7Qgxcwk05dTibaHlUfCzrP79m1DZ0aqyN5IgrOXEpmyJzdDa0TX7dG4OqPCLckHKmlhkAMCq2CQALd5DZ2iBKE1rECrdbsPokB9hFEIjSI9lTe4wbyFN4kUUfdDi9dtIsljVIZkDJjM1Ned2uez0jtL83mfwXXcqMdWHDcFwxQXXc+H2gjdS4MbbmiEypDmuGAlBN3XqycwnkKc/LldK0oOD9QsKle3MCS3hb7885LhVc="
+
+ on:
+ tags: true
+ distributions: sdist bdist_wheel
diff --git a/dhlmex/__init__.py b/dhlmex/__init__.py
index b67319d..3950197 100644
--- a/dhlmex/__init__.py
+++ b/dhlmex/__init__.py
@@ -1,4 +1,5 @@
__all__ = ['__version__', 'Client']
+
from .client import Client
from .version import __version__
diff --git a/dhlmex/client.py b/dhlmex/client.py
index c5d641b..c2d6cb1 100644
--- a/dhlmex/client.py
+++ b/dhlmex/client.py
@@ -1,15 +1,18 @@
import os
from typing import Any, ClassVar, Dict, Optional
-from requests import Response, Session
+from requests import HTTPError, Response, Session, codes
+from requests.exceptions import SSLError
-from .resources import Resource
+from .exceptions import DhlmexException
+from .resources import Guide, PostCode, Resource
API_URL = 'https://prepaid.dhl.com.mx/Prepago'
USER_AGENT = (
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 '
'(KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36'
)
+DHL_CERT = 'prepaid-dhl-com-mx.pem'
class Client:
@@ -19,30 +22,69 @@ class Client:
session: Session
# resources
- ...
+ guides: ClassVar = Guide
+ post_codes: ClassVar = PostCode
def __init__(
self, username: Optional[str] = None, password: Optional[str] = None,
):
+
username = username or os.environ['DHLMEX_USERNAME']
password = password or os.environ['DHLMEX_PASSWORD']
self.session = Session()
self.session.headers['User-Agent'] = USER_AGENT
+ if os.getenv('DEBUG'):
+ print(f'Client using Charles certificate')
+ self.session.verify = DHL_CERT
self._login(username, password)
+
Resource._client = self
def _login(self, username: str, password: str) -> Response:
- self.get('/') # Initialize cookies
- endpoint = '/jsp/app/login/login.xhtml'
- data = {
- 'AJAXREQUEST': '_viewRoot',
- 'j_id6': 'j_id6',
- 'j_id6:j_id20': username,
- 'j_id6:j_id22': password,
- 'javax.faces.ViewState': 'j_id4',
- 'j_id6:j_id29': 'j_id6:j_id29',
- }
- return self.post(endpoint, data)
+ try:
+ self.get('/') # Initialize cookies
+ endpoint = '/jsp/app/login/login.xhtml'
+ data = {
+ 'AJAXREQUEST': '_viewRoot',
+ 'j_id6': 'j_id6',
+ 'j_id6:j_id20': username,
+ 'j_id6:j_id22': password,
+ 'javax.faces.ViewState': 'j_id1',
+ 'j_id6:j_id29': 'j_id6:j_id29',
+ }
+ resp = self.post(endpoint, data)
+ except HTTPError as httpe:
+ if 'Su sesión ha caducado' in resp.text:
+ raise DhlmexException('Session has expired')
+ else:
+ raise httpe
+ except SSLError:
+ raise DhlmexException('Cient on debug, but Charles not running')
+ # DHL always return 200 although there is an existing session
+ if 'Ya existe una sesión' in resp.text:
+ raise DhlmexException(
+ f'There is an exisiting session on DHL for {username}'
+ )
+ return resp
+
+ def _logout(self) -> Response:
+ endpoint = '/jsp/app/inicio/inicio.xhtml'
+ resp = self.post(endpoint, {})
+ if 'Login / Admin' in resp.text:
+ return resp # No need to logout
+ data = Resource.get_data(
+ resp, Resource._actions['close'],
+ ) # Obtain headers to end properly the session
+ try:
+ resp = self.post(endpoint, data)
+ except HTTPError as httpe:
+ if 'Su sesión ha caducado' in httpe.response.text:
+ resp = Response()
+ resp.status_code = codes.ok
+ return resp
+ else:
+ raise httpe
+ return resp
def get(self, endpoint: str, **kwargs: Any) -> Response:
return self.request('get', endpoint, {}, **kwargs)
diff --git a/dhlmex/exceptions.py b/dhlmex/exceptions.py
new file mode 100644
index 0000000..0a8644a
--- /dev/null
+++ b/dhlmex/exceptions.py
@@ -0,0 +1,4 @@
+class DhlmexException(Exception):
+ """
+ An error has occurred during DHL scrapping
+ """
diff --git a/dhlmex/resources/__init__.py b/dhlmex/resources/__init__.py
index 7258390..e30ff33 100644
--- a/dhlmex/resources/__init__.py
+++ b/dhlmex/resources/__init__.py
@@ -1,3 +1,5 @@
-__all__ = ['Resource']
+__all__ = ['Guide', 'PostCode', 'Resource']
from .base import Resource
+from .guides import Guide
+from .post_codes import PostCode
diff --git a/dhlmex/resources/base.py b/dhlmex/resources/base.py
index b045aa6..d846d8f 100644
--- a/dhlmex/resources/base.py
+++ b/dhlmex/resources/base.py
@@ -1,5 +1,57 @@
-from typing import ClassVar
+import re
+from typing import ClassVar, Dict
+
+from bs4 import BeautifulSoup
+from requests import Response
+
+from dhlmex.exceptions import DhlmexException
class Resource:
- _client: ClassVar['cepmex.Client'] # type: ignore
+ _client: ClassVar["dhlmex.Client"] # type: ignore
+ _urls: Dict[str, str] = {
+ 'login': '/jsp/app/login/login.xhtml',
+ 'home': '/jsp/app/inicio/inicio.xhtml',
+ 'guide': '/jsp/app/cliente/impresionClienteSubUsuario.xhtml',
+ 'capture': '/jsp/app/cliente/capturaDatosImpresionClienteSU.xhtml',
+ 'print': '/jsp/app/cliente/guiasImpresas.xhtml',
+ 'pdf': '/generaImpresionPDF',
+ }
+ _actions: Dict[str, Dict[str, str]] = {
+ 'close': {
+ 'text': 'Cerrar Sesión',
+ 'code': 'j_id9:j_id26',
+ 'end': 'j_id9:j_id30',
+ },
+ 'print': {
+ 'text': 'Impresión Sub Usuario',
+ 'code': 'j_id9:j_id14',
+ 'end': 'j_id9:j_id16',
+ },
+ 'download': {
+ 'text': 'Guías Impresas',
+ 'code': 'j_id9:j_id18',
+ 'end': 'j_id9:j_id10',
+ },
+ }
+
+ @staticmethod
+ def get_data(resp: Response, action: Dict) -> Dict:
+ if 'Login / Admin' in resp.text:
+ raise DhlmexException('Client not logged in')
+ soup = BeautifulSoup(resp.text, features='html.parser')
+ view_state = soup.find('input', id='javax.faces.ViewState').attrs[
+ 'value'
+ ]
+ js = soup.find('a', text=action['text']).attrs['onclick']
+ matches = re.findall(r"\'(.+?)\'", js)
+ form_ids = [match for match in matches if match.startswith('j_id')]
+ j_pair_id = form_ids[1].split(',')[0]
+ j_id = form_ids[0]
+
+ return {
+ j_id: j_id,
+ j_pair_id: action['code'],
+ 'javax.faces.ViewState': view_state,
+ action['end']: action['end'],
+ }
diff --git a/dhlmex/resources/destination.py b/dhlmex/resources/destination.py
new file mode 100644
index 0000000..94443f8
--- /dev/null
+++ b/dhlmex/resources/destination.py
@@ -0,0 +1,14 @@
+from dataclasses import dataclass
+
+
+@dataclass
+class Destination:
+ company: str
+ contact: str
+ mail: str
+ phone: str
+ address1: str
+ postal_code: str
+ neighborhood: str
+ city: str
+ state: str
diff --git a/dhlmex/resources/guides.py b/dhlmex/resources/guides.py
new file mode 100644
index 0000000..a1b5162
--- /dev/null
+++ b/dhlmex/resources/guides.py
@@ -0,0 +1,199 @@
+import os
+import re
+from time import sleep
+from typing import Dict, Tuple
+
+from bs4 import BeautifulSoup
+from requests import HTTPError, Response
+
+from dhlmex.exceptions import DhlmexException
+from dhlmex.resources.origin import Origin
+
+from .base import Resource
+from .destination import Destination
+from .order_details import OrderDetails
+
+
+class Guide(Resource):
+ @classmethod
+ def create_guide(
+ cls, origin: Origin, destination: Destination, details: OrderDetails
+ ) -> Tuple[str, str]:
+ guide = cls()
+ try:
+ guides_data = guide._get_guide_data()
+ if guides_data:
+ guide._select_guide(guides_data)
+ view_state = guide._fill_guide_table(
+ origin, destination, details
+ )
+ resp = guide._confirm_capture(view_state)
+ if resp.ok:
+ guide_number = guide._force_percent(view_state)
+ guide_path = guide._download_pdf(guide_number)
+ return guide_number, guide_path
+ else:
+ raise DhlmexException('Error while creating guide')
+ else:
+ raise DhlmexException('No available guides')
+ except HTTPError as httpe:
+ raise httpe
+
+ def _get_guide_data(self) -> Dict:
+ resp = self._client.post(self._urls['home'], {})
+ data = self.get_data(resp, self._actions['print'])
+ soup = BeautifulSoup(resp.text, features='html.parser')
+ field = soup.find('input', id=re.compile('panelBarInput')).attrs[
+ 'name'
+ ]
+ data[field] = self._actions['print']['code']
+ guides_data = {}
+ resp = self._client.post(self._urls['home'], data)
+ if 'seleccionar' in resp.text:
+ soup = BeautifulSoup(resp.text, features='html.parser')
+ view_state = soup.find('input', id='javax.faces.ViewState').attrs[
+ 'value'
+ ]
+ table = soup.find('table', id='j_id6:pnlOrdenesEncontradas')
+ table_body = table.find('tbody')
+ js = table_body.find('a', text='seleccionar').attrs['onclick']
+ matches = re.findall(r"\'(.+?)\'", js)
+ form_ids = [match for match in matches if match.startswith('j_id')]
+ j_pair_id = form_ids[1]
+ j_id = form_ids[0]
+ guides_data = {
+ 'AJAXREQUEST': '_viewRoot',
+ j_id: j_id,
+ 'javax.faces.ViewState': view_state,
+ j_pair_id: j_pair_id,
+ }
+ return guides_data
+
+ def _select_guide(self, guides_data: Dict) -> Dict:
+ resp = self._client.post(self._urls['guide'], guides_data)
+ soup = BeautifulSoup(resp.text, features='html.parser')
+ view_state = soup.find('input', id='javax.faces.ViewState').attrs[
+ 'value'
+ ]
+ j_id2 = soup.find('input', value='').attrs['name']
+ js = soup.find('input', value='').attrs['onkeyup']
+ matches = re.findall(r"\'(.+?)\'", js)
+ form_ids = [match for match in matches if match.startswith('j_id')]
+ j_pair_id = form_ids[1]
+ j_id = form_ids[0]
+ select_data = {
+ 'AJAXREQUEST': '_viewRoot',
+ j_id: j_id,
+ j_id2: '1',
+ 'javax.faces.ViewState': view_state,
+ j_pair_id: j_pair_id,
+ 'AJAX:EVENTS_COUNT': '1',
+ }
+ self._client.post(self._urls['guide'], select_data)
+ select_data.pop(j_pair_id, None)
+ select_data.pop('AJAX:EVENTS_COUNT', None)
+ select_data[
+ 'j_id6:btnGuardarCotizacion'
+ ] = 'j_id6:btnGuardarCotizacion'
+ self._client.post(self._urls['guide'], select_data)
+ return select_data
+
+ def _fill_guide_table(
+ self, origin: Origin, destination: Destination, details: OrderDetails
+ ) -> str:
+ resp = self._client.get(self._urls['capture'])
+ soup = BeautifulSoup(resp.text, features='html.parser')
+ view_state = soup.find('input', id='javax.faces.ViewState').attrs[
+ 'value'
+ ]
+ fill_data = self._client.post_codes.validate_postal_codes(
+ origin, destination, view_state
+ )
+ fill_data['datos:j_id15'] = origin.company
+ fill_data['datos:j_id19'] = origin.contact
+ fill_data['datos:emailOrigen'] = origin.mail
+ fill_data['datos:j_id24'] = origin.phone
+ fill_data['datos:j_id28'] = origin.address1
+ fill_data['datos:j_id36'] = origin.postal_code
+ fill_data['datos:j_id41'] = origin.neighborhood
+ fill_data['datos:j_id45'] = origin.city
+ fill_data['datos:j_id49'] = origin.state
+ fill_data['datos:j_id54'] = destination.company
+ fill_data['datos:j_id58'] = destination.contact
+ fill_data['datos:emailDestino'] = destination.mail
+ fill_data['datos:j_id63'] = destination.phone
+ fill_data['datos:j_id67'] = destination.address1
+ fill_data['datos:j_id75'] = destination.postal_code
+ fill_data['datos:j_id80'] = destination.neighborhood
+ fill_data['datos:j_id84'] = destination.city
+ fill_data['datos:j_id88'] = destination.state
+ fill_data['datos:j_id71'] = details.description
+ fill_data['datos:j_id93'] = details.content
+ fill_data['javax.faces.ViewState'] = view_state
+ fill_data['datos:j_id105'] = 'datos:j_id105'
+
+ self._client.post(self._urls['capture'], fill_data)
+
+ return fill_data['javax.faces.ViewState']
+
+ def _confirm_capture(self, view_state: str) -> Response:
+ confirm_data = {
+ 'AJAXREQUEST': '_viewRoot',
+ 'j_id109': 'j_id109',
+ 'javax.faces.ViewState': view_state,
+ 'j_id109:j_id112': 'j_id109:j_id112',
+ }
+ return self._client.post(self._urls['capture'], confirm_data)
+
+ def _force_percent(self, view_state: str, retries: int = 10) -> str:
+ force_data = {
+ 'AJAXREQUEST': '_viewRoot',
+ 'j_id115': 'j_id115',
+ 'javax.faces.ViewState': view_state,
+ 'j_id115:pb_sub': 'j_id115:pb_sub',
+ 'forcePercent': 'complete',
+ 'ajaxSingle': 'j_id115:pb_sub',
+ }
+ while retries:
+ resp = self._client.post(self._urls['capture'], force_data)
+ if 'Procesada correctamente' in resp.text:
+ soup = BeautifulSoup(resp.text, features='html.parser')
+ return soup.find(
+ 'td', id='j_id115:tblElementos:0:j_id123'
+ ).text
+ else:
+ sleep(1)
+ retries -= 1
+ raise DhlmexException('Error while processing guide')
+
+ def _download_pdf(self, guide_number: str) -> str:
+ resp = self._client.post(self._urls['home'], {})
+ data = self.get_data(resp, self._actions['download'])
+ resp = self._client.post(self._urls['home'], data)
+ soup = BeautifulSoup(resp.text, features='html.parser')
+ view_state = soup.find('input', id='javax.faces.ViewState').attrs[
+ 'value'
+ ]
+ td = soup.find('td', text=guide_number)
+ tds = [td for td in td.next_siblings]
+ j_pair_id = tds[-1].find('a').attrs['id']
+
+ guide_data = {
+ 'AJAXREQUEST': '_viewRoot',
+ 'j_id6': 'j_id6',
+ 'javax.faces.ViewState': view_state,
+ j_pair_id: j_pair_id,
+ }
+ self._client.post(self._urls['print'], guide_data)
+ resp = self._client.get(self._urls['pdf'])
+ path = ''
+ if resp.ok:
+ path = os.getenv('DOWNLOADS_DIRECTORY') or './'
+ path += f'/{guide_number}.pdf'
+ try:
+ with open(path, 'wb') as f:
+ f.write(resp.content)
+ return path
+ except OSError as ose:
+ raise DhlmexException(f'Error downloading guide: {str(ose)}')
+ return path
diff --git a/dhlmex/resources/order_details.py b/dhlmex/resources/order_details.py
new file mode 100644
index 0000000..3753f4c
--- /dev/null
+++ b/dhlmex/resources/order_details.py
@@ -0,0 +1,7 @@
+from dataclasses import dataclass
+
+
+@dataclass
+class OrderDetails:
+ description: str
+ content: str
diff --git a/dhlmex/resources/origin.py b/dhlmex/resources/origin.py
new file mode 100644
index 0000000..7a8d1c3
--- /dev/null
+++ b/dhlmex/resources/origin.py
@@ -0,0 +1,14 @@
+from dataclasses import dataclass
+
+
+@dataclass
+class Origin:
+ company: str
+ contact: str
+ mail: str
+ phone: str
+ address1: str
+ postal_code: str
+ neighborhood: str
+ city: str
+ state: str
diff --git a/dhlmex/resources/post_codes.py b/dhlmex/resources/post_codes.py
new file mode 100644
index 0000000..345015f
--- /dev/null
+++ b/dhlmex/resources/post_codes.py
@@ -0,0 +1,67 @@
+from typing import Dict
+
+from dhlmex.exceptions import DhlmexException
+from dhlmex.resources.destination import Destination
+from dhlmex.resources.origin import Origin
+
+from .base import Resource
+
+
+class PostCode(Resource):
+ @classmethod
+ def validate_postal_codes(
+ cls, origin: Origin, destination: Destination, view_state: str
+ ):
+ post_code = cls()
+ return post_code._validate_postal_codes(
+ origin, destination, view_state
+ )
+
+ def _validate_postal_codes(
+ self, origin: Origin, destination: Destination, view_state: str
+ ) -> Dict:
+ fill_data = {
+ 'AJAXREQUEST': '_viewRoot',
+ 'datos': 'datos',
+ 'datos:j_id10': 'j_id11',
+ 'datos:j_id15': '',
+ 'datos:j_id19': '',
+ 'datos:emailOrigen': '',
+ 'datos:j_id24': '',
+ 'datos:j_id28': '',
+ 'datos:j_id30': '',
+ 'datos:j_id32': '',
+ 'datos:j_id36': origin.postal_code,
+ 'datos:j_id41': '',
+ 'datos:j_id45': '',
+ 'datos:j_id49': '',
+ 'datos:j_id54': '',
+ 'datos:j_id58': '',
+ 'datos:emailDestino': '',
+ 'datos:j_id63': '',
+ 'datos:j_id67': '',
+ 'datos:j_id69': '',
+ 'datos:j_id71': '',
+ 'datos:j_id75': '',
+ 'datos:j_id80': '',
+ 'datos:j_id84': '',
+ 'datos:j_id88': '',
+ 'datos:j_id93': '',
+ 'datos:j_id95': '',
+ 'javax.faces.ViewState': view_state,
+ 'datos:j_id37': 'datos:j_id37',
+ }
+ resp = self._client.post(self._urls['capture'], fill_data)
+ if 'Código Postal válido' in resp.text:
+ fill_data.pop('datos:j_id37')
+ # validate also destiny postal_code
+ fill_data['datos:j_id76'] = 'datos:j_id76'
+ fill_data['datos:j_id75'] = destination.postal_code
+ resp = self._client.post(self._urls['capture'], fill_data)
+ if 'Código Postal válido' in resp.text:
+ fill_data.pop('datos:j_id76')
+ return fill_data
+ else:
+ raise DhlmexException('Invalid destiny postal code')
+ else:
+ raise DhlmexException('Invalid origin postal code')
diff --git a/env.template b/env.template
new file mode 100644
index 0000000..0f4b2ef
--- /dev/null
+++ b/env.template
@@ -0,0 +1,4 @@
+# Copy this to your .env file
+
+DHLMEX_USERNAME=alan@cuenca.com
+DHLMEX_PASSWORD=password
diff --git a/prepaid-dhl-com-mx.pem b/prepaid-dhl-com-mx.pem
new file mode 100644
index 0000000..df20502
--- /dev/null
+++ b/prepaid-dhl-com-mx.pem
@@ -0,0 +1,31 @@
+-----BEGIN CERTIFICATE-----
+MIIFVjCCBD6gAwIBAgIGAW8VyxOiMA0GCSqGSIb3DQEBCwUAMIGvMUAwPgYDVQQD
+DDdDaGFybGVzIFByb3h5IENBICgxNyBEZWMgMjAxOSwgQWxhbnMtTWFjQm9vay1Q
+cm8ubG9jYWwpMSUwIwYDVQQLDBxodHRwczovL2NoYXJsZXNwcm94eS5jb20vc3Ns
+MREwDwYDVQQKDAhYSzcyIEx0ZDERMA8GA1UEBwwIQXVja2xhbmQxETAPBgNVBAgM
+CEF1Y2tsYW5kMQswCQYDVQQGEwJOWjAeFw0wMDAxMDEwMDAwMDBaFw00OTAyMTIy
+MTM3MDhaMIGvMUAwPgYDVQQDDDdDaGFybGVzIFByb3h5IENBICgxNyBEZWMgMjAx
+OSwgQWxhbnMtTWFjQm9vay1Qcm8ubG9jYWwpMSUwIwYDVQQLDBxodHRwczovL2No
+YXJsZXNwcm94eS5jb20vc3NsMREwDwYDVQQKDAhYSzcyIEx0ZDERMA8GA1UEBwwI
+QXVja2xhbmQxETAPBgNVBAgMCEF1Y2tsYW5kMQswCQYDVQQGEwJOWjCCASIwDQYJ
+KoZIhvcNAQEBBQADggEPADCCAQoCggEBALSq7XgA12pQPwZD2ZUtu/DswHJ1axyU
+FYYjv+dyu+fixwuLC4x6oAaGOE8pqd5iqg+hDrQzZQX4AsTQPSvwzLZ3XUJRIuVF
+qoz9cdRwclNwTDOno6GiGh4cA41aCGdCOLSt39i9DJwEp/6OEvP1QYeW5x47f+Kw
+IfV8R5m2LBBvW/DMT4Wm3hQj+KBgvqTWOa8T+VQJ4R8gnuluYBhyGBzidqAySbMP
+7EBgYNkqcrcQ9zuHUd2SCc+u3L0k3PvAEkgMHzaeCsAsAYX9PQe559+pjweRtJik
+d6S7vDjE+KbE00tjYeVz0t3PfWuM3wIu92bHYr1xU4HubUqLNL6Ccb8CAwEAAaOC
+AXQwggFwMA8GA1UdEwEB/wQFMAMBAf8wggEsBglghkgBhvhCAQ0EggEdE4IBGVRo
+aXMgUm9vdCBjZXJ0aWZpY2F0ZSB3YXMgZ2VuZXJhdGVkIGJ5IENoYXJsZXMgUHJv
+eHkgZm9yIFNTTCBQcm94eWluZy4gSWYgdGhpcyBjZXJ0aWZpY2F0ZSBpcyBwYXJ0
+IG9mIGEgY2VydGlmaWNhdGUgY2hhaW4sIHRoaXMgbWVhbnMgdGhhdCB5b3UncmUg
+YnJvd3NpbmcgdGhyb3VnaCBDaGFybGVzIFByb3h5IHdpdGggU1NMIFByb3h5aW5n
+IGVuYWJsZWQgZm9yIHRoaXMgd2Vic2l0ZS4gUGxlYXNlIHNlZSBodHRwOi8vY2hh
+cmxlc3Byb3h5LmNvbS9zc2wgZm9yIG1vcmUgaW5mb3JtYXRpb24uMA4GA1UdDwEB
+/wQEAwICBDAdBgNVHQ4EFgQUsegWPaZRxNnB/4Kz0exFPK8oMOQwDQYJKoZIhvcN
+AQELBQADggEBACU1O3dzdpWS6FZDy/ucnLDmrVUhkDzn+0OuKYEOMnmDm8FdXpgI
+42iP06zQz+mfgQ0zAu1sYRPu0RaGYWurJjOiZWgHRzzRYTwMJO3Zg/eMHIF3IL8b
+hYcrWMBthtR7uRND6sCIoiIHVP4379cM4iAZhO2qHYVNncDbeL0ip0MRUbPcKOIB
+8+bXPja81TZ94gK0c4KCzeu90tdIyhI/omg1N0p9rkOJ2DqfZNkldAqoRiv9bq+N
+pgBq/5BeIGfzHUQVOUUkt4+jVT5pBMC3WsTCmMtGw+1lJZmU5WCx55+VbWVZL9T3
+yvaVL0INXxTICe6HyzH4wB7XQpgzo+2LkHw=
+-----END CERTIFICATE-----
diff --git a/setup.cfg b/setup.cfg
index aaa1d7f..279b1fc 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -2,7 +2,7 @@
test=pytest
[tool:pytest]
-addopts = -p no:warnings -v --cov=dhlmex
+addopts = -p no:warnings -v --cov=dhlmex --cov-report term-missing
[flake8]
inline-quotes = '
@@ -19,3 +19,6 @@ ignore_missing_imports = true
[mypy-vcr]
ignore_missing_imports = true
+
+[mypy-bs4]
+ignore_missing_imports = true
\ No newline at end of file
diff --git a/setup.py b/setup.py
index 9468920..eb07c54 100644
--- a/setup.py
+++ b/setup.py
@@ -4,6 +4,14 @@
version = SourceFileLoader('version', 'dhlmex/version.py').load_module()
+
+install_requirements = [
+ 'dataclasses>=0.6;python_version<"3.7"',
+ 'requests>=2.22.0,<3.0.0',
+ 'beautifulsoup4>=4.8.1',
+ 'Unidecode==1.1.1',
+]
+
test_requires = [
'pytest',
'pytest-vcr',
@@ -29,12 +37,9 @@
url='https://github.com/cuenca-mx/dhlmex-python',
packages=find_packages(),
include_package_data=True,
- package_data=dict(mati=['py.typed']),
+ package_data=dict(dhlmex=['py.typed']),
python_requires='>=3.6',
- install_requires=[
- 'dataclasses>=0.6;python_version<"3.7"',
- 'requests>=2.22.0,<3.0.0',
- ],
+ install_requires=install_requirements,
setup_requires=['pytest-runner'],
tests_require=test_requires,
extras_require=dict(test=test_requires),
diff --git a/tests/cassettes/test_client_log_out.yaml b/tests/cassettes/test_client_log_out.yaml
new file mode 100644
index 0000000..27c5f82
--- /dev/null
+++ b/tests/cassettes/test_client_log_out.yaml
@@ -0,0 +1,779 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ User-Agent:
+ - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML,
+ like Gecko) Chrome/75.0.3770.142 Safari/537.36
+ method: GET
+ uri: https://prepaid.dhl.com.mx/Prepago/
+ response:
+ body:
+ string: "\n\n\n
\n \n Login\
+ \ / Admin\n \n \n \n \n \n \n \n \n \n\
+ \ \n \n \n\n \n \n\
+ \ \n\n \n\n \n
\n \n\n
\n \
+ \
\n
\n \n\n \n \n\n \
+ \
\n \n"
+ headers:
+ Content-Type:
+ - text/html;charset=UTF-8
+ Date:
+ - Thu, 16 Jan 2020 20:02:28 GMT
+ Server:
+ - Apache-Coyote/1.1
+ Set-Cookie:
+ - JSESSIONID=26D0080371411CFC1472F22D4C796AC7; Path=/Prepago/; HttpOnly
+ - BIGipServerpl_prepaid.com.mx_80=1029802396.20480.0000; path=/; Httponly; Secure
+ Transfer-Encoding:
+ - chunked
+ X-Powered-By:
+ - JSF/1.2
+ status:
+ code: 200
+ message: OK
+- request:
+ body: AJAXREQUEST=%5B%27_viewRoot%27%5D&j_id6=%5B%27j_id6%27%5D&j_id6%3Aj_id20=%5B%27USERNAME%27%5D&j_id6%3Aj_id22=%5B%27PASSWORD%27%5D&javax.faces.ViewState=%5B%27j_id1%27%5D&j_id6%3Aj_id29=%5B%27j_id6%3Aj_id29%27%5D
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '148'
+ Content-Type:
+ - application/x-www-form-urlencoded
+ Cookie:
+ - JSESSIONID=26D0080371411CFC1472F22D4C796AC7; BIGipServerpl_prepaid.com.mx_80=1029802396.20480.0000
+ User-Agent:
+ - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML,
+ like Gecko) Chrome/75.0.3770.142 Safari/537.36
+ method: POST
+ uri: https://prepaid.dhl.com.mx/Prepago/jsp/app/login/login.xhtml
+ response:
+ body:
+ string: '
+
+ '
+ headers:
+ Ajax-Response:
+ - redirect
+ Cache-Control:
+ - no-cache, must-revalidate, max_age=0, no-store
+ Content-Type:
+ - text/xml;charset=UTF-8
+ Date:
+ - Thu, 16 Jan 2020 20:02:29 GMT
+ Expires:
+ - '0'
+ Location:
+ - /Prepago/jsp/app/inicio/inicio.xhtml
+ Pragma:
+ - no-cache
+ Server:
+ - Apache-Coyote/1.1
+ Transfer-Encoding:
+ - chunked
+ X-Powered-By:
+ - JSF/1.2
+ status:
+ code: 200
+ message: OK
+- request:
+ body: null
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ Cookie:
+ - JSESSIONID=26D0080371411CFC1472F22D4C796AC7; BIGipServerpl_prepaid.com.mx_80=1029802396.20480.0000
+ User-Agent:
+ - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML,
+ like Gecko) Chrome/75.0.3770.142 Safari/537.36
+ method: POST
+ uri: https://prepaid.dhl.com.mx/Prepago/jsp/app/inicio/inicio.xhtml
+ response:
+ body:
+ string: "\n\n\n \n \n Administrar\n\
+ \ \n \n \n \n \n \n \n \n \n\
+ \ \n \n \n\n \n \n\
+ \ \n\n \n\n \n
\n \n\n
\n
\n \n\n \n \n\n \
+ \
\n \n"
+ headers:
+ Content-Type:
+ - text/html;charset=UTF-8
+ Date:
+ - Thu, 16 Jan 2020 20:02:29 GMT
+ Server:
+ - Apache-Coyote/1.1
+ Transfer-Encoding:
+ - chunked
+ X-Powered-By:
+ - JSF/1.2
+ status:
+ code: 200
+ message: OK
+- request:
+ body: j_id9=j_id9&j_id9%3Aj_id30=j_id9%3Aj_id30&javax.faces.ViewState=j_id2
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '69'
+ Content-Type:
+ - application/x-www-form-urlencoded
+ Cookie:
+ - JSESSIONID=26D0080371411CFC1472F22D4C796AC7; BIGipServerpl_prepaid.com.mx_80=1029802396.20480.0000
+ User-Agent:
+ - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML,
+ like Gecko) Chrome/75.0.3770.142 Safari/537.36
+ method: POST
+ uri: https://prepaid.dhl.com.mx/Prepago/jsp/app/inicio/inicio.xhtml
+ response:
+ body:
+ string: ''
+ headers:
+ Content-Length:
+ - '0'
+ Date:
+ - Thu, 16 Jan 2020 20:02:29 GMT
+ Location:
+ - http://prepaid.dhl.com.mx/Prepago/jsp/app/login/login.xhtml
+ Server:
+ - Apache-Coyote/1.1
+ X-Powered-By:
+ - JSF/1.2
+ status:
+ code: 302
+ message: Found
+- request:
+ body: null
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Cookie:
+ - JSESSIONID=26D0080371411CFC1472F22D4C796AC7
+ User-Agent:
+ - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML,
+ like Gecko) Chrome/75.0.3770.142 Safari/537.36
+ method: GET
+ uri: http://prepaid.dhl.com.mx/Prepago/jsp/app/login/login.xhtml
+ response:
+ body:
+ string: ''
+ headers:
+ Connection:
+ - Keep-Alive
+ Content-Length:
+ - '0'
+ Location:
+ - https://prepaid.dhl.com.mx/Prepago/jsp/app/login/login.xhtml
+ Server:
+ - BigIP
+ status:
+ code: 302
+ message: Found
+- request:
+ body: null
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Cookie:
+ - JSESSIONID=26D0080371411CFC1472F22D4C796AC7; BIGipServerpl_prepaid.com.mx_80=1029802396.20480.0000
+ User-Agent:
+ - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML,
+ like Gecko) Chrome/75.0.3770.142 Safari/537.36
+ method: GET
+ uri: https://prepaid.dhl.com.mx/Prepago/jsp/app/login/login.xhtml
+ response:
+ body:
+ string: "\n\n\n \n \n Login\
+ \ / Admin\n \n \n \n \n \n \n \n \n \n\
+ \ \n \n \n\n \n \n\
+ \ \n\n \n\n \n
\n \n\n
\n \
+ \
\n
\n \n\n \n \n\n \
+ \
\n \n"
+ headers:
+ Content-Type:
+ - text/html;charset=UTF-8
+ Date:
+ - Thu, 16 Jan 2020 20:02:29 GMT
+ Server:
+ - Apache-Coyote/1.1
+ Set-Cookie:
+ - JSESSIONID=BAA3BE588BAEEE6230EE7A8B45C8C639; Path=/Prepago/; HttpOnly
+ Transfer-Encoding:
+ - chunked
+ X-Powered-By:
+ - JSF/1.2
+ status:
+ code: 200
+ message: OK
+version: 1
diff --git a/tests/cassettes/test_existing_session.yaml b/tests/cassettes/test_existing_session.yaml
new file mode 100644
index 0000000..98a64a5
--- /dev/null
+++ b/tests/cassettes/test_existing_session.yaml
@@ -0,0 +1,1302 @@
+interactions:
+- request:
+ body: null
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ User-Agent:
+ - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML,
+ like Gecko) Chrome/75.0.3770.142 Safari/537.36
+ method: GET
+ uri: https://prepaid.dhl.com.mx/Prepago/
+ response:
+ body:
+ string: "\n\n\n \n \n Login\
+ \ / Admin\n \n \n \n \n \n \n \n \n \n\
+ \ \n \n \n\n \n \n\
+ \ \n\n \n\n \n
\n \n\n
\n \
+ \
\n
\n \n\n \n \n\n \
+ \
\n \n"
+ headers:
+ Content-Type:
+ - text/html;charset=UTF-8
+ Date:
+ - Thu, 16 Jan 2020 20:02:30 GMT
+ Server:
+ - Apache-Coyote/1.1
+ Set-Cookie:
+ - JSESSIONID=3E9A40F9D0F79FBB5C55DBDC472E5FBB; Path=/Prepago/; HttpOnly
+ - BIGipServerpl_prepaid.com.mx_80=1029802396.20480.0000; path=/; Httponly; Secure
+ Transfer-Encoding:
+ - chunked
+ X-Powered-By:
+ - JSF/1.2
+ status:
+ code: 200
+ message: OK
+- request:
+ body: AJAXREQUEST=%5B%27_viewRoot%27%5D&j_id6=%5B%27j_id6%27%5D&j_id6%3Aj_id20=%5B%27USERNAME%27%5D&j_id6%3Aj_id22=%5B%27PASSWORD%27%5D&javax.faces.ViewState=%5B%27j_id1%27%5D&j_id6%3Aj_id29=%5B%27j_id6%3Aj_id29%27%5D
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '148'
+ Content-Type:
+ - application/x-www-form-urlencoded
+ Cookie:
+ - JSESSIONID=3E9A40F9D0F79FBB5C55DBDC472E5FBB; BIGipServerpl_prepaid.com.mx_80=1029802396.20480.0000
+ User-Agent:
+ - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML,
+ like Gecko) Chrome/75.0.3770.142 Safari/537.36
+ method: POST
+ uri: https://prepaid.dhl.com.mx/Prepago/jsp/app/login/login.xhtml
+ response:
+ body:
+ string: '
+
+ '
+ headers:
+ Ajax-Response:
+ - redirect
+ Cache-Control:
+ - no-cache, must-revalidate, max_age=0, no-store
+ Content-Type:
+ - text/xml;charset=UTF-8
+ Date:
+ - Thu, 16 Jan 2020 20:02:30 GMT
+ Expires:
+ - '0'
+ Location:
+ - /Prepago/jsp/app/inicio/inicio.xhtml
+ Pragma:
+ - no-cache
+ Server:
+ - Apache-Coyote/1.1
+ Transfer-Encoding:
+ - chunked
+ X-Powered-By:
+ - JSF/1.2
+ status:
+ code: 200
+ message: OK
+- request:
+ body: null
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Cookie:
+ - JSESSIONID=3E9A40F9D0F79FBB5C55DBDC472E5FBB; BIGipServerpl_prepaid.com.mx_80=1029802396.20480.0000
+ User-Agent:
+ - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML,
+ like Gecko) Chrome/75.0.3770.142 Safari/537.36
+ method: GET
+ uri: https://prepaid.dhl.com.mx/Prepago/jsp/app/inicio/inicio.xhtml
+ response:
+ body:
+ string: "\n\n\n \n \n Administrar\n\
+ \ \n \n \n \n \n \n \n \n \n\
+ \ \n \n \n\n \n \n\
+ \ \n\n \n\n \n
\n \n\n
\n
\n \n\n \n \n\n \
+ \
\n \n"
+ headers:
+ Content-Type:
+ - text/html;charset=UTF-8
+ Date:
+ - Thu, 16 Jan 2020 20:02:31 GMT
+ Server:
+ - Apache-Coyote/1.1
+ Transfer-Encoding:
+ - chunked
+ X-Powered-By:
+ - JSF/1.2
+ status:
+ code: 200
+ message: OK
+- request:
+ body: null
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ User-Agent:
+ - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML,
+ like Gecko) Chrome/75.0.3770.142 Safari/537.36
+ method: GET
+ uri: https://prepaid.dhl.com.mx/Prepago/
+ response:
+ body:
+ string: "\n\n\n \n \n Login\
+ \ / Admin\n \n \n \n \n \n \n \n \n \n\
+ \ \n \n \n\n \n \n\
+ \ \n\n \n\n \n
\n \n\n
\n \
+ \
\n
\n \n\n \n \n\n \
+ \
\n \n"
+ headers:
+ Content-Type:
+ - text/html;charset=UTF-8
+ Date:
+ - Thu, 16 Jan 2020 20:02:31 GMT
+ Server:
+ - Apache-Coyote/1.1
+ Set-Cookie:
+ - JSESSIONID=0515EA76C7DB4EA6DDABB99B09BDA568; Path=/Prepago/; HttpOnly
+ - BIGipServerpl_prepaid.com.mx_80=1029802396.20480.0000; path=/; Httponly; Secure
+ Transfer-Encoding:
+ - chunked
+ X-Powered-By:
+ - JSF/1.2
+ status:
+ code: 200
+ message: OK
+- request:
+ body: AJAXREQUEST=%5B%27_viewRoot%27%5D&j_id6=%5B%27j_id6%27%5D&j_id6%3Aj_id20=%5B%27USERNAME%27%5D&j_id6%3Aj_id22=%5B%27PASSWORD%27%5D&javax.faces.ViewState=%5B%27j_id1%27%5D&j_id6%3Aj_id29=%5B%27j_id6%3Aj_id29%27%5D
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '148'
+ Content-Type:
+ - application/x-www-form-urlencoded
+ Cookie:
+ - JSESSIONID=0515EA76C7DB4EA6DDABB99B09BDA568; BIGipServerpl_prepaid.com.mx_80=1029802396.20480.0000
+ User-Agent:
+ - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML,
+ like Gecko) Chrome/75.0.3770.142 Safari/537.36
+ method: POST
+ uri: https://prepaid.dhl.com.mx/Prepago/jsp/app/login/login.xhtml
+ response:
+ body:
+ string: "\r\n- Ya existe una sesi\xF3n en la aplicaci\xF3\
+ n con el usuario Andrues
"
+ headers:
+ Ajax-Response:
+ - 'true'
+ Cache-Control:
+ - no-cache, must-revalidate, max_age=0, no-store
+ Content-Length:
+ - '4555'
+ Content-Type:
+ - text/xml;charset=UTF-8
+ Date:
+ - Thu, 16 Jan 2020 20:02:32 GMT
+ Expires:
+ - '0'
+ Pragma:
+ - no-cache
+ Server:
+ - Apache-Coyote/1.1
+ X-Powered-By:
+ - JSF/1.2
+ status:
+ code: 200
+ message: OK
+- request:
+ body: null
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '0'
+ Cookie:
+ - JSESSIONID=3E9A40F9D0F79FBB5C55DBDC472E5FBB; BIGipServerpl_prepaid.com.mx_80=1029802396.20480.0000
+ User-Agent:
+ - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML,
+ like Gecko) Chrome/75.0.3770.142 Safari/537.36
+ method: POST
+ uri: https://prepaid.dhl.com.mx/Prepago/jsp/app/inicio/inicio.xhtml
+ response:
+ body:
+ string: "\n\n\n \n \n Administrar\n\
+ \ \n \n \n \n \n \n \n \n \n\
+ \ \n \n \n\n \n \n\
+ \ \n\n \n\n \n
\n \n\n
\n
\n \n\n \n \n\n \
+ \
\n \n"
+ headers:
+ Content-Type:
+ - text/html;charset=UTF-8
+ Date:
+ - Thu, 16 Jan 2020 20:02:32 GMT
+ Server:
+ - Apache-Coyote/1.1
+ Transfer-Encoding:
+ - chunked
+ X-Powered-By:
+ - JSF/1.2
+ status:
+ code: 200
+ message: OK
+- request:
+ body: j_id9=j_id9&j_id9%3Aj_id30=j_id9%3Aj_id30&javax.faces.ViewState=j_id3
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Content-Length:
+ - '69'
+ Content-Type:
+ - application/x-www-form-urlencoded
+ Cookie:
+ - JSESSIONID=3E9A40F9D0F79FBB5C55DBDC472E5FBB; BIGipServerpl_prepaid.com.mx_80=1029802396.20480.0000
+ User-Agent:
+ - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML,
+ like Gecko) Chrome/75.0.3770.142 Safari/537.36
+ method: POST
+ uri: https://prepaid.dhl.com.mx/Prepago/jsp/app/inicio/inicio.xhtml
+ response:
+ body:
+ string: ''
+ headers:
+ Content-Length:
+ - '0'
+ Date:
+ - Thu, 16 Jan 2020 20:02:32 GMT
+ Location:
+ - http://prepaid.dhl.com.mx/Prepago/jsp/app/login/login.xhtml
+ Server:
+ - Apache-Coyote/1.1
+ X-Powered-By:
+ - JSF/1.2
+ status:
+ code: 302
+ message: Found
+- request:
+ body: null
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Cookie:
+ - JSESSIONID=3E9A40F9D0F79FBB5C55DBDC472E5FBB
+ User-Agent:
+ - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML,
+ like Gecko) Chrome/75.0.3770.142 Safari/537.36
+ method: GET
+ uri: http://prepaid.dhl.com.mx/Prepago/jsp/app/login/login.xhtml
+ response:
+ body:
+ string: ''
+ headers:
+ Connection:
+ - Keep-Alive
+ Content-Length:
+ - '0'
+ Location:
+ - https://prepaid.dhl.com.mx/Prepago/jsp/app/login/login.xhtml
+ Server:
+ - BigIP
+ status:
+ code: 302
+ message: Found
+- request:
+ body: null
+ headers:
+ Accept:
+ - '*/*'
+ Accept-Encoding:
+ - gzip, deflate
+ Connection:
+ - keep-alive
+ Cookie:
+ - JSESSIONID=3E9A40F9D0F79FBB5C55DBDC472E5FBB; BIGipServerpl_prepaid.com.mx_80=1029802396.20480.0000
+ User-Agent:
+ - Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML,
+ like Gecko) Chrome/75.0.3770.142 Safari/537.36
+ method: GET
+ uri: https://prepaid.dhl.com.mx/Prepago/jsp/app/login/login.xhtml
+ response:
+ body:
+ string: "\n\n\n \n \n Login\
+ \ / Admin\n \n \n \n \n \n \n \n \n \n\
+ \ \n \n \n\n \n \n\
+ \ \n\n \n\n \n
\n \n\n
\n \
+ \
\n
\n \n\n \n \n\n \
+ \
\n \n"
+ headers:
+ Content-Type:
+ - text/html;charset=UTF-8
+ Date:
+ - Thu, 16 Jan 2020 20:02:32 GMT
+ Server:
+ - Apache-Coyote/1.1
+ Set-Cookie:
+ - JSESSIONID=1666171B897CD969E04469F63EF362A2; Path=/Prepago/; HttpOnly
+ Transfer-Encoding:
+ - chunked
+ X-Powered-By:
+ - JSF/1.2
+ status:
+ code: 200
+ message: OK
+version: 1
diff --git a/tests/cassettes/test_successful_login.yaml b/tests/cassettes/test_successful_login.yaml
index 1916c36..5f2dc32 100644
--- a/tests/cassettes/test_successful_login.yaml
+++ b/tests/cassettes/test_successful_login.yaml
@@ -15,181 +15,206 @@ interactions:
uri: https://prepaid.dhl.com.mx/Prepago/
response:
body:
- string: "\n\n\n \n \n Login
- / Admin\n \n \n
- \ \n
- \ \n \n \n \n \n \n \n
- \ \n \n\n
- \ \n \n
- \ \n\n \n\n \n
\n \n\n
\n
\n
- \
\n \n\n \n \n\n
\n \n"
+ string: "\n\n\n \n \n Login\
+ \ / Admin\n \n \n \n \n \n \n \n \n \n\
+ \ \n \n \n\n \n \n\
+ \ \n\n \n\n \n
\n \n\n
\n \
+ \
\n
\n \n\n \n \n\n \
+ \
\n \n"
headers:
Content-Type:
- text/html;charset=UTF-8
Date:
- - Sun, 17 Nov 2019 23:30:50 GMT
+ - Thu, 16 Jan 2020 20:02:26 GMT
Server:
- Apache-Coyote/1.1
Set-Cookie:
- - JSESSIONID=B5470032B5F652B29B9BA82DD96D17E1; Path=/Prepago/; HttpOnly
+ - JSESSIONID=F0730899EAC021DE714EF9ADB65E1DB5; Path=/Prepago/; HttpOnly
- BIGipServerpl_prepaid.com.mx_80=1029802396.20480.0000; path=/; Httponly; Secure
Transfer-Encoding:
- chunked
@@ -199,7 +224,7 @@ interactions:
code: 200
message: OK
- request:
- body: AJAXREQUEST=%5B%27_viewRoot%27%5D&j_id6=%5B%27j_id6%27%5D&j_id6%3Aj_id20=%5B%27USERNAME%27%5D&j_id6%3Aj_id22=%5B%27PASSWORD%27%5D&javax.faces.ViewState=%5B%27j_id4%27%5D&j_id6%3Aj_id29=%5B%27j_id6%3Aj_id29%27%5D
+ body: AJAXREQUEST=%5B%27_viewRoot%27%5D&j_id6=%5B%27j_id6%27%5D&j_id6%3Aj_id20=%5B%27USERNAME%27%5D&j_id6%3Aj_id22=%5B%27PASSWORD%27%5D&javax.faces.ViewState=%5B%27j_id1%27%5D&j_id6%3Aj_id29=%5B%27j_id6%3Aj_id29%27%5D
headers:
Accept:
- '*/*'
@@ -208,11 +233,11 @@ interactions:
Connection:
- keep-alive
Content-Length:
- - '161'
+ - '148'
Content-Type:
- application/x-www-form-urlencoded
Cookie:
- - JSESSIONID=B5470032B5F652B29B9BA82DD96D17E1; BIGipServerpl_prepaid.com.mx_80=1029802396.20480.0000
+ - JSESSIONID=F0730899EAC021DE714EF9ADB65E1DB5; BIGipServerpl_prepaid.com.mx_80=1029802396.20480.0000
User-Agent:
- Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML,
like Gecko) Chrome/75.0.3770.142 Safari/537.36
@@ -223,21 +248,21 @@ interactions:
string: '
'
+ content="redirect" />