Skip to content

Commit 2503919

Browse files
committed
Added a test that makes sure the slash is properly encoded.
Signed-off-by: dblock <[email protected]>
1 parent 0716eda commit 2503919

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

test_opensearchpy/test_async/test_server/test_clients.py

+13
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,22 @@
3030
import pytest
3131
from _pytest.mark.structures import MarkDecorator
3232

33+
from opensearchpy.exceptions import RequestError
34+
3335
pytestmark: MarkDecorator = pytest.mark.asyncio
3436

3537

38+
class TestSpecialCharacters:
39+
async def test_index_with_slash(self, async_client: Any) -> None:
40+
index_name = "movies/shmovies"
41+
with pytest.raises(RequestError) as e:
42+
await async_client.indices.create(index=index_name)
43+
assert (
44+
str(e.value)
45+
== "RequestError(400, 'invalid_index_name_exception', 'Invalid index name [movies/shmovies], must not contain the following characters [ , \", *, \\\\, <, |, ,, >, /, ?]')"
46+
)
47+
48+
3649
class TestUnicode:
3750
async def test_indices_lifecycle_english(self, async_client: Any) -> None:
3851
index_name = "movies"

test_opensearchpy/test_server/test_clients.py

+15
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,24 @@
2525
# under the License.
2626

2727

28+
import pytest
29+
30+
from opensearchpy.exceptions import RequestError
31+
2832
from . import OpenSearchTestCase
2933

3034

35+
class TestSpecialCharacters(OpenSearchTestCase):
36+
def test_index_with_slash(self) -> None:
37+
index_name = "movies/shmovies"
38+
with pytest.raises(RequestError) as e:
39+
self.client.indices.create(index=index_name)
40+
self.assertEqual(
41+
str(e.value),
42+
"RequestError(400, 'invalid_index_name_exception', 'Invalid index name [movies/shmovies], must not contain the following characters [ , \", *, \\\\, <, |, ,, >, /, ?]')",
43+
)
44+
45+
3146
class TestUnicode(OpenSearchTestCase):
3247
def test_indices_lifecycle_english(self) -> None:
3348
index_name = "movies"

0 commit comments

Comments
 (0)