+
    Z4i"                         R t ^ RIt^ RIt^ RIt^ RIHt ]]J d   ]t	M]t	^ RI
HtHt ^ RIHtHtHtHt  ! R R]P$                  4      t ! R R]P$                  4      t ! R	 R
]4      t ! R R]4      tR# )z'Tests for the credential store classes.N)	b64decode)fake_keyringInMemoryKeyring)AccessTokenCredentialsKeyringCredentialStoreUnencryptedFileCredentialStorec                   0   a  ] tR t^,t o RtR tR tRtV tR# )TestAccessTokenz Tests for the AccessToken class.c                    \         P                  ! R 4      pV P                  RVP                  4       V P                  RVP                  4       V P                  VP                  4       R# )z;oauth_token_secret=secret%3Dpassword&oauth_token=lock%26keylock&keysecret=passwordN)r   from_stringassertEqualkeysecretassertIsNonecontextselfaccess_tokens   & J/usr/lib/python3/dist-packages/launchpadlib/tests/test_credential_store.pytest_from_string TestAccessToken.test_from_string/   sX    "..I
 	\%5%56*L,?,?@,../    c                    \         P                  ! R 4      pV P                  RVP                  4       V P                  RVP                  4       V P                  RVP
                  4       R# )zNoauth_token_secret=secret%3Dpassword&oauth_token=lock%26key&lp.context=firefoxr   r   firefoxN)r   r   r   r   r   r   r   s   & r   test_from_string_with_context-TestAccessToken.test_from_string_with_context7   s\    "..!
 	\%5%56*L,?,?@L$8$89r    N)	__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes____classdictcell____classdict__s   @r   r
   r
   ,   s     *0: :r   r
   c                   &   a  ] tR t^At o R tRtV tR# )CredentialStoreTestCasec                2    \        RR\        VR4      R7      # )z(Helper method to make a fake credential.zapp namezconsumer_secret:42zaccess_secret:168)consumer_secretr   )r   r   )r   consumer_keys   &&r   make_credential'CredentialStoreTestCase.make_credentialB   s     0$\3FG
 	
r   r   N)r    r!   r"   r#   r.   r%   r&   r'   s   @r   r*   r*   A   s     
 
r   r*   c                   B   a  ] tR t^Kt o RtR tR tR tR tR t	Rt
V tR# )	"TestUnencryptedFileCredentialStorez3Tests for the UnencryptedFileCredentialStore class.c                r    \         P                  ! 4       w  qn        \        V P                  4      V n        R # N)tempfilemkstempfilenamer   store)r   ignores   & r   setUp(TestUnencryptedFileCredentialStore.setUpN   s%     ( 0 0 23DMMB
r   c                    \         P                  P                  V P                  4      '       d#   \         P                  ! V P                  4       R # R # r3   )ospathexistsr6   remover   s   &r   tearDown+TestUnencryptedFileCredentialStore.tearDownR   s.    77>>$--((IIdmm$ )r   c                
   V P                  R 4      pV P                  P                  VR4       V P                  P                  R4      pV P	                  VP
                  P                  VP
                  P                  4       R# consumer key
unique keyNr.   r7   saveloadr   consumerr   r   
credentialcredential2s   &  r   test_save_and_load5TestUnencryptedFileCredentialStore.test_save_and_loadV   s^    )).9



L1jjool3,,00+2F2F2J2JKr   c                
   V P                  R 4      pV P                  P                  VR4       V P                  P                  R4      pV P	                  VP
                  P                  VP
                  P                  4       R# )rE   zsome keyzsome other keyNrG   rK   s   &  r   test_unique_id_doesnt_matter?TestUnencryptedFileCredentialStore.test_unique_id_doesnt_matter]   sa     )).9



J/jjoo&67,,00+2F2F2J2JKr   c                d   V P                  R 4      pV P                  R4      pV P                  P                  VR4       V P                  P                  VR4       V P                  P                  R4      pV P	                  VP
                  P                  VP
                  P                  4       R# )rE   consumer key2zunique key 1zunique key 2NrG   r   credential1rM   loadeds   &   r   &test_file_only_contains_one_credentialITestUnencryptedFileCredentialStore.test_file_only_contains_one_credentiale   s    
 **>:**?;

^4

^40,,k.B.B.F.FGr   )r6   r7   N)r    r!   r"   r#   r$   r9   rA   rN   rQ   rX   r%   r&   r'   s   @r   r1   r1   K   s+     =C%LL
H 
Hr   r1   c                   T   a  ] tR t^rt o RtR tR tR tR tR t	R t
R tR	 tR
tV tR# )TestKeyringCredentialStorez+Tests for the KeyringCredentialStore class.c                B    \        4       V n        \        4       V n        R # r3   )r   keyringr   r7   r@   s   &r   r9    TestKeyringCredentialStore.setUpu   s    &(+-
r   c                ~   \        V P                  4      ;_uu_ 4        V P                  R 4      pV P                  P	                  VR4       V P                  P                  R4      pV P                  VP                  P                  VP                  P                  4       RRR4       R#   + '       g   i     R# ; irD   	r   r]   r.   r7   rH   rI   r   rJ   r   rK   s   &  r   rN   -TestKeyringCredentialStore.test_save_and_loady   s|    $,,''--n=JJJOOJ5**//,7KZ0044k6J6J6N6NO	 ('''s   BB++B<	c                   \        V P                  4      ;_uu_ 4        V P                  R 4      pV P                  P	                  VR4       V P                  R4      pV P                  P	                  VR4       V P                  P                  R4      pV P                  V4       V P                  VP                  P                  VP                  P                  4       V P                  P                  R4      pV P                  VP                  P                  VP                  P                  4       RRR4       R#   + '       g   i     R# ; i)consumer key1zkey 1rT   zkey 2N)
r   r]   r.   r7   rH   rI   
assertTruer   rJ   r   )r   rV   rM   loaded1loaded2s   &    r   test_lookup_by_unique_key4TestKeyringCredentialStore.test_lookup_by_unique_key   s     $,,''..?KJJOOK1..?KJJOOK1jjoog.GOOG$[1155w7G7G7K7KLjjoog.G[1155w7G7G7K7KL ('''s   DD>>E	c                   \        V P                  4      ;_uu_ 4        V P                  R 4      pV P                  P	                  VR4       V P                  R4      pV P                  P	                  VR4       V P                  P                  R4      pV P                  VP                  P                  VP                  P                  4       RRR4       R#   + '       g   i     R# ; i)rc   zthe only keyrT   Nr`   rU   s   &   r   /test_reused_unique_id_overwrites_old_credentialJTestKeyringCredentialStore.test_reused_unique_id_overwrites_old_credential   s     $,,''..?KJJOOK8..?KJJOOK8ZZ__^4F[1155v7J7JK ('''s   B0CC)	c                    \        V P                  4      ;_uu_ 4        V P                  V P                  P	                  R 4      4       RRR4       R#   + '       g   i     R# ; i)zno such keyN)r   r]   r   r7   rI   r@   s   &r   test_bad_unique_id_returns_none:TestKeyringCredentialStore.test_bad_unique_id_returns_none   s=     $,,''djjoom<= ('''s   +AA$	c                l    ! R  R\         4      pV! 4       V n        \        V P                  4      ;_uu_ 4        V P                  R4      pV P	                  V4       V P
                  P                  VR4       V P
                  P                  R4      pV P	                  V4       V P                  VP                  P                  VP                  P                  4       V P                  VP                  P                  VP                  P                  4       RRR4       R#   + '       g   i     R# ; i)c                   2   a a ] tR t^t oV 3R ltRtVtV ;t# )WTestKeyringCredentialStore.test_keyring_returns_unicode.<locals>.UnicodeInMemoryKeyringc                t   < \         SV `  W4      p\        V\        4      '       d   VP	                  R 4      pV# )zutf-8)superget_password
isinstanceunicode_typeencode)r   serviceusernamepassword	__class__s   &&& r   rt   dTestKeyringCredentialStore.test_keyring_returns_unicode.<locals>.UnicodeInMemoryKeyring.get_password   s2     7/Bh55'w7Hr   r   r    r!   r"   r#   rt   r%   r&   __classcell__r{   r(   s   @@r   UnicodeInMemoryKeyringrq      s        r   r   rE   rF   N)r   r]   r   r.   rd   r7   rH   rI   r   rJ   r   r   )r   r   rL   rM   s   &   r   test_keyring_returns_unicode7TestKeyringCredentialStore.test_keyring_returns_unicode   s    	 _ 	  ./$,,''--n=JOOJ'JJOOJ5**//,7KOOK(Z0044k6J6J6N6NO##**K,@,@,G,G ('''s   CD""D3	c                (    ! R  R\         4      pV! 4       V n        \        V P                  4      ;_uu_ 4        V P                  R4      pV P                  P                  VR4       V P                  P                  R4      pV P                  VP                  P                  VP                  P                  4       V P                  VP                  P                  VP                  P                  4       RRR4       R#   + '       g   i     R# ; i)c                   2   a a ] tR t^t oV 3R ltRtVtV ;t# )XTestKeyringCredentialStore.test_nonencoded_key_handled.<locals>.UnencodedInMemoryKeyringc                F   < \         SV `  W4      p\        VR ,          4      # ):   NN)rs   rt   r   )r   rx   ry   pwr{   s   &&& r   rt   eTestKeyringCredentialStore.test_nonencoded_key_handled.<locals>.UnencodedInMemoryKeyring.get_password   s!    W)'< B((r   r   r}   r   s   @@r   UnencodedInMemoryKeyringr      s     ) )r   r   rE   rF   N)r   r]   r   r.   r7   rH   rI   r   rJ   r   r   )r   r   rL   rM   s   &   r   test_nonencoded_key_handled6TestKeyringCredentialStore.test_nonencoded_key_handled   s    	) 	)
 01$,,''--n=JJJOOJ5**//,7KZ0044k6J6J6N6NO##**K,@,@,G,G ('''s   B=D  D	c                b    ! R  R\         4      pV! 4       V n        \        V P                  4      ;_uu_ 4        V P                  R4      pV P                  P                  VR4       V P                  P                  R4      pV P                  V4       RRR4       R#   + '       g   i     R# ; i)c                   &   a  ] tR t^t o R tRtV tR# )WTestKeyringCredentialStore.test_corrupted_key_handled.<locals>.CorruptedInMemoryKeyringc                    R # )badr   )r   rx   ry   s   &&&r   rt   dTestKeyringCredentialStore.test_corrupted_key_handled.<locals>.CorruptedInMemoryKeyring.get_password   s    r   r   N)r    r!   r"   r#   rt   r%   r&   r'   s   @r   CorruptedInMemoryKeyringr      s      r   r   rE   rF   N)r   r]   r   r.   r7   rH   rI   r   )r   r   rL   rM   s   &   r   test_corrupted_key_handled5TestKeyringCredentialStore.test_corrupted_key_handled   sz    	 	 01$,,''--n=JJJOOJ5**//,7Kk*	 ('''s   ABB.	)r]   r7   N)r    r!   r"   r#   r$   r9   rN   rg   rj   rm   r   r   r   r%   r&   r'   s   @r   r[   r[   r   s8     5.PM"L>0$+ +r   r[   )r$   r<   r4   unittestbase64r   bytesstrunicoderv   launchpadlib.testing.helpersr   r   launchpadlib.credentialsr   r   r   r   TestCaser
   r*   r1   r[   r   r   r   <module>r      sy   " . 	   C<LL
 :h'' :*
h// 
$H)@ $HNj+!8 j+r   