
    IR-eY                         d Z ddlZddlmZmZ ddlZddlmZmZm	Z	 ddl
mZmZ ddlmZ ddlmZ dd	lmZmZ d
 Z G d de          ZdS )z
Test the web profile using Python classes that have been adapted to act like a
web client. We can only put a single test here because only one hub can run
with the web profile active, and the user might want to run the tests in
parallel.
    N)Requesturlopen)SAMPHubServerSAMPIntegratedClientconf)CLIENT_ACCESS_POLICYCROSS_DOMAIN)get_readable_fileobj   )TestStandardProfile)AlwaysApproveWebProfileDialogSAMPIntegratedWebClientc                     dt           _        d S )NF)r   use_internet)modules    Clib/python3.11/site-packages/astropy/samp/tests/test_web_profile.pysetup_moduler      s    D    c                   N    e Zd Z ej        d          d             Zd Zd ZdS )TestWebProfileT)autousec                    t                      | _        t          j        | j        j                  }|                                 t          |          | _        t          |dz            }t          | j        |dd          | _	        | j	                                         t                      | _        | j                            | j	        d           | j                                        | _        | j                                        | _        t#                      | _        | j                            | j	        j        d           | j                                        | _        | j                                        | _        d S )	N)targetz.sampr   r   )web_profile_dialoglockfileweb_port	pool_size)hubr      )r   r   )r   dialog	threadingThreadpollstartstrtmpdirr   r   r   client1connectget_public_id
client1_idget_private_keyclient1_keyr   client2	_web_port
client2_idclient2_key)selftmp_pathtr   s       r   setup_methodzTestWebProfile.setup_method   s<   355DK$4555				(mmx')** #{XUV
 
 
 	+--Q777,4466<7799.00dh&8AFFF,4466<7799r   c                     | j         j        r| j                                          | j        j        r| j                                         | j                                         | j                                         d S )N)r'   is_connected
disconnectr-   r   stopr    )r1   s    r   teardown_methodzTestWebProfile.teardown_method4   sm    <$ 	&L##%%%<$ 	&L##%%%r   c                    t          d| j        j         d          5 }|                                t          k    sJ 	 d d d            n# 1 swxY w Y   t          d| j        j         d          5 }|                                t
          k    sJ 	 d d d            n# 1 swxY w Y   t          d| j        j         d          }|                    dd           t          |          }|	                    d          dk    sJ |	                    d          dk    sJ |	                    d	          d
k    sJ d S )Nzhttp://localhost:z/crossdomain.xmlz/clientaccesspolicy.xmlOrigintest_web_profilezAccess-Control-Allow-OriginzAccess-Control-Allow-HeaderszContent-Typez Access-Control-Allow-Credentialstrue)
r
   r   r.   readr	   r   r   
add_headerr   	getheader)r1   freqresps       r   r<   zTestWebProfile.test_web_profile@   s    "D 2DDD
 
 	,6688|+++++	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,
 "K 2KKK
 
 	46688333333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 N$(*<NNNOOx!3444s||~~;<<@RRRRR~~<==OOOO~~@AAVKKKKKKs#    AAA3 B  B$'B$N)__name__
__module____qualname__pytestfixturer4   r9   r<    r   r   r   r      s`        V^D!!!: : "!:.  L L L L Lr   r   )__doc__r!   urllib.requestr   r   rG   astropy.sampr   r   r   astropy.samp.web_profiler   r	   astropy.utils.datar
   test_standard_profiler   BaseTestStandardProfileweb_profile_test_helpersr   r   r   r   rI   r   r   <module>rR      s        + + + + + + + +  B B B B B B B B B B G G G G G G G G 3 3 3 3 3 3 Q Q Q Q Q Q         :L :L :L :L :L, :L :L :L :L :Lr   