do not use str(url) to stringify a URL for subsequent use

The str(url) function in SQLAlchemy hides the password.
For a URL string that is to be re-used, use
render_as_string(hide_password=False).

Co-Authored-By: Mike Bayer <mike_mp@zzzcomputing.com>
Change-Id: I00e8bab328b3969c503d682fac6d3f3f811d9c68
This commit is contained in:
Takashi Kajinami 2024-05-16 00:12:29 +09:00
parent 7fd8e38895
commit 5f746b474c
2 changed files with 7 additions and 2 deletions

View File

@ -45,7 +45,9 @@ class BaseFullStackTestCase(testlib_api.MySQLTestCaseMixin,
# neutron server against this database.
_orig_db_url = cfg.CONF.database.connection
cfg.CONF.set_override(
'connection', str(self.engine.url), group='database')
'connection',
self.engine.url.render_as_string(hide_password=False),
group='database')
self.addCleanup(
cfg.CONF.set_override,
"connection", _orig_db_url, group="database"

View File

@ -33,7 +33,10 @@ VERSION_TABLE = 'alembic_version_fwaas'
class _TestModelsMigrationsFWaaS(test_migrations._TestModelsMigrations):
def db_sync(self, engine):
cfg.CONF.set_override('connection', engine.url, group='database')
cfg.CONF.set_override(
'connection',
self.engine.url.render_as_string(hide_password=False),
group='database')
for conf in migration.get_alembic_configs():
self.alembic_config = conf
self.alembic_config.neutron_config = cfg.CONF