Skip to content

Commit

Permalink
Restore authentication tests (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
eolivelli authored Dec 7, 2023
1 parent c2d0272 commit 9ad9667
Showing 1 changed file with 33 additions and 32 deletions.
65 changes: 33 additions & 32 deletions ragstack-e2e-tests/e2e_tests/test_astra.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from astrapy.db import AstraDB as LibAstraDB
import pytest
from httpx import ConnectError

from langchain.schema.embeddings import Embeddings
from langchain.schema.vectorstore import VectorStore
Expand Down Expand Up @@ -68,38 +69,38 @@ def test_ingest_errors(environment):
)


# def test_wrong_connection_parameters():
# # This is expected to be a valid endpoint, because we want to test an AUTHENTICATION error
# api_endpoint = get_required_env("ASTRA_PROD_DB_ENDPOINT")
#
# try:
# AstraDB(
# collection_name="something",
# embedding=init_embeddings(),
# token="xxxxx",
# # we assume that post 1234 is not open locally
# api_endpoint="https://locahost:1234",
# )
# pytest.fail("Should have thrown exception")
# except ConnectError as e:
# print("Error:", e)
# pass
#
# try:
# print("api_endpoint:", api_endpoint)
# AstraDB(
# collection_name="something",
# embedding=init_embeddings(),
# token="this-is-a-wrong-token",
# api_endpoint=api_endpoint,
# )
# pytest.fail("Should have thrown exception")
# except ValueError as e:
# print("Error:", e)
# if "AUTHENTICATION ERROR" not in e.args[0]:
# pytest.fail(
# f"Should have thrown ValueError with AUTHENTICATION ERROR but it was {e}"
# )
def test_wrong_connection_parameters():
# This is expected to be a valid endpoint, because we want to test an AUTHENTICATION error
api_endpoint = get_required_env("ASTRA_PROD_DB_ENDPOINT")

try:
AstraDB(
collection_name="something",
embedding=init_embeddings(),
token="xxxxx",
# we assume that post 1234 is not open locally
api_endpoint="https://locahost:1234",
)
pytest.fail("Should have thrown exception")
except ConnectError as e:
print("Error:", e)
pass

try:
print("api_endpoint:", api_endpoint)
AstraDB(
collection_name="something",
embedding=init_embeddings(),
token="this-is-a-wrong-token",
api_endpoint=api_endpoint,
)
pytest.fail("Should have thrown exception")
except ValueError as e:
print("Error:", e)
if "AUTHENTICATION ERROR" not in e.args[0]:
pytest.fail(
f"Should have thrown ValueError with AUTHENTICATION ERROR but it was {e}"
)


def test_basic_metadata_filtering(environment):
Expand Down

0 comments on commit 9ad9667

Please sign in to comment.