
    b                         d Z ddlZddlZddlZddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZ  G d	 d
e          ZdS )zySmoke test for encrypted secrets

A quick test to confirm that the secret attributes are being stored
encrypted on disk.
    N)TestCase)Credentials)SamDB)system_session)
ndr_unpack)drsblobsc                   *     e Zd Z fdZd Zd Z xZS )EncryptedSecretsTestsc                    t          t          |                                            t          j                                        | _        t                      | _        t                      | _
        | j                            | j                   t                      | _
        t          | j
        | j        | j                  | _        d S )N)session_infocredentialslp)superr
   setUpsambatestsenv_loadparmr   r   credsr   sessionguessr   ldb)self	__class__s    ?/usr/lib/python3/dist-packages/samba/tests/encrypted_secrets.pyr   zEncryptedSecretsTests.setUp'   s    #T**00222+**,, ]]
%''
!!!%''dl%)Z G% % %    c                    | j                                         }d|                                z  }t          j                            d|          }| j                            |          }t          j        d|z   t           j	                  }d|z  }|
                    t           j        |dg          }|                     dt          |          d	k               |d	         }|d         d	         }	|                     t          |	          d
k               t          t           j        |	          }
d}|                     ||
j        j                   dS )z8Test that secret attributes are stored encrypted on diskz%s.ldbz	sam.ldb.dzldb://)flagszCN=Administrator,CN=Users,%s
unicodePwdscopebaseattrsTr      l   - N)r   	domain_dnupperospathjoinr   private_pathLdbFLG_DONT_CREATE_DBsearch
SCOPE_BASEassertIslen
assertTruer   r   EncryptedSecretassertEqualheadermagic)r   basednbackend_filenamebackend_subpathbackend_path	backenddbdnresobjblob	encryptedr4   s               r   test_encrypted_secretsz,EncryptedSecretsTests.test_encrypted_secrets2   s0   ##%%#fllnn4',,{'79 9w++O<<GH|33;QRRR	+f4S^$&&2^  5 5 	dCHHqL)))!f< #D		B'''x7>>		 0 677777r   c                 &   | j                             t           j        ddg          }|                     t	          |          dk               |                     d|d         v            |d         d         }|                     d|v            dS )zcTest that databases are provisioned with encryptedSecrets as a
           required feature
        z@SAMBA_DSDBrequiredFeaturesr   r   s   encryptedSecretsN)r   r,   r-   r0   r/   )r   r;   required_featuress      r   test_required_featuresz,EncryptedSecretsTests.test_required_featuresI   s     hooCN#0%7$8  : : 	C1%%%*c!f4555F#56+/@@AAAAAr   )__name__
__module____qualname__r   r?   rC   __classcell__)r   s   @r   r
   r
   %   s]        	% 	% 	% 	% 	%8 8 8.
B 
B 
B 
B 
B 
B 
Br   r
   )__doc__r&   r   r   samba.testsr   samba.credentialsr   samba.samdbr   
samba.authr   	samba.ndrr   samba.dcerpcr   r
    r   r   <module>rP      s   &  
			 



              ) ) ) ) ) )       % % % % % %             ! ! ! ! ! !.B .B .B .B .BH .B .B .B .B .Br   