
    b4*                     2    d dl mZmZ  G d de          ZdS )    )UserCmdCryptShaTestCase_get_attributec                   Z    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd ZdS )UserCmdCryptShaTestCaseGPGzz
    Tests for samba-tool user subcommands generation of the virtualCryptSHA256
    and virtualCryptSHA512 attributes
    c                     |                                   |                     dd          }|                     d|v            |                     d|v            |                     d|v           d S Nz%virtualCryptSHA256,virtualCryptSHA512TvirtualCryptSHA256:virtualCryptSHA512:rounds=add_user_get_password
assertTrueselfouts     Q/usr/lib/python3/dist-packages/samba/tests/samba_tool/user_virtualCryptSHA_gpg.pytest_gpg_both_hashes_no_roundsz9UserCmdCryptShaTestCaseGPG.test_gpg_both_hashes_no_rounds   sr      !H$OO-4555-4555	,-----    c                     |                                   |                     dd          }|                     d|v            |                     d|v           |                     d|v           d S NvirtualCryptSHA256Tr	   r
   r   r   r   s     r   test_gpg_sha256_no_roundsz4UserCmdCryptShaTestCaseGPG.test_gpg_sha256_no_rounds-   sr      !5t<<-4555-S8999	,-----r   c                     |                                   |                     dd          }|                     d|v           |                     d|v            |                     d|v           d S )NvirtualCryptSHA512Tr	   r
   r   r   r   s     r   test_gpg_sha512_no_roundsz4UserCmdCryptShaTestCaseGPG.test_gpg_sha512_no_rounds;   sr      !5t<<-S8999-4555	,-----r   c                     |                                   |                     dd          }|                     d|v           |                     d|v           |                     d|v           d S )NvirtualCryptSHA128Tr	   r
   r   r   r   s     r   test_gpg_invalid_alg_no_roundsz9UserCmdCryptShaTestCaseGPG.test_gpg_invalid_alg_no_roundsI   sr      !5t<<-S8999-S8999	,-----r   c                    |                                   |                                  |                     dd          }|                     d|v           |                     d|v           |                     d|v           d S r   r   _change_nt_hashr   r   r   s     r   *test_gpg_both_hashes_no_rounds_pwd_changedzEUserCmdCryptShaTestCaseGPG.test_gpg_both_hashes_no_rounds_pwd_changedW   s      !H$OO-S8999-S8999	,-----r   c                    |                                   |                                  |                     dd          }|                     d|v           |                     d|v           |                     d|v           d S r   r!   r   s     r   %test_gpg_sha256_no_rounds_pwd_changedz@UserCmdCryptShaTestCaseGPG.test_gpg_sha256_no_rounds_pwd_changedf         !5t<<-S8999-S8999	,-----r   c                    |                                   |                                  |                     dd          }|                     d|v           |                     d|v           |                     d|v           d S r   r!   r   s     r   %test_gpg_sha512_no_rounds_pwd_changedz@UserCmdCryptShaTestCaseGPG.test_gpg_sha512_no_rounds_pwd_changedu   r&   r   c                    |                                   |                     dd          }|                     d|v            |                     d|v            t          |d          }|                     |                    d                     t          |d          }|                     |                    d                     d S )	Nz?virtualCryptSHA256;rounds=10123,virtualCryptSHA512;rounds=10456Tr	   r
   r   z{CRYPT}$5$rounds=10123$r   z{CRYPT}$6$rounds=10456$r   r   r   r   
startswithr   r   sha256sha512s       r    test_gpg_both_hashes_both_roundsz;UserCmdCryptShaTestCaseGPG.test_gpg_both_hashes_both_rounds   s      M  	-4555-4555%9::))*CDDEEE%9::))*CDDEEEEEr   c                    |                                   |                     dd          }|                     d|v            |                     d|v            t          |d          }|                     |                    d                     |                     d|v           t          |d          }|                     |                    d	                     d S )
Nz@virtualCryptSHA256;rounds=invalid,virtualCryptSHA512;rounds=3125Tr	   r
   r   z
{CRYPT}$5$roundsr   z{CRYPT}$6$rounds=3125$r*   r,   s       r   *test_gpg_both_hashes_sha256_rounds_invalidzEUserCmdCryptShaTestCaseGPG.test_gpg_both_hashes_sha256_rounds_invalid   s      N  	-4555-4555%9::)),77888.///%9::))*BCCDDDDDr   c                    |                      d           |                     dd          }|                     d|v            |                     d|v            |                     d|v            t          |d          }t          |d          }|                     dd          }|                     |t          |d          k               |                     |t          |d          k               |                     |                    d	                     |                     |                    d
                     d S )NzCryptSHA512 CryptSHA256=virtualCryptSHA256;rounds=2561,virtualCryptSHA512;rounds=5129Tr	   r
   r   r   r   {CRYPT}$5$rounds=2561{CRYPT}$6$rounds=5129r   r   r   r   assertFalser+   r,   s       r   )test_gpg_both_hashes_rounds_stored_hasheszDUserCmdCryptShaTestCaseGPG.test_gpg_both_hashes_rounds_stored_hashes   sP   /000   "B!%' ' 	-4555-4555	S()))  %9::%9::   "B!%' ' 	>#7K#L#LLMMM>#7K#L#LLMMM 	))*ABBCCC))*ABBCCCCCr   c                    |                      d           |                     dd          }|                     d|v            |                     d|v            |                     d|v            t          |d          }t          |d          }|                     dd          }|                     |t          |d                     |                     |t          |d                     |                     |                    d	                     |                     |                    d
                     d S )NGCryptSHA512 CryptSHA256 CryptSHA512:rounds=5129 CryptSHA256:rounds=2561r4   Tr	   r
   r   r   r   r5   r6   )r   r   r   r   assertEqualsr+   r,   s       r   5test_gpg_both_hashes_rounds_stored_hashes_with_roundszPUserCmdCryptShaTestCaseGPG.test_gpg_both_hashes_rounds_stored_hashes_with_rounds   sT    0 	1 	1 	1
    "B!%' ' 	-4555-4555	S()))  %9::%9::   "B!%' ' 	&.6J"K"KLLL&.6J"K"KLLL 	))*ABBCCC))*ABBCCCCCr   c                    |                      d           |                     dd          }|                     d|v            |                     d|v            |                     d|v            t          |d          }t          |d          }|                     dd          }|                     |t          |d          k               |                     |t          |d          k               |                     |                    d	                     |                     |                    d
                     d S )Nr;   z=virtualCryptSHA256;rounds=4000,virtualCryptSHA512;rounds=5000Tr	   r
   r   r   r   z{CRYPT}$5$rounds=4000z{CRYPT}$6$rounds=5000r7   r,   s       r   >test_gpg_both_hashes_rounds_stored_hashes_with_rounds_no_matchzYUserCmdCryptShaTestCaseGPG.test_gpg_both_hashes_rounds_stored_hashes_with_rounds_no_match   sZ    0 	1 	1 	1
    "B!%' ' 	-4555-4555	S()))  %9::%9::   "B!%' ' 	>#7K#L#LLMMM>#7K#L#LLMMM 	))*ABBCCC))*ABBCCCCCr   N)__name__
__module____qualname____doc__r   r   r   r   r#   r%   r(   r/   r2   r9   r=   r?    r   r   r   r      s         . . .. . .. . .. . .. . .. . .. . .F F F(E E E(D D D<D D DDD D D D Dr   r   N)0samba.tests.samba_tool.user_virtualCryptSHA_baser   r   r   rD   r   r   <module>rF      si   & e d d d d d d dpD pD pD pD pD!8 pD pD pD pD pDr   