a
    “I_  ã                   @   sD   d Z ddlmZ ddlZG dd„ dejjƒZG dd„ dejjƒZdS )z¤Tests for the Auth Python bindings.

Note that this just tests the bindings work. It does not intend to test
the functionality, that's already done in other tests.
é    )ÚauthNc                       sD   e Zd Z‡ fdd„Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Z‡  Z	S )ÚAuthSystemSessionTestsc                    s(   t t| ƒ ¡  t ¡ | _tj ¡ | _d S ©N)	Úsuperr   ÚsetUpr   Úsystem_sessionÚsambaÚtestsÚenv_loadparmÚlp©Úself©Ú	__class__© ú2/usr/lib/python3/dist-packages/samba/tests/auth.pyr      s    
zAuthSystemSessionTests.setUpc                 C   s^   |   t| jdƒ¡ |   t| jdƒ¡ |   t| jdƒ¡ |   t| jdƒ¡ |   t| jdƒ¡ d S ©NÚcredentialsÚinfoÚsecurity_tokenÚsession_keyZtorture)Ú
assertTrueÚhasattrr   r   r   r   r   Útest_system_session_attrs#   s
    z0AuthSystemSessionTests.test_system_session_attrsc                 C   sL   |   | jj ¡ ¡ |  | jj ¡ ¡ |  | jj ¡ | j 	d¡ 
¡ d ¡ d S )Nznetbios nameú$)ÚassertIsNoner   r   Zget_bind_dnÚassertIsNotNoneZget_passwordÚassertEqualZget_usernamer   ÚgetÚupperr   r   r   r   Útest_system_session_credentials*   s
    ÿz6AuthSystemSessionTests.test_system_session_credentialsc                 C   s:   |   | jjjd¡ |   | jjjd¡ |   | jjjd¡ d S )NZSystemzNT AUTHORITYZSYSTEM)r   r   r   Ú	full_nameÚdomain_nameÚaccount_namer   r   r   r   Útest_system_session_info0   s    z/AuthSystemSessionTests.test_system_session_infoc                 C   s   d}|   | jj|¡ d S )Ns                   )r   r   r   )r   Zexpectedr   r   r   Útest_system_session_session_key5   s    z6AuthSystemSessionTests.test_system_session_session_keyc                 C   s(   |   | jj ¡ ¡ |  | jj ¡ ¡ d S r   )r   r   r   Ú	is_systemÚassertFalseÚis_anonymousr   r   r   r   Ú"test_system_session_security_token9   s    z9AuthSystemSessionTests.test_system_session_security_token)
Ú__name__Ú
__module__Ú__qualname__r   r   r    r$   r%   r)   Ú__classcell__r   r   r   r   r      s   r   c                       sD   e Zd Z‡ fdd„Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Z‡  Z	S )ÚAuthAdminSessionTestsc                    s.   t t| ƒ ¡  tj ¡ | _t | jd¡| _d S )Nz)S-1-5-21-2212615479-2695158682-2101375467)	r   r.   r   r   r	   r
   r   r   Úadmin_sessionr   r   r   r   r   @   s
    ÿzAuthAdminSessionTests.setUpc                 C   s^   |   t| jdƒ¡ |   t| jdƒ¡ |   t| jdƒ¡ |   t| jdƒ¡ |   t| jdƒ¡ d S r   )r   r   r/   r   r   r   r   Útest_admin_session_attrsF   s
    z.AuthAdminSessionTests.test_admin_session_attrsc                 C   s   |   | jj¡ d S r   )r   r/   r   r   r   r   r   Útest_admin_session_credentialsM   s    z4AuthAdminSessionTests.test_admin_session_credentialsc                 C   sB   |   | jjjd¡ |   | jjj| j d¡¡ |   | jjjd¡ d S )NÚAdministratorÚ	workgroup)r   r/   r   r!   r"   r   r   r#   r   r   r   r   Útest_session_info_detailsP   s    ÿ
ÿÿz/AuthAdminSessionTests.test_session_info_detailsc                 C   s:   |   | jj ¡ ¡ |   | jj ¡ ¡ |  | jj ¡ ¡ d S r   )r'   r/   r   r&   r(   r   Zhas_builtin_administratorsr   r   r   r   Útest_security_tokenX   s    z)AuthAdminSessionTests.test_security_tokenc                 C   sh   t jj| j| jdd |  | jjjd¡ |  | jjj| j 	d¡ 
¡ | j 	d¡ d ¡ |  | jj¡ d S )Nr2   )Zsession_infoZlp_ctxZ	user_namer3   zwinbind separator)r   r   Zsession_info_fill_unixr/   r   r   Z	unix_infoZsanitized_usernameZ	unix_namer   r   r   Z
unix_tokenr   r   r   r   Útest_session_info_unix_details]   s    
þÿ
ÿÿÿz4AuthAdminSessionTests.test_session_info_unix_details)
r*   r+   r,   r   r0   r1   r4   r5   r6   r-   r   r   r   r   r.   >   s   r.   )Ú__doc__r   r   Zsamba.testsr	   ZTestCaser   r.   r   r   r   r   Ú<module>   s   "