Skip to content

Commit 8b61a87

Browse files
ranchodeluxeranchodeluxevincentsarago
authored
use quote_plus instead of quote (#122)
* use quote_plus instead of quote `asyncpg` doesn't work well for all US-ASCII characters, we need to use `quote_plus` instead MagicStack/asyncpg#1159 * make it fail * fix test * one more quote --------- Co-authored-by: ranchodeluxe <[email protected]> Co-authored-by: vincentsarago <[email protected]>
1 parent 60b046f commit 8b61a87

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

stac_fastapi/pgstac/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Postgres API configuration."""
22

33
from typing import List, Type
4-
from urllib.parse import quote
4+
from urllib.parse import quote_plus as quote
55

66
from pydantic import BaseModel
77
from pydantic_settings import SettingsConfigDict

tests/api/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ async def test_no_extension(
712712
hydrate, validation, load_test_data, database, pgstac
713713
) -> None:
714714
"""test PgSTAC with no extension."""
715-
connection = f"postgresql://{database.user}:{database.password}@{database.host}:{database.port}/{database.dbname}"
715+
connection = f"postgresql://{database.user}:{quote_plus(database.password)}@{database.host}:{database.port}/{database.dbname}"
716716
with PgstacDB(dsn=connection) as db:
717717
loader = Loader(db=db)
718718
loader.load_collections(os.path.join(DATA_DIR, "test_collection.json"))

tests/conftest.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
import time
66
from typing import Callable, Dict
7+
from urllib.parse import quote_plus as quote
78
from urllib.parse import urljoin
89

910
import asyncpg
@@ -53,11 +54,9 @@ def database(postgresql_proc):
5354
port=postgresql_proc.port,
5455
dbname="pgstactestdb",
5556
version=postgresql_proc.version,
56-
password="secret",
57+
password="a2Vw:yk=)CdSis[fek]tW=/o",
5758
) as jan:
58-
connection = (
59-
f"postgresql://{jan.user}:{jan.password}@{jan.host}:{jan.port}/{jan.dbname}"
60-
)
59+
connection = f"postgresql://{jan.user}:{quote(jan.password)}@{jan.host}:{jan.port}/{jan.dbname}"
6160
with PgstacDB(dsn=connection) as db:
6261
migrator = Migrate(db)
6362
version = migrator.run_migration()
@@ -68,7 +67,7 @@ def database(postgresql_proc):
6867

6968
@pytest.fixture(autouse=True)
7069
async def pgstac(database):
71-
connection = f"postgresql://{database.user}:{database.password}@{database.host}:{database.port}/{database.dbname}"
70+
connection = f"postgresql://{database.user}:{quote(database.password)}@{database.host}:{database.port}/{database.dbname}"
7271
yield
7372
conn = await asyncpg.connect(dsn=connection)
7473
await conn.execute(
@@ -99,7 +98,6 @@ async def pgstac(database):
9998
)
10099
def api_client(request, database):
101100
hydrate, prefix, response_model = request.param
102-
103101
api_settings = Settings(
104102
postgres_user=database.user,
105103
postgres_pass=database.password,

0 commit comments

Comments
 (0)