Commit b3042e57 authored by Jérome Perrin's avatar Jérome Perrin

software/matomo: set environment variables to configure database

using https://github.com/matomo-org/matomo/pull/13676
parent aba7fac7
......@@ -15,7 +15,7 @@
[template-matomo-instance]
filename = matomo-instance.cfg.in
md5sum = 9ff98282480b9edf9af75fca5da5f349
md5sum = 145ebeb4adcd4ec3d13929f1d2ee239c
[template-matomo-backup.sh]
filename = matomo-backup.sh.in
......
......@@ -19,3 +19,12 @@ output = ${directory:scripts}/matomo-backup
context =
section parameter_dict instance-parameter
key php_bin php-bin:wrapper-path
[apache-php-service]
environment=
MATOMO_DATABASE_HOST=${mariadb-urlparse:host}:${mariadb-urlparse:port}
MATOMO_DATABASE_ADAPTER=mysql
MATOMO_DATABASE_TABLES_PREFIX=matomo_
MATOMO_DATABASE_USERNAME=${mariadb-urlparse:username}
MATOMO_DATABASE_PASSWORD=${mariadb-urlparse:password}
MATOMO_DATABASE_DBNAME=${mariadb-urlparse:path}
......@@ -46,6 +46,7 @@ setup(
'slapos.libnetworkcache',
'erp5.util',
'requests',
'lxml',
],
zip_safe=True,
test_suite='test',
......
......@@ -25,10 +25,14 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import io
import os
import requests
import urllib.parse
import glob
import lxml.etree
import requests
from slapos.testing.testcase import makeModuleSetUpAndTestCaseClass
setUpModule, SlapOSInstanceTestCase = makeModuleSetUpAndTestCaseClass(
......@@ -63,5 +67,25 @@ class MatomoTestCase(SlapOSInstanceTestCase):
resp = requests.get(self.connection_parameters['monitor-setup-url'], verify=False)
self.assertEqual(requests.codes.ok, resp.status_code)
def test_database_setup(self):
# Database setup page is prefilled with mariadb connection parameters
resp = requests.get(
urllib.parse.urljoin(
self.connection_parameters['backend-url'],
'index.php?module=CoreUpdater&action=databaseSetup'),
verify=False)
parser = lxml.etree.HTMLParser()
tree = lxml.etree.parse(io.StringIO(resp.text), parser)
self.assertEqual(
tree.xpath('//input[@name="username"]/@value'),
['matomo'])
self.assertEqual(
tree.xpath('//input[@name="dbname"]/@value'),
['matomo'])
self.assertTrue(
tree.xpath('//input[@name="password"]/@value')[0])
self.assertEqual(
tree.xpath('//input[@name="host"]/@value'),
[f'{self._ipv4_address}:2099']
)
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