U
    
W[‰  ã                   @   sl   d Z ddlmZmZ ddlmZ ddlmZmZ ddlm	Z	 ddlm
Z
 G dd„ deƒZG d	d
„ d
eƒZdS )z<
Tests for basic constructs of L{twisted.cred.credentials}.
é    )ÚdivisionÚabsolute_import)ÚTestCase)ÚUsernamePasswordÚIUsernamePassword)ÚUsernameHashedPassword)ÚIUsernameHashedPasswordc                   @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚUsernamePasswordTestsz(
    Tests for L{UsernamePassword}.
    c                 C   s*   t ddƒ}|  |jd¡ |  |jd¡ dS )zo
        The initialisation of L{UsernamePassword} will set C{username} and
        C{password} on it.
        ó   fooó   barN)r   ÚassertEqualÚusernameZpassword©ÚselfZcreds© r   úC/usr/lib/python3/dist-packages/twisted/cred/test/test_simpleauth.pyÚtest_initialisation   s    
z)UsernamePasswordTests.test_initialisationc                 C   s   t ddƒ}|  | d¡¡ dS )z–
        Calling C{checkPassword} on a L{UsernamePassword} will return L{True}
        when the password given is the password on the object.
        ó   useró   passN)r   Ú
assertTrueÚcheckPasswordr   r   r   r   Útest_correctPassword   s    
z*UsernamePasswordTests.test_correctPasswordc                 C   s   t ddƒ}|  | d¡¡ dS )z›
        Calling C{checkPassword} on a L{UsernamePassword} will return L{False}
        when the password given is NOT the password on the object.
        r   r   ó   someotherpassN)r   ÚassertFalser   r   r   r   r   Útest_wrongPassword'   s    
z(UsernamePasswordTests.test_wrongPasswordc                 C   s   |   t t¡¡ dS )zF
        L{UsernamePassword} implements L{IUsernamePassword}.
        N)r   r   ÚimplementedByr   ©r   r   r   r   Útest_interface0   s    z$UsernamePasswordTests.test_interfaceN©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r	      s
   
		r	   c                   @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚUsernameHashedPasswordTestsz.
    Tests for L{UsernameHashedPassword}.
    c                 C   s*   t ddƒ}|  |jd¡ |  |jd¡ dS )zs
        The initialisation of L{UsernameHashedPassword} will set C{username}
        and C{hashed} on it.
        r
   r   N)r   r   r   Zhashedr   r   r   r   r   <   s    
z/UsernameHashedPasswordTests.test_initialisationc                 C   s   t ddƒ}|  | d¡¡ dS )zœ
        Calling C{checkPassword} on a L{UsernameHashedPassword} will return
        L{True} when the password given is the password on the object.
        r   r   N)r   r   r   r   r   r   r   r   F   s    
z0UsernameHashedPasswordTests.test_correctPasswordc                 C   s   t ddƒ}|  | d¡¡ dS )z¡
        Calling C{checkPassword} on a L{UsernameHashedPassword} will return
        L{False} when the password given is NOT the password on the object.
        r   r   r   N)r   r   r   r   r   r   r   r   O   s    
z.UsernameHashedPasswordTests.test_wrongPasswordc                 C   s   |   t t¡¡ dS )zR
        L{UsernameHashedPassword} implements L{IUsernameHashedPassword}.
        N)r   r   r   r   r   r   r   r   r   X   s    ÿz*UsernameHashedPasswordTests.test_interfaceNr   r   r   r   r   r#   8   s
   
		r#   N)r"   Z
__future__r   r   Ztwisted.trial.unittestr   Ztwisted.cred.credentialsr   r   r   r   r	   r#   r   r   r   r   Ú<module>   s   (