
    bM                         d dl Z d dlZd dlZd dlmZ dZ ej        d          Z G d de	          Z
 G d de
j                  Z G d	 d
e
j                  ZdS )    N)
get_stringzbin/net adsz^([^ 	:][^:]*):c                   B    e Zd ZdZ G d dej        j                  ZdS )BaseWrapperzw
    Guard the base so it doesn't inherit from TestCase. This prevents it from
    being run by unittest directly.
    c                   2     e Zd ZdZdZ fdZd Zd Z xZS ) BaseWrapper.NetAdsJSONTests_Basez@Blackbox tests for JSON output of the net ads suite of commands.Nc                 `    t          t          j        |                                            d S )N)superr   NetAdsJSONTests_BasesetUp)self	__class__s    B/usr/lib/python3/dist-packages/samba/tests/blackbox/netads_json.pyr   z&BaseWrapper.NetAdsJSONTests_Base.setUp&   s(    +2D99??AAAAA    c                    t           d| j        d}	 |                     |          }t          j        t          |                     dS # t          j        j        $ r&}| 	                    d|d|           Y d}~dS d}~ww xY w)z5The output of ``--json`` commands must parse as JSON.  --jsonError calling []: N)
COMMANDsubcmdcheck_outputjsonloadsr   sambatestsBlackboxProcessErrorfail)r   argvoutes       r   test_json_wellformedz5BaseWrapper.NetAdsJSONTests_Base.test_json_wellformed)   s    %,WWdkkk:D@''--
JsOO,,,,,;3 @ @ @			dddAA>?????????@s   6A B BBc                    t           d| j        }	 t          |                     |                    }n<# t          j        j        $ r%}|                     d|d|           Y d}~nd}~ww xY wt           d| j        d}	 |                     |          }n<# t          j        j        $ r%}|                     d|d|           Y d}~nd}~ww xY wt          j	        t          |                    }d |
                    d          D             D ]/}|                     |                    |          du           ||= 0|                     t          |          dk               dS )	z
            The ``--json`` variants must contain the same keys as their
            respective plain counterpart.

            Does not check nested dictionaries (e. g. the ``Flags`` value of
            ``net ads lookup``..
            r   r   r   Nr   c                     g | ]?}|d k    |d         dvt          j        t          |                              d          @S ) r   z 	:   )rematchPLAIN_KEY_REGEXgroup).0lines     r   
<listcomp>zOBaseWrapper.NetAdsJSONTests_Base.test_json_matching_entries.<locals>.<listcomp>H   sV     G G G!#rzzdAhf.D.D ?D99??BB.D.D.Dr   
r   )r   r   r   r   r   r   r   r   r   r   split
assertTruegetlen)r   r   	out_plainr    	out_jsobjparsedkeys          r   test_json_matching_entriesz;BaseWrapper.NetAdsJSONTests_Base.test_json_matching_entries2   s    &ggt{{3D@&t'8'8'>'>??		;3 @ @ @			dddAA>????????@ &-WWdkkk:D@ --d33		;3 @ @ @			dddAA>????????@ ZI!6!677FG G%.__d%;%;G G G ! ! S!1!1!=>>>CLLOOS&\\Q./////s-   "6 A/
A**A/B C/CC)	__name__
__module____qualname____doc__r   r   r!   r6   __classcell__)r   s   @r   r
   r   "   si        NN	B 	B 	B 	B 	B	@ 	@ 	@	0 	0 	0 	0 	0 	0 	0r   r
   N)r7   r8   r9   r:   r   r   BlackboxTestCaser
    r   r   r   r      sM         
,0 ,0 ,0 ,0 ,0u{; ,0 ,0 ,0 ,0 ,0r   r   c                       e Zd ZdZdS )NetAdsJSONInfoTestsinfoNr7   r8   r9   r   r=   r   r   r?   r?   P   s        FFFr   r?   c                       e Zd ZdZdS )NetAdsJSONlookupTestslookupNrA   r=   r   r   rC   rC   S   s        FFFr   rC   )r   r&   samba.testsr   samba.commonr   r   compiler(   objectr   r
   r?   rC   r=   r   r   <module>rI      s   $  				     # # # # # #"*01120 20 20 20 206 20 20 20h    +:       K<     r   