a
    “I_¾  ã                   @   s†   d Z ddlZddlZddlmZ dZdZdZejd Z	ejd Z
ejd	 Zd
ee
f Zej ed¡Zej ed¡ZG dd„ deƒZdS )z!Blackbox tests for traffic_replayé    N)ÚBlackboxTestCasez$python/samba/tests/blackbox/testdatazscript/traffic_replayz!--fixed-password=trafficreplay01%ÚSERVERÚPASSWORDZUSERNAMEz-U%s%%%sztraffic-sample-very-short.modelztraffic_replay-%s.expectedc                   @   s<   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )ÚTrafficLearnerTestsc                 C   s"   d}dt |ttf }|  |¡ d S )Nz
--clean-upú%s %s %s %s)ÚSCRIPTÚCREDSr   Ú	check_run©ÚselfZoptionsÚcommand© r   úE/usr/lib/python3/dist-packages/samba/tests/blackbox/traffic_replay.pyÚtearDown&   s    zTrafficLearnerTests.tearDownc                 C   sB   d}dt |tttf }|  |¡ dt t|tttf }|  |¡ dS )zEEnsure the generate users only option functions correctly
           ú[--generate-users-only --number-of-users 20 --number-of-groups 5 --average-groups-per-user 2ú%s %s %s %s %sz%s %s %s %s %s %sN)r   ÚFIXEDr   r   r	   ÚMODELr
   r   r   r   Útest_generate_users_only+   s    
ÿ
ÿz,TrafficLearnerTests.test_generate_users_onlyc              	   C   s¢   t dgdgddgg d¢fƒD ]€\}}|  ¡ `}ttd|ddg| tttg }|  |¡ tt	| ƒ 
¡ }t|ƒ 
¡ }|  ||¡ W d  ƒ q1 s’0    Y  qdS )	z?Ensure a summary file is generated and the contents are correctú--random-seed=3z--random-seed=4z--conversation-persistence=0.5)r   z--old-scalez--conversation-persistence=0.95z--traffic-summaryz-D1ú-S0.1N)Ú	enumerateZmktempr   r   r   r   r   r	   ÚopenÚEXPECTED_OUTPUTÚreadZassertStringsEqual)r   ÚiZoptsÚoutputr   ZexpectedZactualr   r   r   Útest_summary_generation7   s(    ÿü
þýü
z+TrafficLearnerTests.test_summary_generationc                 C   s   t tttg}|  |d¡ dS )z>Ensure a summary file with no fixed password fails
           é   N)r   r   r   r   Úcheck_exit_code©r   r   r   r   r   Útest_summary_replay_no_fixedM   s    z0TrafficLearnerTests.test_summary_replay_no_fixedc                 C   s    t ttddttg}|  |¡ dS )z7Ensure a model can be replayed against a DC
           z-D2r   N)r   r   r   r   r   r	   r    r   r   r   Útest_model_replayS   s    ýz%TrafficLearnerTests.test_model_replayc                 C   sB   d}dt |ttf }|  |d¡ dt t|ttf }|  |d¡ dS )zOEnsure the generate users only fails if no fixed_password supplied"
           r   r   r   r   N)r   r   r   r   r   r
   r   r   r   Ú$test_generate_users_only_no_password\   s
    z8TrafficLearnerTests.test_generate_users_only_no_passwordN)	Ú__name__Ú
__module__Ú__qualname__r   r   r   r!   r"   r#   r   r   r   r   r   $   s   	r   )Ú__doc__ÚosZtempfileZsamba.testsr   ZDATA_DIRr   r   Úenvironr   r   ZUSERr   ÚpathÚjoinr   r   r   r   r   r   r   Ú<module>   s   


