§
    ÐŠ¬j  ã                   ó    — d dl Zd dlmc mZ d dlZd dlmZ d dl	m
Z
 d dlmZ  G d„ dej        ¦  «        Zedk    r ej        ¦   «          dS dS )é    N)Ú
TestClient)Ú
create_app)Úget_current_userc                   ó�   — e Zd ZdZd„ Zd„ Zddedefd„Zd„ Zd	„ Z	d
„ Z
d„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ ZdS )ÚTestViewerSecurityRestrictionsu  
    Test suite verifying that users with 'viewer' role are strictly blocked (HTTP 403)
    from accessing internal confidential modules and mutating operations:
    - Debt Ledger (TK 131, TK 331, TK 211, TK 214)
    - Bank Statements & Balances (4 Bank Accounts, 943 Transactions)
    - State Treasury Dossiers (Kho Báº¡c NÄ� 254/2025/NÄ�-CP)
    - HR Timesheets & Payroll
    - 4 Pillars Financial Reconciliations & Quality Audits
    - Inventory Truth & Material Dispatches
    - CAD Drawing Takeoff Mutations & AI Training
    c                 ó^   — t          ¦   «         | _        t          | j        ¦  «        | _        d S ©N)r   Úappr   Úclient©Úselfs    ú=C:\Projects\DSCons\tests\test_viewer_security_restrictions.pyÚsetUpz$TestViewerSecurityRestrictions.setUp   s"   € Ý‘<”<ˆŒÝ  ¤Ñ*Ô*ˆŒˆˆó    c                 ó   — i | j         _        d S r	   )r
   Údependency_overridesr   s    r   ÚtearDownz'TestViewerSecurityRestrictions.tearDown   s   € Ø(*ˆŒÔ%Ð%Ð%r   útest@dscons.vnÚroleÚemailc                 ó:   ‡‡— ˆˆfd„| j         j        t          <   d S )Nc                  óF   •— d‰› d�‰ d‰                      ¦   «         › �‰ddœS )Nz
