-
-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Process URL encoded password in connection string (#356)
Co-authored-by: Lev Gorodetskiy <[email protected]>
- Loading branch information
1 parent
91c3640
commit e45d414
Showing
5 changed files
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,6 +108,22 @@ def test_postgres_basic(self): | |
}, | ||
) | ||
|
||
def test_postgres_encoded_password(self): | ||
res = expand_db_url("postgres://postgres:kx%25jj5%[email protected]:54321/test") | ||
self.assertDictEqual( | ||
res, | ||
{ | ||
"engine": "tortoise.backends.asyncpg", | ||
"credentials": { | ||
"database": "test", | ||
"host": "127.0.0.1", | ||
"password": "kx%jj5/g", | ||
"port": 54321, | ||
"user": "postgres", | ||
}, | ||
}, | ||
) | ||
|
||
def test_postgres_no_db(self): | ||
res = expand_db_url("postgres://postgres:[email protected]:54321") | ||
self.assertDictEqual( | ||
|
@@ -199,6 +215,24 @@ def test_mysql_basic(self): | |
}, | ||
) | ||
|
||
def test_mysql_encoded_password(self): | ||
res = expand_db_url("mysql://root:kx%25jj5%[email protected]:33060/test") | ||
self.assertEqual( | ||
res, | ||
{ | ||
"engine": "tortoise.backends.mysql", | ||
"credentials": { | ||
"database": "test", | ||
"host": "127.0.0.1", | ||
"password": "kx%jj5/g", | ||
"port": 33060, | ||
"user": "root", | ||
"charset": "utf8mb4", | ||
"sql_mode": "STRICT_TRANS_TABLES", | ||
}, | ||
}, | ||
) | ||
|
||
def test_mysql_no_db(self): | ||
res = expand_db_url("mysql://root:@127.0.0.1:33060") | ||
self.assertEqual( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters