Merged in SCALE-137-jdbc-url-ampersand (pull request #178)

SCALE-137: Replace '&' with `&`

* SCALE-137: replace '&' with '&'

* Fix unit tests

* Fix unit tests

* Check if jdbc url container excaped ampersand before replacing


Approved-by: Yifei Zhang
This commit is contained in:
Eugene Ivantsov 2024-08-19 05:10:29 +00:00
parent 0bab37a331
commit 38b24ecbcc
2 changed files with 21 additions and 1 deletions

View File

@ -24,7 +24,7 @@
} %}
<property name="confluence.database.choice">{{ atl_db_type }}</property>
<property name="hibernate.connection.url">{{ atl_jdbc_url }}</property>
<property name="hibernate.connection.url">{% if "&amp;" in atl_jdbc_url %} {{ atl_jdbc_url }}{% else %}{{ atl_jdbc_url | replace("&", "&amp;") }}{% endif %}</property>
<property name="hibernate.connection.username">{{ atl_jdbc_user }}</property>
{% if atl_jdbc_secret_class is defined %}
<property name="jdbc.password.decrypter.classname">{{ atl_jdbc_secret_class }}</property>

View File

@ -308,6 +308,26 @@ def test_confluence_xml_postgres(docker_cli, image, run_user):
assert xml.findall('.//property[@name="hibernate.hikari.registerMbeans"]')[0].text == "true"
assert xml.findall('.//property[@name="hibernate.connection.provider_class"]')[0].text == "com.atlassian.confluence.impl.hibernate.DelegatingHikariConnectionProvider"
def test_confluence_xml_postgres_ampersand(docker_cli, image, run_user):
environment = {
'ATL_DB_TYPE': 'postgresql',
'ATL_JDBC_URL': 'jdbc://atl_jdbc_url?param1=1&param2=2',
}
container = run_image(docker_cli, image, user=run_user, environment=environment)
_jvm = wait_for_proc(container, get_bootstrap_proc(container))
raw_xml = container.run(f'cat {get_app_home(container)}/confluence.cfg.xml').stdout
assert "jdbc://atl_jdbc_url?param1=1&amp;param2=2" in raw_xml
def test_confluence_xml_postgres_ampersand_escaped(docker_cli, image, run_user):
environment = {
'ATL_DB_TYPE': 'postgresql',
'ATL_JDBC_URL': 'jdbc://atl_jdbc_url?param1=1&amp;param2=2',
}
container = run_image(docker_cli, image, user=run_user, environment=environment)
_jvm = wait_for_proc(container, get_bootstrap_proc(container))
raw_xml = container.run(f'cat {get_app_home(container)}/confluence.cfg.xml').stdout
assert "jdbc://atl_jdbc_url?param1=1&amp;param2=2" in raw_xml
def test_confluence_xml_postgres_all_set(docker_cli, image, run_user):
environment = {
'ATL_DB_TYPE': 'postgresql',