o
    nÒYi\  ã                   @   s,   d dl mZ d dlmZ G dd„ deƒZdS )é    )ÚTestCase)Ú	MultiDictc                   @   s<   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )ÚTestRequestValidatorc           	      C   sd   ddl m} d}d}d}d}||ƒ}| ||¡}|  |t¡ |  ||¡ | |||¡}|  |¡ d S )Nr   ©ÚRequestValidatorz(https://81f2-2-45-18-191.ngrok-free.app/ÚPSK_7TruNcSNTxp4zNrykMj4EPzFÚ(b18500437ebb010220ddd770cbe6fd531ea0ba0da¶  {"call":{"call_id":"b5d63b2e-f75b-4dc8-b6d4-269b635f96c0","node_id":"fa3570ae-f8bd-42c2-83f4-9950d906c91b@us-west","segment_id":"b5d63b2e-f75b-4dc8-b6d4-269b635f96c0","call_state":"created","direction":"inbound","type":"phone","from":"+12135877632","to":"+12089806814","from_number":"+12135877632","to_number":"+12089806814","project_id":"4b7ae78a-d02e-4889-a63b-08b156d5916e","space_id":"62615f44-2a34-4235-b38b-76b5a1de6ef8"},"vars":{}})Úsignalwire.request_validatorr   Úbuild_signatureÚassertIsInstanceÚstrÚassertEqualÚvalidateÚ
assertTrue)	Úselfr   ÚurlÚtokenÚ	signatureÚbodyÚ	validatorÚcomputedÚvalid© r   úk/var/www/html/asistente-voz-ia/venv/lib/python3.10/site-packages/signalwire/tests/test_request_validator.pyÚ%test_should_validate_no_compatibility   s   z:TestRequestValidator.test_should_validate_no_compatibilityc                 C   sL   ddl m} d}d}d}ddddd	d
œ}||ƒ}| |||¡}|  |¡ d S )Nr   r   ú+https://mycompany.com/myapp.php?foo=1&bar=2Ú12345úRSOYDt4T1cUTdK1PDd93/VVr8B8=ÚCA1234567890ABCDEú+14158675309Ú1234ú+18005551212)ÚCallSidÚCallerÚDigitsÚFromÚTo©r	   r   r   r   ©r   r   r   r   r   r   r   r   r   r   r   Ú%test_should_validate_with_compatibity   s   ûz:TestRequestValidator.test_should_validate_with_compatibityc                 C   sH   ddl m} d}d}d}tg d¢ƒ}||ƒ}| |||¡}|  |¡ d S )Nr   r   r   r   r   ))r"   r   )r#   r   )r$   r    )r%   r   )r&   r!   )r	   r   r   r   r   r(   r   r   r   Ú+test_should_validate_with_compatibity_flask&   s   ÿ
z@TestRequestValidator.test_should_validate_with_compatibity_flaskc                 C   sZ   ddl m} d}d}d}dddd	d
ddddddddœ}||ƒ}| |||¡}|  |¡ d S )Nr   r   z/http://0aac-189-71-169-171.ngrok-free.app/voiceÚPSK_V3bF8oyeRNpJWGoRWHNYQMUUzlf3nWPmUr2y6jSeeoMW4mg58vgI=ú$6bfbbe86-a901-4197-8759-2a0de1fa319dú
2010-04-01úcall-progress-eventsz$0703574f-b151-465d-aedb-28972eb513c7Úbusyúoutbound-apiúsip:+17063958228@sip.swire.ioú1sip:jpsantos@joaosantos-2a0de1fa319d.sip.swire.ioÚinboundzThu, 09 Nov 2023 17:05:04 +0000Ú486)Ú
AccountSidÚ
ApiVersionÚCallbackSourcer"   Ú
CallStatusÚ	Directionr%   ÚHangupByÚHangupDirectionÚ	Timestampr&   ÚSipResultCoder'   r(   r   r   r   Ú1test_should_validate_from_signalwire_http_request:   s(   ôzFTestRequestValidator.test_should_validate_from_signalwire_http_requestc                 C   sZ   ddl m} d}d}d}dddd	d
dddddd
ddœ}||ƒ}| |||¡}|  |¡ d S )Nr   r   ú0https://675d-189-71-169-171.ngrok-free.app/voicer+   úmuUMpldcBHlzuXGZ5gbw1ETZCYA=z$a97d4e8a-6047-4e2b-be48-fb96b33b5642r,   r-   r0   r1   r2   zThu, 09 Nov 2023 14:40:55 +0000z	no-answerr.   ÚoutboundÚ487)r"   r5   r6   r9   r%   r&   r<   r8   r7   r;   r:   r=   r'   r(   r   r   r   Ú2test_should_validate_from_signalwire_https_requestS   s(   ôzGTestRequestValidator.test_should_validate_from_signalwire_https_requestc                 C   s@   ddl m} d}d}d}d}||ƒ}| |||¡}|  |¡ d S )Nr   r   r?   r+   r@   a„  {
            "CallSid": "a97d4e8a-6047-4e2b-be48-fb96b33b5642", 
            "AccountSid": "6bfbbe86-a901-4197-8759-2a0de1fa319d", 
            "ApiVersion": "2010-04-01", 
            "Direction": "outbound-api", 
            "From": "sip:+17063958228@sip.swire.io", 
            "To": "sip:jpsantos@joaosantos-2a0de1fa319d.sip.swire.io", 
            "Timestamp": "Thu, 09 Nov 2023 14:40:55 +0000", 
            "CallStatus": "no-answer", 
            "CallbackSource": "call-progress-events", 
            "HangupDirection": "outbound", 
            "HangupBy": "sip:+17063958228@sip.swire.io", 
            "SipResultCode": "487"
        }r'   r(   r   r   r   Ú"test_should_validate_from_raw_jsonm   s   z7TestRequestValidator.test_should_validate_from_raw_jsonN)	Ú__name__Ú
__module__Ú__qualname__r   r)   r*   r>   rC   rD   r   r   r   r   r      s    r   N)Úunittestr   Ú	multidictr   r   r   r   r   r   Ú<module>   s    