diff --git a/.gitignore b/.gitignore index 7d38bf1..08d7f3e 100644 --- a/.gitignore +++ b/.gitignore @@ -159,3 +159,5 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ +ansible/credentials/ +terraform/mcaptcha/mcaptcha diff --git a/tests/mcaptcha/base.py b/tests/mcaptcha/base.py new file mode 100644 index 0000000..e2ff4b7 --- /dev/null +++ b/tests/mcaptcha/base.py @@ -0,0 +1,39 @@ +# SPDX-FileCopyrightText: 2023 Aravinth Manivannan +# +# SPDX-License-Identifier: AGPL-3.0-or-later + +import os +import requests + + +def test_mcaptcha_nginx_is_listening(host): + socket = host.socket(f"tcp://127.0.0.1:80") + assert socket.is_listening + + +def test_mcaptcha_config_exists(host): + config = host.file("/etc/mcaptcha/config.toml") + assert config.exists + assert config.is_file + + +def test_mcaptcha_health(host): + url = f"http://{host.interface.default().addresses[0]}/api/v1/meta/health" + resp = requests.get(url, headers={"Host": "mcaptcha.local"}) + assert resp.status_code == 200 + data = resp.json() + if "redis" in data: + assert data["redis"] is True + assert data["db"] is True + + +def test_nginx_service_running_and_enabled(host): + service = host.service("nginx") + assert service.is_running + assert service.is_enabled + + +def test_mcaptcha_service_running_and_enabled(host): + service = host.service("mcaptcha") + assert service.is_running + assert service.is_enabled