
    b                     Z    d dl mZ d dlZd dlmZ dZ G d dej        j                  Z	dS )    )StringION)trafficz&testdata/traffic-sample-very-short.txtc                   &    e Zd Zd Zd Zd Zd ZdS )TrafficEmulatorTestsc                 6    t          j                    | _        d S N)r   TrafficModelmodelselfs    =/usr/lib/python3/dist-packages/samba/tests/emulate/traffic.pysetUpzTrafficEmulatorTests.setUp   s    )++


    c                 
    | ` d S r   )r
   r   s    r   tearDownzTrafficEmulatorTests.tearDown!   s    JJJr   c                    t          j                    }t          t                    }t          j        |gd          \  }}}}|                                 |                    |           g dg ddgddgdgg ddgd	gd
gdgdgdgd}g dg ddgdgddgdgd}d| _        d |j        	                                D             }	d |j
        	                                D             }
|                     ||	           |                     ||
           t                      }|                    |           t          j                    }|                    d           |                    |           d |j        	                                D             }	d |j
        	                                D             }
|                     ||	           |                     ||
           d S )Ninclude)dns_mode)dns:0r   r   ldap:3)r   r   r   wait:0cldap:3rpc_netlogon:29)r   r   r   r   -ldap:2r   	kerberos:)r   r   )r   r   r   r   r   r   r   r   )r   r   )r   r   r   r   r   r   r   r   )r   r   r   r    r'   r'   Netlogonr'   r'   r'   r&   r&   )	 r)   r)   r)   r)   r)   r)   r)   r)   r'   r'   r'   r'   r'   r'   r'   r'   r'   r'   r'   a  subschemaSubentry,dsServiceName,namingContexts,defaultNamingContext,schemaNamingContext,configurationNamingContext,rootDomainNamingContext,supportedControl,supportedLDAPVersion,supportedLDAPPolicies,supportedSASLMechanisms,dnsHostName,ldapServiceName,serverName,supportedCapabilitiesr'   r'   r'   2zDC,DCr'   cnr'   r'   r'   r)   )r   r   r   r   r   r     c                 4    i | ]\  }}|t          |          S r)   sorted.0kvs      r   
<dictcomp>zGTrafficEmulatorTests.test_parse_ngrams_dns_included.<locals>.<dictcomp>S   s$    @@@41a!VAYY@@@r   c                 4    i | ]\  }}|t          |          S r)   r2   r4   s      r   r8   zGTrafficEmulatorTests.test_parse_ngrams_dns_included.<locals>.<dictcomp>T   s$    HHHDAq1fQiiHHHr   r   c                 4    i | ]\  }}|t          |          S r)   r2   r4   s      r   r8   zGTrafficEmulatorTests.test_parse_ngrams_dns_included.<locals>.<dictcomp>`   $    AAA41a!VAYYAAAr   c                 4    i | ]\  }}|t          |          S r)   r2   r4   s      r   r8   zGTrafficEmulatorTests.test_parse_ngrams_dns_included.<locals>.<dictcomp>a   $    IIIDAq1fQiiIIIr   )r   r	   open	TEST_FILEingest_summariescloselearnmaxDiffngramsitemsquery_detailsassertEqualr   saveseekload)r   r
   fconversationsintervalduration
dns_countsexpected_ngramsexpected_query_detailsrD   detailsmodel2s               r   test_parse_ngrams_dns_includedz3TrafficEmulatorTests.test_parse_ngrams_dns_included$   s4   $&&OO /iHHH								M"""===777&Z%.$9$5#6 E E E"+&)U#+*/7j$-;,7=
 
> > > :9934 <= !#t+"
 "
. @@5<+=+=+?+?@@@HHE,?,E,E,G,GHHH&111/999JJ

1%''	q			AAA6=+>+>+@+@AAAIIF,@,F,F,H,HIII&111/99999r   c           
         t          t                    }t          j        |g          \  }}}}|                                 | j                            ||           ddgdgdgddgdgdgdgdgdgd	}g d	d
gdgddgdgd}d| _        d | j        j        	                                D             }d | j        j
        	                                D             }	|                     ||           |                     ||	           t                      }| j                            |           t          j                    }
|                    d           |
                    |           d |
j        	                                D             }d |
j
        	                                D             }	|                     ||           |                     ||	           d S )Nr   r   r   r   r   r   r   )	r   )r   r   r   r   r    r!   r"   r#   r$   r%   r*   r+   r,   r-   r)   )r   r   r   r   r   r0   c                 4    i | ]\  }}|t          |          S r)   r2   r4   s      r   r8   z:TrafficEmulatorTests.test_parse_ngrams.<locals>.<dictcomp>   s$    EEE41a!VAYYEEEr   c                 4    i | ]\  }}|t          |          S r)   r2   r4   s      r   r8   z:TrafficEmulatorTests.test_parse_ngrams.<locals>.<dictcomp>   s$    MMMDAq1fQiiMMMr   r   c                 4    i | ]\  }}|t          |          S r)   r2   r4   s      r   r8   z:TrafficEmulatorTests.test_parse_ngrams.<locals>.<dictcomp>   r;   r   c                 4    i | ]\  }}|t          |          S r)   r2   r4   s      r   r8   z:TrafficEmulatorTests.test_parse_ngrams.<locals>.<dictcomp>   r=   r   )r>   r?   r   r@   rA   r
   rB   rC   rD   rE   rF   rG   r   rH   r	   rI   rJ   )r   rK   rL   rM   rN   rO   rP   rQ   rD   rR   rS   s              r   test_parse_ngramsz&TrafficEmulatorTests.test_parse_ngramse   s   OO /44								

333 #H-(k&Z%.$9$5#6&)U#+*/7j,7=

 

> > >  34 <= !#t)"
 "
, EE4:+<+B+B+D+DEEEMMDJ,D,J,J,L,LMMM&111/999JJ
%''	q			AAA6=+>+>+@+@AAAIIF,@,F,F,H,HIII&111/99999r   N)__name__
__module____qualname__r   r   rT   rZ   r)   r   r   r   r      sQ        , , ,  ?: ?: ?:B?: ?: ?: ?: ?:r   r   )
ior   samba.testssambasamba.emulater   r?   testsTestCaser   r)   r   r   <module>rd      s   &           ! ! ! ! ! ! 5	G: G: G: G: G:5;/ G: G: G: G: G:r   