a
    cl_                     @   s<   d Z ddlmZmZmZmZ ddlZG dd dejj	Z
dS )zDTests for integer handling in PIDL generated bindings samba.dcerpc.*    )	server_idmiscsrvsvcsamrNc                   @   s$  e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: Zd;d< Z d=d> Z!d?d@ Z"dAdB Z#dCdD Z$dEdF Z%dGS )HIntegerTestsc                 C   s"   t   }t j|_| |jd d S Nl    )r   NONCLUSTER_VNN	unique_idassertEqualselfs r   </usr/lib/python3/dist-packages/samba/tests/dcerpc/integer.pytest_uint32_into_hyper   s    z#IntegerTests.test_uint32_into_hyperc                 C   s    t   }d|_| |jd d S )N   )r   r	   r
   r   r   r   r   test_int_into_hyper   s    z IntegerTests.test_int_into_hyperc                    s$   t     fdd}| t| d S )Nc                      s
   d _ d S N)r	   r   r   r   r   assign'   s    z9IntegerTests.test_negative_int_into_hyper.<locals>.assignr   assertRaisesOverflowErrorr   r   r   r   r   test_negative_int_into_hyper$   s    z)IntegerTests.test_negative_int_into_hyperc                    s$   t     fdd}| t| d S )Nc                      s   t j _d S N)r    SERVERID_UNIQUE_ID_NOT_TO_VERIFYvnnr   r   r   r   r   .   s    z3IntegerTests.test_hyper_into_uint32.<locals>.assignr   r   r   r   r   test_hyper_into_uint32+   s    z#IntegerTests.test_hyper_into_uint32c                    s$   t    fdd}| t| d S )Nc                      s   t j _d S r   )r   r   timezoner   r   r   r   r   5   s    z2IntegerTests.test_hyper_into_int32.<locals>.assignr   NetRemoteTODInfor   r   r   r   r   r   test_hyper_into_int322   s    z"IntegerTests.test_hyper_into_int32c                 C   s    t  }d|_| |jd d S N   r   r"   r    r
   r   r   r   r   test_int_into_int329   s    z IntegerTests.test_int_into_int32c                    s$   t    fdd}| t| d S )Nc                      s   t j _d S r   )r   r   r    r   r   r   r   r   A   s    z3IntegerTests.test_uint32_into_int32.<locals>.assignr!   r   r   r   r   test_uint32_into_int32>   s    z#IntegerTests.test_uint32_into_int32c                 C   s    t  }d|_| |jd d S r$   r&   r   r   r   r   test_long_into_int32E   s    z!IntegerTests.test_long_into_int32c                    s$   t    fdd}| t| d S )Nc                      s
   d _ d S )Nl        r    r   r   r   r   r   S   s    z<IntegerTests.test_larger_long_int_into_int32.<locals>.assignr!   r   r   r   r   test_larger_long_int_into_int32P   s    z,IntegerTests.test_larger_long_int_into_int32c                 C   s    t  }d|_| |jd d S )Nir&   r   r   r   r   test_larger_int_into_int32W   s    z'IntegerTests.test_larger_int_into_int32c                    s$   t    fdd}| t| d S )Nc                      s
   d _ d S )Ng      @r*   r   r   r   r   r   _   s    z2IntegerTests.test_float_into_int32.<locals>.assignr   r"   r   	TypeErrorr   r   r   r   test_float_into_int32\   s    z"IntegerTests.test_float_into_int32c                    s$   t    fdd}| t| d S )Nc                      s
   d _ d S )Ng       @r*   r   r   r   r   r   f   s    z6IntegerTests.test_int_float_into_int32.<locals>.assignr-   r   r   r   r   test_int_float_into_int32c   s    z&IntegerTests.test_int_float_into_int32c                 C   s    t  }d|_| |jd d S )Ni   r&   r   r   r   r   test_negative_int_into_int32j   s    z)IntegerTests.test_negative_int_into_int32c                    s$   t     fdd}| t| d S )Nc                      s
   d _ d S r   )r   r   r   r   r   r   r   s    z6IntegerTests.test_negative_into_uint32.<locals>.assignr   r   r   r   r   test_negative_into_uint32o   s    z&IntegerTests.test_negative_into_uint32c                    s$   t    fdd}| t| d S )Nc                      s   t j _d S r   )r   r   time_midr   gr   r   r   y   s    z3IntegerTests.test_hyper_into_uint16.<locals>.assignr   GUIDr   r   r   r   r4   r   test_hyper_into_uint16v   s    z#IntegerTests.test_hyper_into_uint16c                    s$   t    fdd}| t| d S )Nc                      s
   d _ d S )Ni@ r3   r   r4   r   r   r      s    z1IntegerTests.test_int_into_uint16.<locals>.assignr6   r   r   r4   r   test_int_into_uint16}   s    z!IntegerTests.test_int_into_uint16c                    s$   t    fdd}| t| d S )Nc                      s
   d _ d S )Nr9   r   r4   r   r   r      s    z:IntegerTests.test_negative_int_into_uint16.<locals>.assignr6   r   r   r4   r   test_negative_int_into_uint16   s    z*IntegerTests.test_negative_int_into_uint16c                 C   s$   t  }t j|_| |jt j d S r   )r   r7   ZSEC_CHAN_DOMAINr3   r
   r   r5   r   r   r   test_enum_into_uint16   s    z"IntegerTests.test_enum_into_uint16c                 C   s$   t  }t j|_| |jt j d S r   )r   r7   ZSV_TYPE_WFWr3   r
   r=   r   r   r   test_bitmap_into_uint16   s    z$IntegerTests.test_bitmap_into_uint16c                    s$   t    fdd}| t| d S )Nc                      s   t j _d S r   )r   ZSV_TYPE_LOCAL_LIST_ONLYr3   r   r4   r   r   r      s    z=IntegerTests.test_overflow_bitmap_into_uint16.<locals>.assignr6   r   r   r4   r    test_overflow_bitmap_into_uint16   s    z-IntegerTests.test_overflow_bitmap_into_uint16c                    s$   t    fdd}| t| d S )Nc                      s   t j _d S r   )r   ZSV_TYPE_DOMAIN_ENUMr3   r   r4   r   r   r      s    z?IntegerTests.test_overflow_bitmap_into_uint16_2.<locals>.assignr6   r   r   r4   r   "test_overflow_bitmap_into_uint16_2   s    z/IntegerTests.test_overflow_bitmap_into_uint16_2c                    s$   t    fdd}| t| d S )Nc                      s   t j _d S r   )r   r   max_password_ager   r   r   r   r      s    z2IntegerTests.test_hyper_into_int64.<locals>.assign)r   DomInfo1r   r   r   r   r   r   test_hyper_into_int64   s    z"IntegerTests.test_hyper_into_int64c                 C   s    t  }d|_| |jd d S r$   r   rC   rB   r
   r   r   r   r   test_int_into_int64   s    z IntegerTests.test_int_into_int64c                 C   s    t  }d|_| |jd d S )NrE   r   r   r   r   test_negative_int_into_int64   s    z)IntegerTests.test_negative_int_into_int64c                 C   s"   t  }tj|_| |jd d S r   )r   rC   r   r   rB   r
   r   r   r   r   test_larger_int_into_int64   s    z'IntegerTests.test_larger_int_into_int64c                 C   s    t  }d|_| |jd d S )Nl    rE   r   r   r   r   #test_larger_negative_int_into_int64   s    z0IntegerTests.test_larger_negative_int_into_int64c                 C   s(   t  }g d|_| |jd d d S N)r%   r   r%   r         r   r%   r   r7   noder
   r=   r   r   r   test_int_list_over_list   s    
z$IntegerTests.test_int_list_over_listc                 C   s(   t  }g d|_| |jd d d S rK   rN   r=   r   r   r   "test_long_int_list_over_uint8_list   s    
z/IntegerTests.test_long_int_list_over_uint8_listc                    s$   t    fdd}| t| d S )Nc                      s   g d _ d S )N)r   r   r%   r   rL   rM   rO   r   r4   r   r   r      s    z?IntegerTests.test_negative_list_over_uint8_list.<locals>.assignr6   r   r   r4   r   "test_negative_list_over_uint8_list   s    z/IntegerTests.test_negative_list_over_uint8_listc                    s$   t    fdd}| t| d S )Nc                      s   g d _ d S )N)   r   r%   r   rL   rM   rR   r   r4   r   r   r      s    z?IntegerTests.test_overflow_list_over_uint8_list.<locals>.assignr6   r   r   r4   r   "test_overflow_list_over_uint8_list   s    z/IntegerTests.test_overflow_list_over_uint8_listc                    s$   t    fdd}| t| d S )Nc                      s   g d _ d S )N)r%   r   r%   rR   r   r4   r   r   r      s    z<IntegerTests.test_short_list_over_uint8_list.<locals>.assignr   r7   r   r.   r   r   r4   r   test_short_list_over_uint8_list   s    z,IntegerTests.test_short_list_over_uint8_listc                    s$   t    fdd}| t| d S )Nc                      s   g d _ d S )N)r%   r   r%      rX   rX   rX   rX   rR   r   r4   r   r   r      s    z;IntegerTests.test_long_list_over_uint8_list.<locals>.assignrV   r   r   r4   r   test_long_list_over_uint8_list   s    z+IntegerTests.test_long_list_over_uint8_listc                 C   s(   t  }d|jd< | |jd d d S )Nr%   r   rN   r=   r   r   r   test_assign_into_uint8_list   s    
z(IntegerTests.test_assign_into_uint8_listc                    s$   t    fdd}| t| d S )Nc                      s   d j d< d S )Nr   r   rR   r   r4   r   r   r      s    z:IntegerTests.test_negative_into_uint8_list.<locals>.assignr6   r   r   r4   r   test_negative_into_uint8_list   s    z*IntegerTests.test_negative_into_uint8_listc                    s$   t    fdd}| t| d S )Nc                      s   d j d< d S )NrT   r   rR   r   r4   r   r   r      s    z:IntegerTests.test_overflow_into_uint8_list.<locals>.assignr6   r   r   r4   r   test_overflow_into_uint8_list   s    z*IntegerTests.test_overflow_into_uint8_listN)&__name__
__module____qualname__r   r   r   r   r#   r'   r(   r)   r+   r,   r/   r0   r1   r2   r8   r:   r<   r>   r?   r@   rA   rD   rF   rH   rI   rJ   rP   rQ   rS   rU   rW   rY   rZ   r[   r\   r   r   r   r   r      sF   r   )__doc__Zsamba.dcerpcr   r   r   r   Zsamba.testsZsambaZtestsZTestCaser   r   r   r   r   <module>   s   