HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/launchpadlib/tests/__pycache__/test_credential_store.cpython-38.pyc
U

H�9^�"�@s�dZddlZddlZddlZddlmZeekr6eZ	neZ	ddl
mZmZddl
mZmZmZmZGdd�dej�ZGdd	�d	ej�ZGd
d�de�ZGdd
�d
e�ZdS)z'Tests for the credential store classes.�N)�	b64decode)�fake_keyring�InMemoryKeyring)�AccessToken�Credentials�KeyringCredentialStore�UnencryptedFileCredentialStorec@s eZdZdZdd�Zdd�ZdS)�TestAccessTokenz Tests for the AccessToken class.cCs6t�d�}|�d|j�|�d|j�|�|j�dS)Nz;oauth_token_secret=secret%3Dpassword&oauth_token=lock%26key�lock&key�secret=password)r�from_string�assertEqual�key�secret�assertIsNone�context��self�access_token�r�J/usr/lib/python3/dist-packages/launchpadlib/tests/test_credential_store.py�test_from_string/s�z TestAccessToken.test_from_stringcCs8t�d�}|�d|j�|�d|j�|�d|j�dS)NzNoauth_token_secret=secret%3Dpassword&oauth_token=lock%26key&lp.context=firefoxr
rZfirefox)rrr
rrrrrrr�test_from_string_with_context6s�z-TestAccessToken.test_from_string_with_contextN)�__name__�
__module__�__qualname__�__doc__rrrrrrr	,sr	c@seZdZdd�ZdS)�CredentialStoreTestCasecCstddt|d�d�S)z(Helper method to make a fake credential.zapp namezconsumer_secret:42zaccess_secret:168)Zconsumer_secretr)rr)rZconsumer_keyrrr�make_credentialAs
�z'CredentialStoreTestCase.make_credentialN)rrrrrrrrr?src@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�"TestUnencryptedFileCredentialStorez3Tests for the UnencryptedFileCredentialStore class.cCst��\}|_t|j�|_dS�N)�tempfileZmkstemp�filenamer�store)r�ignorerrr�setUpKsz(TestUnencryptedFileCredentialStore.setUpcCstj�|j�rt�|j�dSr )�os�path�existsr"�remove�rrrr�tearDownOsz+TestUnencryptedFileCredentialStore.tearDowncCs<|�d�}|j�|d�|j�d�}|�|jj|jj�dS�N�consumer key�
unique key�rr#�save�loadr
�consumerr�r�
credential�credential2rrr�test_save_and_loadSs
z5TestUnencryptedFileCredentialStore.test_save_and_loadcCs<|�d�}|j�|d�|j�d�}|�|jj|jj�dS)Nr-zsome keyzsome other keyr/r3rrr�test_unique_id_doesnt_matterZs
z?TestUnencryptedFileCredentialStore.test_unique_id_doesnt_mattercCsT|�d�}|�d�}|j�|d�|j�|d�|j�d�}|�|jj|jj�dS)Nr-�
consumer key2zunique key 1zunique key 2r/�r�credential1r5Zloadedrrr�&test_file_only_contains_one_credentialbs

zITestUnencryptedFileCredentialStore.test_file_only_contains_one_credentialN)	rrrrr%r+r6r7r;rrrrrHsrc@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�TestKeyringCredentialStorez+Tests for the KeyringCredentialStore class.cCst�|_t�|_dSr )r�keyringrr#r*rrrr%rsz TestKeyringCredentialStore.setUpc	CsRt|j��>|�d�}|j�|d�|j�d�}|�|jj|jj�W5QRXdSr,�	rr=rr#r0r1r
r2rr3rrrr6vs
�z-TestKeyringCredentialStore.test_save_and_loadc	Cs�t|j���|�d�}|j�|d�|�d�}|j�|d�|j�d�}|�|�|�|jj	|jj	�|j�d�}|�|jj	|jj	�W5QRXdS)N�
consumer key1zkey 1r8zkey 2)
rr=rr#r0r1�
assertTruer
r2r)rr:r5Zloaded1Zloaded2rrr�test_lookup_by_unique_keys 


��z4TestKeyringCredentialStore.test_lookup_by_unique_keyc	Csjt|j��V|�d�}|j�|d�|�d�}|j�|d�|j�d�}|�|jj|jj�W5QRXdS)Nr?zthe only keyr8r>r9rrr�/test_reused_unique_id_overwrites_old_credential�s

�zJTestKeyringCredentialStore.test_reused_unique_id_overwrites_old_credentialc	Cs,t|j��|�|j�d��W5QRXdS)Nzno such key)rr=rr#r1r*rrr�test_bad_unique_id_returns_none�sz:TestKeyringCredentialStore.test_bad_unique_id_returns_nonec	s�G�fdd�dt����|_t|j��f|�d�}|�|�|j�|d�|j�d�}|�|�|�|j	j
|j	j
�|�|j	j|j	j�W5QRXdS)NcseZdZ��fdd�Z�ZS)zWTestKeyringCredentialStore.test_keyring_returns_unicode.<locals>.UnicodeInMemoryKeyringcs*t�|��||�}t|t�r&|�d�}|S)Nzutf-8)�super�get_password�
isinstance�unicode_type�encode)r�service�usernameZpassword)�UnicodeInMemoryKeyring�	__class__rrrE�s
�

zdTestKeyringCredentialStore.test_keyring_returns_unicode.<locals>.UnicodeInMemoryKeyring.get_password�rrrrE�
__classcell__r�rK�rLrrK�srKr-r.)rr=rrr@r#r0r1r
r2rrr3rrOr�test_keyring_returns_unicode�s 


��z7TestKeyringCredentialStore.test_keyring_returns_unicodec	s�G�fdd�dt����|_t|j��R|�d�}|j�|d�|j�d�}|�|jj	|jj	�|�|jj
|jj
�W5QRXdS)NcseZdZ��fdd�Z�ZS)zXTestKeyringCredentialStore.test_nonencoded_key_handled.<locals>.UnencodedInMemoryKeyringcs"t�|��||�}t|dd��S)N�)rDrEr)rrIrJZpw)�UnencodedInMemoryKeyringrLrrrE�s

�zeTestKeyringCredentialStore.test_nonencoded_key_handled.<locals>.UnencodedInMemoryKeyring.get_passwordrMr�rSrPrrS�srSr-r.)rr=rrr#r0r1r
r2rrr3rrTr�test_nonencoded_key_handled�s
��z6TestKeyringCredentialStore.test_nonencoded_key_handledc	Cs`Gdd�dt�}|�|_t|j��4|�d�}|j�|d�|j�d�}|�|�W5QRXdS)Nc@seZdZdd�ZdS)zWTestKeyringCredentialStore.test_corrupted_key_handled.<locals>.CorruptedInMemoryKeyringcSsdS)NZbadr)rrIrJrrrrE�szdTestKeyringCredentialStore.test_corrupted_key_handled.<locals>.CorruptedInMemoryKeyring.get_passwordN)rrrrErrrr�CorruptedInMemoryKeyring�srVr-r.)rr=rrr#r0r1r)rrVr4r5rrr�test_corrupted_key_handled�s
z5TestKeyringCredentialStore.test_corrupted_key_handledN)rrrrr%r6rArBrCrQrUrWrrrrr<os	r<)rr&r!Zunittest�base64r�bytes�strZunicoderGZlaunchpadlib.testing.helpersrrZlaunchpadlib.credentialsrrrrZTestCaser	rrr<rrrr�<module>s	'