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

@ -16,11 +16,13 @@
<param-name>login.cookie.key</param-name> <param-name>login.cookie.key</param-name>
<param-value>seraph.confluence</param-value> <param-value>seraph.confluence</param-value>
</init-param> </init-param>
<init-param> {% if atl_autologin_cookie_age is defined %}
<param-name>autologin.cookie.age</param-name> <init-param>
<param-value>{{ atl_autologin_cookie_age }}</param-value> <param-name>autologin.cookie.age</param-name>
</init-param> <param-value>{{ atl_autologin_cookie_age }}</param-value>
</init-param>
{% endif %}
<!--only basic authentication available--> <!--only basic authentication available-->
<init-param> <init-param>

View File

@ -10,6 +10,8 @@ import jinja2 as j2
###################################################################### ######################################################################
# Utils # Utils
logging.basicConfig(level=logging.DEBUG)
def set_perms(path, user, group, mode): def set_perms(path, user, group, mode):
shutil.chown(path, user=user, group=group) shutil.chown(path, user=user, group=group)
os.chmod(path, mode) os.chmod(path, mode)
@ -26,8 +28,6 @@ def gen_cfg(tmpl, target, env, user='root', group='root', mode=0o644):
fd.write(cfg) fd.write(cfg)
set_perms(target, user, group, mode) set_perms(target, user, group, mode)
logging.basicConfig(level=logging.DEBUG)
###################################################################### ######################################################################
# Setup inputs and outputs # 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)
###################################################################### gen_cfg('confluence-init.properties.j2',
# Configure seraph login handling. env['confluence_install_dir']+'/confluence/WEB-INF/classes/confluence-init.properties', env)
# The default is two weeks, in seconds, same as the seraph default. gen_cfg('confluence.cfg.xml.j2',
env['atl_autologin_cookie_age'] = env.get('atl_autologin_cookie_age', "1209600") env['confluence_home']+'/confluence.cfg.xml', env,
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,
user=env['run_user'], group=env['run_group'], mode=0o640) 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") 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) 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() param = xml.xpath('//param-name[text()="autologin.cookie.age"]') == []
assert param.text == "1209600"
def test_seraph_login_set(docker_cli, image): def test_seraph_login_set(docker_cli, image):
container = run_image(docker_cli, image, environment={"ATL_AUTOLOGIN_COOKIE_AGE": "TEST_VAL"}) container = run_image(docker_cli, image, environment={"ATL_AUTOLOGIN_COOKIE_AGE": "TEST_VAL"})