Fix AuthorizationException with AWSV4SignerAsyncAuth when the doc ID has special characters. (#848)
* Lifecycle integration tests. Signed-off-by: dblock <[email protected]> * Added a test that makes sure the slash is properly encoded. Signed-off-by: dblock <[email protected]> * Added more tests for signer and _make_path. Signed-off-by: Nathalie Jonathan <[email protected]> * Prevent AIOHttpConnection from encoding the url a second time. Signed-off-by: Nathalie Jonathan <[email protected]> --------- Signed-off-by: dblock <[email protected]> Signed-off-by: Nathalie Jonathan <[email protected]> Co-authored-by: dblock <[email protected]>
This commit is contained in:
@@ -25,10 +25,72 @@
|
||||
# under the License.
|
||||
|
||||
|
||||
import pytest
|
||||
|
||||
from opensearchpy.exceptions import RequestError
|
||||
|
||||
from . import OpenSearchTestCase
|
||||
|
||||
|
||||
class TestSpecialCharacters(OpenSearchTestCase):
|
||||
def test_index_with_slash(self) -> None:
|
||||
index_name = "movies/shmovies"
|
||||
with pytest.raises(RequestError) as e:
|
||||
self.client.indices.create(index=index_name)
|
||||
self.assertEqual(
|
||||
str(e.value),
|
||||
"RequestError(400, 'invalid_index_name_exception', 'Invalid index name [movies/shmovies], must not contain the following characters [ , \", *, \\\\, <, |, ,, >, /, ?]')",
|
||||
)
|
||||
|
||||
|
||||
class TestUnicode(OpenSearchTestCase):
|
||||
def test_indices_lifecycle_english(self) -> None:
|
||||
index_name = "movies"
|
||||
|
||||
index_create_result = self.client.indices.create(index=index_name)
|
||||
self.assertTrue(index_create_result["acknowledged"])
|
||||
self.assertEqual(index_name, index_create_result["index"])
|
||||
|
||||
document = {"name": "Solaris", "director": "Andrei Tartakovsky", "year": "2011"}
|
||||
id = "solaris@2011"
|
||||
doc_insert_result = self.client.index(
|
||||
index=index_name, body=document, id=id, refresh=True
|
||||
)
|
||||
self.assertEqual("created", doc_insert_result["result"])
|
||||
self.assertEqual(index_name, doc_insert_result["_index"])
|
||||
self.assertEqual(id, doc_insert_result["_id"])
|
||||
|
||||
doc_delete_result = self.client.delete(index=index_name, id=id)
|
||||
self.assertEqual("deleted", doc_delete_result["result"])
|
||||
self.assertEqual(index_name, doc_delete_result["_index"])
|
||||
self.assertEqual(id, doc_delete_result["_id"])
|
||||
|
||||
index_delete_result = self.client.indices.delete(index=index_name)
|
||||
self.assertTrue(index_delete_result["acknowledged"])
|
||||
|
||||
def test_indices_lifecycle_russian(self) -> None:
|
||||
index_name = "кино"
|
||||
index_create_result = self.client.indices.create(index=index_name)
|
||||
self.assertTrue(index_create_result["acknowledged"])
|
||||
self.assertEqual(index_name, index_create_result["index"])
|
||||
|
||||
document = {"название": "Солярис", "автор": "Андрей Тарковский", "год": "2011"}
|
||||
id = "соларис@2011"
|
||||
doc_insert_result = self.client.index(
|
||||
index=index_name, body=document, id=id, refresh=True
|
||||
)
|
||||
self.assertEqual("created", doc_insert_result["result"])
|
||||
self.assertEqual(index_name, doc_insert_result["_index"])
|
||||
self.assertEqual(id, doc_insert_result["_id"])
|
||||
|
||||
doc_delete_result = self.client.delete(index=index_name, id=id)
|
||||
self.assertEqual("deleted", doc_delete_result["result"])
|
||||
self.assertEqual(index_name, doc_delete_result["_index"])
|
||||
self.assertEqual(id, doc_delete_result["_id"])
|
||||
|
||||
index_delete_result = self.client.indices.delete(index=index_name)
|
||||
self.assertTrue(index_delete_result["acknowledged"])
|
||||
|
||||
def test_indices_analyze(self) -> None:
|
||||
self.client.indices.analyze(body='{"text": "привет"}')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user