test-user-z-idzTest T)Úidr   Ú	full_namer   Ú	is_active)Útitle)r   r   s   €€r   ú<lambda>z:TestViewerSecurityRestrictions._set_user.<locals>.<lambda>   s;   ø€ Ø(˜tÐ(Ð(Ð(ØØ/ §¢¡¤Ð/Ð/ØØðC
ð C
€ r   )r
   r   r   )r   r   r   s    ``r   Ú	_set_userz(TestViewerSecurityRestrictions._set_user   s0   øø€ ð;
ð ;
ð ;
ð ;
ð ;
ˆŒÔ%Õ&6Ñ7Ð7Ð7r   c                 óš   — |                       d¦  «         | j                             d¦  «        }|                      |j        d¦  «         d S )NÚviewerú/v1/erp/finance/debt-ledgeré“  ©r   r   ÚgetÚassertEqualÚstatus_code©r   Úresponses     r   Ú$test_viewer_blocked_from_debt_ledgerzCTestViewerSecurityRestrictions.test_viewer_blocked_from_debt_ledger&   sG   € Ø�Š�xÑ Ô Ð Ø”;—?’?Ð#@ÑAÔAˆØ×Ò˜Ô-¨sÑ3Ô3Ð3Ð3Ð3r   c                 óš   — |                       d¦  «         | j                             d¦  «        }|                      |j        d¦  «         d S )NÚ
accountantr!   r"   ©r   r   r$   ÚassertNotEqualr&   r'   s     r   Ú#test_accountant_allowed_debt_ledgerzBTestViewerSecurityRestrictions.test_accountant_allowed_debt_ledger+   sG   € Ø�Š�|Ñ$Ô$Ð$Ø”;—?’?Ð#@ÑAÔAˆØ×Ò˜HÔ0°#Ñ6Ô6Ð6Ð6Ð6r   c                 óš   — |                       d¦  «         | j                             d¦  «        }|                      |j        d¦  «         d S )Nr    z!/v1/erp/finance/bank-transactionsr"   r#   r'   s     r   Ú*test_viewer_blocked_from_bank_transactionszITestViewerSecurityRestrictions.test_viewer_blocked_from_bank_transactions1   sG   € Ø�Š�xÑ Ô Ð Ø”;—?’?Ð#FÑGÔGˆØ×Ò˜Ô-¨sÑ3Ô3Ð3Ð3Ð3r   c                 óš   — |                       d¦  «         | j                             d¦  «        }|                      |j        d¦  «         d S )Nr    ú/v1/erp/finance/bank-summaryr"   r#   r'   s     r   Ú%test_viewer_blocked_from_bank_summaryzDTestViewerSecurityRestrictions.test_viewer_blocked_from_bank_summary6   sG   € Ø�Š�xÑ Ô Ð Ø”;—?’?Ð#AÑBÔBˆØ×Ò˜Ô-¨sÑ3Ô3Ð3Ð3Ð3r   c                 óš   — |                       d¦  «         | j                             d¦  «        }|                      |j        d¦  «         d S )Nr+   r2   r"   r,   r'   s     r   Ú$test_accountant_allowed_bank_summaryzCTestViewerSecurityRestrictions.test_accountant_allowed_bank_summary;   sG   € Ø�Š�|Ñ$Ô$Ð$Ø”;—?’?Ð#AÑBÔBˆØ×Ò˜HÔ0°#Ñ6Ô6Ð6Ð6Ð6r   c                 óš   — |                       d¦  «         | j                             d¦  «        }|                      |j        d¦  «         d S )Nr    ú/v1/erp/hr/timesheetsr"   r#   r'   s     r   Ú&test_viewer_blocked_from_hr_timesheetszETestViewerSecurityRestrictions.test_viewer_blocked_from_hr_timesheetsA   sG   € Ø�Š�xÑ Ô Ð Ø”;—?’?Ð#:Ñ;Ô;ˆØ×Ò˜Ô-¨sÑ3Ô3Ð3Ð3Ð3r   c                 óš   — |                       d¦  «         | j                             d¦  «        }|                      |j        d¦  «         d S )NÚdirectorr7   r"   r,   r'   s     r   Ú#test_director_allowed_hr_timesheetszBTestViewerSecurityRestrictions.test_director_allowed_hr_timesheetsF   sG   € Ø�Š�zÑ"Ô"Ð"Ø”;—?’?Ð#:Ñ;Ô;ˆØ×Ò˜HÔ0°#Ñ6Ô6Ð6Ð6Ð6r   c                 óš   — |                       d¦  «         | j                             d¦  «        }|                      |j        d¦  «         d S )Nr    ú/v1/erp/dossier/treasury/datar"   r#   r'   s     r   Ú)test_viewer_blocked_from_treasury_dossierzHTestViewerSecurityRestrictions.test_viewer_blocked_from_treasury_dossierL   sG   € Ø�Š�xÑ Ô Ð Ø”;—?’?Ð#BÑCÔCˆØ×Ò˜Ô-¨sÑ3Ô3Ð3Ð3Ð3r   c                 óš   — |                       d¦  «         | j                             d¦  «        }|                      |j        d¦  «         d S )NÚqsr=   r"   r,   r'   s     r   Ú test_qs_allowed_treasury_dossierz?TestViewerSecurityRestrictions.test_qs_allowed_treasury_dossierQ   sG   € Ø�Š�tÑÔÐØ”;—?’?Ð#BÑCÔCˆØ×Ò˜HÔ0°#Ñ6Ô6Ð6Ð6Ð6r   c                 óš   — |                       d¦  «         | j                             d¦  «        }|                      |j        d¦  «         d S )Nr    z-/v1/erp/inventory-truth/extract-from-invoicesr"   ©r   r   Úpostr%   r&   r'   s     r   Ú0test_viewer_blocked_from_inventory_truth_extractzOTestViewerSecurityRestrictions.test_viewer_blocked_from_inventory_truth_extractW   sI   € Ø�Š�xÑ Ô Ð Ø”;×#Ò#Ð$SÑTÔTˆØ×Ò˜Ô-¨sÑ3Ô3Ð3Ð3Ð3r   c                 ó¦   — |                       d¦  «         | j                             dddddœ¬¦  «        }|                      |j        d¦  «         d S )	Nr    z /v1/erp/inventory-truth/dispatchz	TEST-PROJu	   ThÃ©p D10éd   )Úproject_codeÚ	item_nameÚquantity)Újsonr"   rC   r'   s     r   Ú+test_viewer_blocked_from_inventory_dispatchzJTestViewerSecurityRestrictions.test_viewer_blocked_from_inventory_dispatch\   sg   € Ø�Š�xÑ Ô Ð Ø”;×#Ò#Ø.à +Ø(Øðð ð $ñ 
ô 
ˆð 	×Ò˜Ô-¨sÑ3Ô3Ð3Ð3Ð3r   c                 ó¢   — |                       d¦  «         | j                             dddi¬¦  «        }|                      |j        d¦  «         d S )Nr    z/v1/takeoff/uploadÚfile©ztest.pdfs   %PDF-1.4 dummyzapplication/pdf©Úfilesr"   rC   r'   s     r   Ú'test_viewer_blocked_from_takeoff_uploadzFTestViewerSecurityRestrictions.test_viewer_blocked_from_takeoff_uploadi   s]   € Ø�Š�xÑ Ô Ð Ø”;×#Ò#Ø ØÐMÐNð $ñ 
ô 
ˆð 	×Ò˜Ô-¨sÑ3Ô3Ð3Ð3Ð3r   c                 ó    — |                       d¦  «         | j                             ddg¬¦  «        }|                      |j        d¦  «         d S )Nr    z/v1/takeoff/upload-batch)rQ   rO   rP   r"   rC   r'   s     r   Ú-test_viewer_blocked_from_takeoff_batch_uploadzLTestViewerSecurityRestrictions.test_viewer_blocked_from_takeoff_batch_uploadq   sZ   € Ø�Š�xÑ Ô Ð Ø”;×#Ò#Ø&ØPÐQð $ñ 
ô 
ˆð 	×Ò˜Ô-¨sÑ3Ô3Ð3Ð3Ð3r   c                 óš   — |                       d¦  «         | j                             d¦  «        }|                      |j        d¦  «         d S )Nr    z#/v1/pillars/epc/3-way-match/PROJ-01r"   r#   r'   s     r   Ú0test_viewer_blocked_from_four_pillars_3way_matchzOTestViewerSecurityRestrictions.test_viewer_blocked_from_four_pillars_3way_matchz   sG   € Ø�Š�xÑ Ô Ð Ø”;—?’?Ð#HÑIÔIˆØ×Ò˜Ô-¨sÑ3Ô3Ð3Ð3Ð3r   c                 óš   — |                       d¦  «         | j                             d¦  «        }|                      |j        d¦  «         d S )Nr    z&/v1/pillars/equipment/rental-reconciler"   r#   r'   s     r   Ú@test_viewer_blocked_from_four_pillars_equipment_rental_reconcilez_TestViewerSecurityRestrictions.test_viewer_blocked_from_four_pillars_equipment_rental_reconcile   sG   € Ø�Š�xÑ Ô Ð Ø”;—?’?Ð#KÑLÔLˆØ×Ò˜Ô-¨sÑ3Ô3Ð3Ð3Ð3r   c                 óš   — |                       d¦  «         | j                             d¦  «        }|                      |j        d¦  «         d S )Nr    z0/v1/pillars/logistics/sludge-transport/reconciler"   r#   r'   s     r   Ú@test_viewer_blocked_from_four_pillars_sludge_transport_reconcilez_TestViewerSecurityRestrictions.test_viewer_blocked_from_four_pillars_sludge_transport_reconcile„   sG   € Ø�Š�xÑ Ô Ð Ø”;—?’?Ð#UÑVÔVˆØ×Ò˜Ô-¨sÑ3Ô3Ð3Ð3Ð3r   N)r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ústrr   r)   r.   r0   r3   r5   r8   r;   r>   rA   rE   rL   rR   rT   rV   rX   rZ   © r   r   r   r      sS  € € € € € ð
ð 
ð+ð +ð +ð+ð +ð +ð
ð 
˜cð 
¨#ð 
ð 
ð 
ð 
ð4ð 4ð 4ð
7ð 7ð 7ð4ð 4ð 4ð
4ð 4ð 4ð
7ð 7ð 7ð4ð 4ð 4ð
7ð 7ð 7ð4ð 4ð 4ð
7ð 7ð 7ð4ð 4ð 4ð

4ð 
4ð 
4ð4ð 4ð 4ð4ð 4ð 4ð4ð 4ð 4ð
4ð 4ð 4ð
4ð 4ð 4ð 4ð 4r   r   Ú__main__)ÚbuiltinsÚ@py_builtinsÚ_pytest.assertion.rewriteÚ	assertionÚrewriteÚ
@pytest_arÚunittestÚfastapi.testclientr   Úapp.mainr   Ú"app.modules.auth.presentation.authr   ÚTestCaser   r[   Úmainr`   r   r   ú<module>rn      sº   ðØ  € € € € € € € € € € € € €€€€Ø )Ð )Ð )Ð )Ð )Ð )à Ð Ð Ð Ð Ð Ø ?Ð ?Ð ?Ð ?Ð ?Ð ?ð4ð 4ð 4ð 4ð 4 XÔ%6ñ 4ô 4ð 4ðD ˆzÒÐØ€H„M�O„O€O€O€Oð Ðr   