
    ug&                     x   d dl mZmZmZ d dlmZ d dlZd dlm	Z	m
Z
mZ d dlmZ d dlmZmZ d dlmZ d dlmZmZmZ d dlmZ d	ed
dfdZ edej4                  ej6                  gd       e e        ej8                          e        ej:                               de
ee	f   dedee   de	d
df
d              Z y)    )givenPhasesettingsN)AnyDictOptional)	ServerAPI)SettingsSystem)api_executors)random_token_transport_headerrbac_test_confunauthorized_actions)_fastapi_fixtureapi_with_authn_rbac_authzreturnc                 F    | j                          | j                  d       y )Ntest_collection)resetcreate_collection)r   s    ^/var/www/openai/venv/lib/python3.12/site-packages/chromadb/test/auth/test_simple_rbac_authz.py%test_basic_authn_rbac_authz_unit_testr      s    ##%//0AB    
   )max_examplesphasesdeadline	rbac_confpersistenceheaderdatac                 B   | d   D ]   }|d   dk(  r y |j                  t        j                  dt        |d         dz
              }|d   |   }t	        |||dd	| d
   d| d
         }t        |      }|j                          |j                  t              }	|	j                          t        di t        |j                        }
| d   D cg c]  }|d   dk(  s| }}t        |      dk(  sJ |d   }|d   d   |
_        t        |
      }|j                  t              }|j                          | d   D cg c]  }|d   d   k(  s| }}t        |      dk(  sJ |d   }|d   D ],  }t!        |   |	||j                          |j#                          . t%        |d         D ]Z  }t'        j(                  t*              5 }t!        |   |	||j                          dt-        |      v sdt-        |      v sJ d d d        \  y c c}w c c}w # 1 sw Y   txY w)Nusersid__root__r   tokens   )	min_value	max_valuez1chromadb.auth.token_authn.TokenAuthClientProviderz;chromadb.auth.token_authn.TokenAuthenticationServerProviderfilenamez?chromadb.auth.simple_rbac_authz.SimpleRBACAuthorizationProvider)is_persistent"chroma_auth_token_transport_headerchroma_client_auth_credentialschroma_client_auth_providerchroma_server_authn_provider$chroma_server_authn_credentials_filechroma_server_authz_providerchroma_server_authz_config_filerolesroleactionsUnauthorized	Forbidden )drawstintegerslenr   nextreset_stateinstancer	   	heartbeatr
   dictr   r-   r   startr   r   r   pytestraises	Exceptionstr)r   r   r    r!   usertoken_indextokenapi_fixturesysapiroot_settings
root_users	root_usersystemroot_apirrole_matchesr4   actionunauthorized_actionexs                        r   test_token_authn_rbac_authzrW      s<   
 '":#iiKK!s4>/BQ/FG
 X{+&%/5+0)2*01::1F*.,5j,A
 ;'ll9% 64#56'0'9V'9tT$Z:=Ud'9
V:!###qM	7@7J17M4&??9-#,W#5Q#5a4DL9P#5Q< A%%%A9oF&!		
 NN & $8Y#Hy)R12II
 &R0K3r74JJJ *) $Ia #8 W R *)s$   HH<HH7HH)!
hypothesisr   r   r   hypothesis.strategies
strategiesr:   rC   typingr   r   r   chromadb.apir	   chromadb.configr
   r   &chromadb.test.auth.rbac_test_executorsr   chromadb.test.auth.strategiesr   r   r   chromadb.test.conftestr   r   generatetargetbooleansr!   rF   boolrW   r8   r   r   <module>re      s    - - "  & & " , @ 
 4CY CSW C
 
r5>>5<<"@4P~(E(GS:KCH~:K,0:K:B3-:KOR:K	:K T Q:Kr   