mirror of
https://github.com/placeholder-soft/chroma.git
synced 2026-01-12 22:44:55 +08:00
Refs: #1083 ## Description of changes *Summarize the changes made by this PR.* - New functionality - JS Client now supports Authorization, and X-Chroma-Token auths supported - Tests and integration tests updated ## Test plan *How are these changes tested?* - [x] Tests pass locally `yarn test` for js ## Documentation Changes TBD
72 lines
2.0 KiB
Bash
Executable File
72 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
export CHROMA_PORT=8000
|
|
|
|
function cleanup {
|
|
docker compose -f docker-compose.test.yml down --rmi local --volumes
|
|
rm server.htpasswd .chroma_env
|
|
}
|
|
|
|
function setup_auth {
|
|
local auth_type="$1"
|
|
case "$auth_type" in
|
|
basic)
|
|
docker run --rm --entrypoint htpasswd httpd:2 -Bbn admin admin > server.htpasswd
|
|
cat <<EOF > .chroma_env
|
|
CHROMA_SERVER_AUTH_CREDENTIALS_FILE="/chroma/server.htpasswd"
|
|
CHROMA_SERVER_AUTH_CREDENTIALS_PROVIDER="chromadb.auth.providers.HtpasswdFileServerAuthCredentialsProvider"
|
|
CHROMA_SERVER_AUTH_PROVIDER="chromadb.auth.basic.BasicAuthServerProvider"
|
|
EOF
|
|
;;
|
|
token)
|
|
cat <<EOF > .chroma_env
|
|
CHROMA_SERVER_AUTH_CREDENTIALS="test-token"
|
|
CHROMA_SERVER_AUTH_TOKEN_TRANSPORT_HEADER="AUTHORIZATION"
|
|
CHROMA_SERVER_AUTH_CREDENTIALS_PROVIDER="chromadb.auth.token.TokenConfigServerAuthCredentialsProvider"
|
|
CHROMA_SERVER_AUTH_PROVIDER="chromadb.auth.token.TokenAuthServerProvider"
|
|
EOF
|
|
;;
|
|
xtoken)
|
|
cat <<EOF > .chroma_env
|
|
CHROMA_SERVER_AUTH_CREDENTIALS="test-token"
|
|
CHROMA_SERVER_AUTH_TOKEN_TRANSPORT_HEADER="X_CHROMA_TOKEN"
|
|
CHROMA_SERVER_AUTH_CREDENTIALS_PROVIDER="chromadb.auth.token.TokenConfigServerAuthCredentialsProvider"
|
|
CHROMA_SERVER_AUTH_PROVIDER="chromadb.auth.token.TokenAuthServerProvider"
|
|
EOF
|
|
;;
|
|
*)
|
|
echo "Unknown auth type: $auth_type"
|
|
exit 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
docker compose -f docker-compose.test.yml up --build -d
|
|
|
|
export CHROMA_INTEGRATION_TEST_ONLY=1
|
|
export CHROMA_API_IMPL=chromadb.api.fastapi.FastAPI
|
|
export CHROMA_SERVER_HOST=localhost
|
|
export CHROMA_SERVER_HTTP_PORT=8000
|
|
#
|
|
#echo testing: python -m pytest "$@"
|
|
#python -m pytest "$@"
|
|
|
|
cd clients/js
|
|
yarn
|
|
yarn test:run
|
|
docker compose down
|
|
cd ../..
|
|
for auth_type in basic token xtoken; do
|
|
echo "Testing $auth_type auth"
|
|
setup_auth "$auth_type"
|
|
cd clients/js
|
|
docker compose --env-file ../../.chroma_env -f ../../docker-compose.test-auth.yml up --build -d
|
|
yarn test:run-auth-"$auth_type"
|
|
cd ../..
|
|
docker compose down
|
|
done
|