From 194f5e4afe8468d3185944a9982df2c81c491fed Mon Sep 17 00:00:00 2001 From: Scott Trinh Date: Tue, 5 Mar 2024 20:48:05 -0500 Subject: [PATCH] Allow `/branch/{dbname}` in extension routes (#6979) --- edb/server/protocol/protocol.pyx | 10 +++++----- edb/testbase/http.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/edb/server/protocol/protocol.pyx b/edb/server/protocol/protocol.pyx index 59d5b581af..d0f70de872 100644 --- a/edb/server/protocol/protocol.pyx +++ b/edb/server/protocol/protocol.pyx @@ -496,7 +496,7 @@ cdef class HttpProtocol: path_parts_len = len(path_parts) route = path_parts[0] - if self.tenant is None and route in ['db', 'auth']: + if self.tenant is None and route in ['db', 'auth', 'branch']: self.tenant = self.server.get_default_tenant() self.check_readiness() if self.tenant.is_accepting_connections(): @@ -510,7 +510,7 @@ cdef class HttpProtocol: b'The server is closing.', ) - if route == 'db': + if route in ['db', 'branch']: if path_parts_len < 2: return self._not_found(request, response) @@ -635,7 +635,7 @@ cdef class HttpProtocol: else request_url.host.decode() ) extension_base_path = f"{request_url.schema.decode()}://" \ - f"{netloc}/db/{dbname}/ext/auth" + f"{netloc}/{route}/{dbname}/ext/auth" handler = auth_ext.http.Router( db=db, base_path=extension_base_path, @@ -738,7 +738,7 @@ cdef class HttpProtocol: bint allow_credentials = False ): db = self.tenant.maybe_get_db(dbname=dbname) if dbname else None - + config = None if db is not None: if db.db_config is None: @@ -774,7 +774,7 @@ cdef class HttpProtocol: if allow_credentials: response.custom_headers['Access-Control-Allow-Credentials'] = ( 'true') - + return True return False diff --git a/edb/testbase/http.py b/edb/testbase/http.py index 5ea182d8d7..7c9db11312 100644 --- a/edb/testbase/http.py +++ b/edb/testbase/http.py @@ -44,7 +44,7 @@ def get_extension_path(cls): def get_api_prefix(cls): extpath = cls.get_extension_path() dbname = cls.get_database_name() - return f'/db/{dbname}/{extpath}' + return f'/branch/{dbname}/{extpath}' @classmethod def tearDownClass(cls):