Initial draft
This commit is contained in:
0
tests/e2e/__init__.py
Normal file
0
tests/e2e/__init__.py
Normal file
27
tests/e2e/docker-compose.yml
Normal file
27
tests/e2e/docker-compose.yml
Normal file
@@ -0,0 +1,27 @@
|
||||
services:
|
||||
db:
|
||||
image: mariadb:11
|
||||
environment:
|
||||
MARIADB_DATABASE: matomo
|
||||
MARIADB_USER: matomo
|
||||
MARIADB_PASSWORD: matomo_pw
|
||||
MARIADB_ROOT_PASSWORD: root_pw
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "mariadb-admin ping -uroot -proot_pw --silent"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 60
|
||||
|
||||
matomo:
|
||||
image: matomo:5.3.2
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
ports:
|
||||
- "8080:80"
|
||||
environment:
|
||||
MATOMO_DATABASE_HOST: db
|
||||
MATOMO_DATABASE_ADAPTER: mysql
|
||||
MATOMO_DATABASE_USERNAME: matomo
|
||||
MATOMO_DATABASE_PASSWORD: matomo_pw
|
||||
MATOMO_DATABASE_DBNAME: matomo
|
||||
44
tests/e2e/test_bootstrap.py
Normal file
44
tests/e2e/test_bootstrap.py
Normal file
@@ -0,0 +1,44 @@
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import unittest
|
||||
import urllib.request
|
||||
|
||||
|
||||
MATOMO_URL = os.environ.get("MATOMO_URL", "http://127.0.0.1:8080")
|
||||
ADMIN_USER = os.environ.get("MATOMO_ADMIN_USER", "administrator")
|
||||
ADMIN_PASSWORD = os.environ.get("MATOMO_ADMIN_PASSWORD", "AdminSecret123!")
|
||||
|
||||
|
||||
class TestMatomoBootstrapE2E(unittest.TestCase):
|
||||
def test_bootstrap_creates_api_token(self) -> None:
|
||||
cmd = [
|
||||
"python3",
|
||||
"-m",
|
||||
"matomo_bootstrap",
|
||||
"--base-url",
|
||||
MATOMO_URL,
|
||||
"--admin-user",
|
||||
ADMIN_USER,
|
||||
"--admin-password",
|
||||
ADMIN_PASSWORD,
|
||||
"--token-description",
|
||||
"e2e-test-token",
|
||||
]
|
||||
|
||||
token = subprocess.check_output(
|
||||
cmd,
|
||||
env={**os.environ, "PYTHONPATH": "src"},
|
||||
).decode().strip()
|
||||
|
||||
self.assertRegex(token, r"^[a-f0-9]{32,64}$", f"Expected token_auth, got: {token}")
|
||||
|
||||
api_url = (
|
||||
f"{MATOMO_URL}/api.php"
|
||||
f"?module=API&method=SitesManager.getSitesWithAtLeastViewAccess"
|
||||
f"&format=json&token_auth={token}"
|
||||
)
|
||||
with urllib.request.urlopen(api_url, timeout=10) as resp:
|
||||
data = json.loads(resp.read().decode())
|
||||
|
||||
self.assertIsInstance(data, list)
|
||||
Reference in New Issue
Block a user