Commit 7bc19d84 authored by Łukasz Nowak's avatar Łukasz Nowak

powerdns: Fix monitor URL publication

Test has been updated, as it was not really testing parameter given to the
user. Currently the situation is not perfect, but good enough.

Real test would require full monitor URL implicit usage understanding which
is out of scope of this test.
parent f3c37e0c
...@@ -26,7 +26,7 @@ md5sum = 20c37ea06a8fa405bc02470d5115fd11 ...@@ -26,7 +26,7 @@ md5sum = 20c37ea06a8fa405bc02470d5115fd11
[template-dns-replicate] [template-dns-replicate]
_update_hash_filename_ = instance-powerdns-replicate.cfg.jinja2 _update_hash_filename_ = instance-powerdns-replicate.cfg.jinja2
md5sum = 72ce30bee3b8a9da8ac9be7eb65d83a2 md5sum = 504d15f0bbf0e515d5ff16070f1ac802
[iso-list] [iso-list]
_update_hash_filename_ = template/zz.countries.nexedi.dk.rbldnsd _update_hash_filename_ = template/zz.countries.nexedi.dk.rbldnsd
......
...@@ -122,22 +122,16 @@ config-monitor-username = admin ...@@ -122,22 +122,16 @@ config-monitor-username = admin
config-monitor-password = ${monitor-htpasswd:passwd} config-monitor-password = ${monitor-htpasswd:passwd}
[publish-information] [publish-information]
<= monitor-publish
recipe = slapos.cookbook:publish recipe = slapos.cookbook:publish
slave-amount = {{ slave_instance_list | length }} slave-amount = {{ slave_instance_list | length }}
ns-record = {{ ns_record }} ns-record = {{ ns_record }}
monitor-url = ${monitor-publish-parameters:monitor-url}
monitor-user = ${monitor-publish-parameters:monitor-user}
monitor-password = ${monitor-publish-parameters:monitor-password}
{% for dns_name, dns_section in zip(dns_list, dns_section_list) -%} {% for dns_name, dns_section in zip(dns_list, dns_section_list) -%}
{% set dns_ipv6 = '${' ~ dns_section ~ ':connection-powerdns-ipv6}' -%} {% set dns_ipv6 = '${' ~ dns_section ~ ':connection-powerdns-ipv6}' -%}
{% set dns_port = '${' ~ dns_section ~ ':connection-powerdns-port}' -%} {% set dns_port = '${' ~ dns_section ~ ':connection-powerdns-port}' -%}
{{ dns_name }}-ipv6 = {{ dns_ipv6 }} {{ dns_name }}-ipv6 = {{ dns_ipv6 }}
{{ dns_name }}-port = {{ dns_port }} {{ dns_name }}-port = {{ dns_port }}
{% endfor -%} {% endfor -%}
{% set monitor_interface_url = slapparameter_dict.get('monitor-interface-url', 'https://monitor.app.officejs.com') -%}
{% if monitor_interface_url -%}
monitor-setup-url = {{ monitor_interface_url }}/#page=settings_configurator&url=${monitor-publish-parameters:monitor-url}
{% endif -%}
[buildout] [buildout]
......
...@@ -32,6 +32,7 @@ import http.client ...@@ -32,6 +32,7 @@ import http.client
import os import os
import requests import requests
import unittest import unittest
import urllib
from slapos.recipe.librecipe import generateHashFromFiles from slapos.recipe.librecipe import generateHashFromFiles
from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass
...@@ -130,11 +131,19 @@ class TestMonitorAccess(PowerDNSTestCase): ...@@ -130,11 +131,19 @@ class TestMonitorAccess(PowerDNSTestCase):
def test(self): def test(self):
connection_parameter_dict = self.requestDefaultInstance()\ connection_parameter_dict = self.requestDefaultInstance()\
.getConnectionParameterDict() .getConnectionParameterDict()
monitor_base_url = connection_parameter_dict.get('monitor-url') # special parsing of monitor-setup-url as the URLs there are not really
# still, this test does not really check the real monitor-setup-url
# but this seems good enough
monitor_setup_url = connection_parameter_dict['monitor-setup-url']
monitor_base_url = connection_parameter_dict['monitor-base-url']
monitor_url_with_auth = 'https' + monitor_setup_url.split('https')[2]
parsed_monitor_url = urllib.parse.urlparse(monitor_url_with_auth)
auth = urllib.parse.parse_qs(parsed_monitor_url.path)
result = requests.get( result = requests.get(
monitor_base_url, verify=False, auth=( monitor_base_url, verify=False, auth=(
connection_parameter_dict.get('monitor-user'), auth['username'][0],
connection_parameter_dict.get('monitor-password') auth['password'][0]
) )
) )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment