Skip to content

Commit

Permalink
tests: deserialized AWS signer for IAM auth fails
Browse files Browse the repository at this point in the history
  • Loading branch information
ArzelaAscoIi committed Aug 12, 2024
1 parent f03073f commit ccdde1f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions integrations/opensearch/tests/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest
from haystack_integrations.document_stores.opensearch.auth import AWSAuth
from opensearchpy import Urllib3AWSV4SignerAuth
from haystack.components.retrievers import SentenceWindowRetrieval


class TestAWSAuth:
Expand Down Expand Up @@ -111,3 +112,27 @@ def test_call(self, _get_urllib3_aws_v4_signer_auth_mock):
aws_auth = AWSAuth()
aws_auth(method="GET", url="http://some.url", body="some body")
signer_auth_mock.assert_called_once_with("GET", "http://some.url", "some body")

@patch("haystack_integrations.document_stores.opensearch.auth.AWSAuth._get_urllib3_aws_v4_signer_auth")
def test_sentence_window_retriever(self, _get_urllib3_aws_v4_signer_auth_mock, mock_boto3_session):
data = {
"init_parameters": {
"document_store": {
"init_parameters": {
"embedding_dim": 1024,
"hosts": ["${OPENSEARCH_HOST}:${OPENSEARCH_PORT}"],
"http_auth": {"type": "haystack_integrations.document_stores.opensearch.auth.AWSAuth"},
"index": "0a4680f5-f96c-4315-96a0-1c61373077ba-9b24e10f-d5b8-45d4-b844-d848ee3d3fa6-594cdce3-05eb-472a-9ab7-3493242ad463",
"similarity": "cosine",
"use_ssl": True,
"verify_certs": False,
},
"type": "haystack_integrations.document_stores.opensearch.document_store.OpenSearchDocumentStore",
},
"window_size": 5,
},
"type": "haystack.components.retrievers.sentence_window_retrieval.SentenceWindowRetrieval",
}
retriever = SentenceWindowRetrieval.from_dict(data)
assert hasattr(retriever.document_store, "_http_auth")
assert isinstance(retriever.document_store._http_auth, AWSAuth) # this fails for HS 2.3

0 comments on commit ccdde1f

Please sign in to comment.