
    ug
                        d dl mZmZ d dlmZmZ d dlm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mZmZ  ed	       e e        e        ej(                               d
eeef   dededdfd              Z ed	       e e        e        e        ej(                               d
eeef   dedededdf
d              Zy)    )givensettings)AnyDictN)	ServerAPI)System)_fastapi_fixture)random_tokenrandom_token_transport_headertoken_test_conf
   )max_examplestconftransport_headerpersistencereturnc           
          | d   D ]u  }|d   D ]k  }t        ||d| d   d|      }t        |      }|j                          |j                  t              }|j                          |j                         g k(  rkJ  w y )Nuserstokens;chromadb.auth.token_authn.TokenAuthenticationServerProviderfilename1chromadb.auth.token_authn.TokenAuthClientProvideris_persistent"chroma_auth_token_transport_headerchroma_server_authn_provider$chroma_server_authn_credentials_filechroma_client_auth_providerchroma_client_auth_credentials)r	   nextreset_stateinstancer   	heartbeatlist_collections)r   r   r   usertokenapi_sys_apis           X/var/www/openai/venv/lib/python3.12/site-packages/chromadb/test/auth/test_token_authn.py;test_fastapi_server_token_authn_allows_when_it_should_allowr+      s    
 g(^E")3C-j5::5F,_/4C  9D==+DNN((*b000 $     unauthorized_tokenc           
         | d   D ]  }|d   D ]
  }||k(  s	  y   | d   D ]  }|d   D ]  }t        ||d| d   d|      }t        |      }|j                          |j                  t              }|j                          t        j                  t              5 }	|j                          d d d        dt        	      v rJ   y # 1 sw Y   xY w)Nr   r   r   r   r   r   	Forbidden)r	   r    r!   r"   r   r#   pytestraises	Exceptionr$   str)
r   r-   r   r   r%   tr)   r(   r'   es
             r*   =test_fastapi_server_token_authn_rejects_when_it_should_rejectr6   '   s     ghA&&   
 ghA#)3C-j5::5F,_/AD  :D--	*CMMOy)Q$$& * #a&(((!    *)s   CC)
hypothesisr   r   typingr   r   hypothesis.strategies
strategiesstr0   chromadb.apir   chromadb.configr   chromadb.test.conftestr	   chromadb.test.auth.strategiesr
   r   r   booleansr3   boolr+   r6    r,   r*   <module>rC      s    &  "  " " 3  
r79;2;;=I1S>1-01?C1	1 J 1( 
r|~'D'F)S>)) ) 	)
 
) )r,   