DCD-545: Move seraph logic into the template and generally clean-up.

This commit is contained in:
Steve Smith 2019-08-13 11:33:49 +10:00
parent 063a249d18
commit 8f9469c9ac
3 changed files with 19 additions and 30 deletions

View File

@ -17,10 +17,12 @@
<param-value>seraph.confluence</param-value>
</init-param>
{% if atl_autologin_cookie_age is defined %}
<init-param>
<param-name>autologin.cookie.age</param-name>
<param-value>{{ atl_autologin_cookie_age }}</param-value>
</init-param>
{% endif %}
<!--only basic authentication available-->
<init-param>

View File

@ -10,6 +10,8 @@ import jinja2 as j2
######################################################################
# Utils
logging.basicConfig(level=logging.DEBUG)
def set_perms(path, user, group, mode):
shutil.chown(path, user=user, group=group)
os.chmod(path, mode)
@ -26,8 +28,6 @@ def gen_cfg(tmpl, target, env, user='root', group='root', mode=0o644):
fd.write(cfg)
set_perms(target, user, group, mode)
logging.basicConfig(level=logging.DEBUG)
######################################################################
# Setup inputs and outputs
@ -46,30 +46,19 @@ env['atl_product_home_shared'] = env.get('confluence_shared_home')
######################################################################
# Generate server.xml for Tomcat.
# Generate all configuration files for Confluence
gen_cfg('server.xml.j2', env['confluence_install_dir']+'/conf/server.xml', env)
gen_cfg('server.xml.j2',
env['confluence_install_dir']+'/conf/server.xml', env)
gen_cfg('seraph-config.xml.j2',
env['confluence_install_dir']+'/confluence/WEB-INF/classes/seraph-config.xml', env)
######################################################################
# Configure seraph login handling.
gen_cfg('confluence-init.properties.j2',
env['confluence_install_dir']+'/confluence/WEB-INF/classes/confluence-init.properties', env)
# The default is two weeks, in seconds, same as the seraph default.
env['atl_autologin_cookie_age'] = env.get('atl_autologin_cookie_age', "1209600")
gen_cfg('seraph-config.xml.j2', env['confluence_install_dir']+'/confluence/WEB-INF/classes/seraph-config.xml', env)
######################################################################
# Configure confluence-init.properties
gen_cfg('confluence-init.properties.j2', env['confluence_install_dir']+'/confluence/WEB-INF/classes/confluence-init.properties', env)
######################################################################
# Configure confluence.cfg.xml
gen_cfg('confluence.cfg.xml.j2', env['confluence_home']+'/confluence.cfg.xml', env,
gen_cfg('confluence.cfg.xml.j2',
env['confluence_home']+'/confluence.cfg.xml', env,
user=env['run_user'], group=env['run_group'], mode=0o640)

View File

@ -174,9 +174,7 @@ def test_seraph_defaults(docker_cli, image):
wait_for_file(container, "/opt/atlassian/confluence/confluence/WEB-INF/classes/seraph-config.xml")
xml = etree.fromstring(container.file('/opt/atlassian/confluence/confluence/WEB-INF/classes/seraph-config.xml').content)
param = xml.xpath('//param-name[text()="autologin.cookie.age"]')[0].getnext()
assert param.text == "1209600"
param = xml.xpath('//param-name[text()="autologin.cookie.age"]') == []
def test_seraph_login_set(docker_cli, image):
container = run_image(docker_cli, image, environment={"ATL_AUTOLOGIN_COOKIE_AGE": "TEST_VAL"})