a
    ¡Öa-  ã                   @   s8   d dl mZ d dlmZ d dlmZ G dd„ deƒZdS )é    )Úprint_function)ÚSmbCaclsBlockboxTestBase)ÚBlackboxProcessErrorc                       s<   e Zd Z‡ fdd„Zdd„ Zdd„ Zdd„ Zd	d
„ Z‡  ZS )ÚBasicSmbCaclsTestsc                    s   t t| ƒ ¡  d S )N)Úsuperr   ÚsetUp)Úself©Ú	__class__© úE/usr/lib/python3/dist-packages/samba/tests/blackbox/smbcacls_basic.pyr      s    zBasicSmbCaclsTests.setUpc              
   C   sÎ   d}z|   |¡}W n2 tyD } z|  t|ƒ¡ W Y d}~n
d}~0 0 d| j }d| j| j|| j| j|f }z|  |¡}W n2 ty¬ } z|  t|ƒ¡ W Y d}~n
d}~0 0 |  	|¡}|  
|  ||¡¡ dS )zÛtest smbcacls '--set' attempts to overwrite the ACL for the file

        before:

        +-test_dir/
          +-file.1            (I)(F)

        after/expected:

        +-test_dir/
          +-file.1            (F)úfile-1NúACL:%s:ALLOWED/0x0/FULLz)bin/smbcacls -U%s%%%s --set %s //%s/%s %s)Úcreate_remote_test_filer   ÚfailÚstrÚuserZpasswdZserverZshareZcheck_outputÚace_parse_strÚ
assertTrueÚfile_ace_check)r   Zfile1ÚfilepathÚeZaclZcommandÚresultÚacer   r   r   Útest_simple_single_set   s    $
$
z)BasicSmbCaclsTests.test_simple_single_setc              
   C   s²   d| j  }zp|  d¡}|  d||g¡ |  |¡}|  |  ||¡¡ d| j  }|  d||g¡ |  |¡}|  |  ||¡¡ W n2 ty¬ } z|  t|ƒ¡ W Y d}~n
d}~0 0 dS )a)  test smbcacls '--modify' attempts to modify the ACL for the file
        (note: first part of the test 'set' ACL to (F) then attempts to modify
        before:

        +-test_dir/
          +-file.1            (F)

        after/expected:

        +-test_dir/
          +-file.1            (READ)r   r   ú--setzACL:%s:ALLOWED/0x0/READz--modifyN©	r   r   Ú	smb_caclsr   r   r   r   r   r   ©r   Úacl_strÚ
remotepathr   r   r   r   r   Útest_simple_single_mod9   s    




z)BasicSmbCaclsTests.test_simple_single_modc              
   C   sŽ   d| j  }zL|  d¡}|  |¡}|  |  ||¡¡ |  d||g¡ |  |  ||¡¡ W n2 tyˆ } z|  t	|ƒ¡ W Y d}~n
d}~0 0 dS )aT  test smbcacls '--delete' attempts to delete the ACL for the file
        (note: first part of the test 'set' ACL to (F) then attempts to delete
        before:

        +-tar_test_dir/
          +-file.1            (F)

        after/expected:

        +-tar_test_dir/
          +-file.1            (none) - meaning no (F) ACL for this userr   r   z--deleteN)
r   r   r   r   r   r   ZassertFalser   r   r   r   r   r   r   Útest_simple_single_delY   s    


z)BasicSmbCaclsTests.test_simple_single_delc              
   C   s²   d| j  }d| j  }zf|  d¡}|  d||g¡ |  |¡}|  |  ||¡¡ |  d||g¡ |  |¡}|  |  ||¡¡ W n2 ty¬ } z|  t|ƒ¡ W Y d }~n
d }~0 0 d S )Nr   zACL:%s:DENIED/0x0/READr   r   r   )r   r   Zdny_strr    r   r   r   r   r   Útest_simple_single_addu   s    




z)BasicSmbCaclsTests.test_simple_single_add)	Ú__name__Ú
__module__Ú__qualname__r   r   r!   r"   r#   Ú__classcell__r   r   r	   r   r      s
    r   N)Z
__future__r   Zsamba.tests.blackbox.smbcaclsr   Zsamba.testsr   r   r   r   r   r   Ú<module>   s   