bugfix: parse password on db connection string when it has @ on It (#3173)
* ✨ (test_connection_string.py): add unit test for the transform_connection_string function to ensure correct transformation of connection strings * 📝 (pgvector.py): add support for parsing and transforming connection string in PGVectorStoreComponent to improve security and maintainability 📝 (connection_string_parser.py): create utility function to transform connection string by encoding password to improve security 📝 (test_connection_string_parser.py): add unit tests for transform_connection_string function to ensure correct transformation of connection string * test: fix import --------- Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
This commit is contained in:
parent
a9fec06992
commit
5dc3ff2b1f
3 changed files with 41 additions and 2 deletions
|
|
@ -0,0 +1,25 @@
|
|||
import pytest
|
||||
from langflow.utils.connection_string_parser import transform_connection_string
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
pass
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"connection_string, expected",
|
||||
[
|
||||
("protocol:user:password@host", "protocol:user:password@host"),
|
||||
("protocol:user@host", "protocol:user@host"),
|
||||
("protocol:user:pass@word@host", "protocol:user:pass%40word@host"),
|
||||
("protocol:user:pa:ss:word@host", "protocol:user:pa:ss:word@host"),
|
||||
("user:password@host", "user:password@host"),
|
||||
("protocol::password@host", "protocol::password@host"),
|
||||
("protocol:user:password@", "protocol:user:password@"),
|
||||
("protocol:user:pa@ss@word@host", "protocol:user:pa%40ss%40word@host"),
|
||||
],
|
||||
)
|
||||
def test_transform_connection_string(connection_string, expected):
|
||||
result = transform_connection_string(connection_string)
|
||||
assert result == expected
|
||||
Loading…
Add table
Add a link
Reference in a new issue