mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-22 12:11:26 +00:00
test(services): untie dkim-related service tests from rest
This commit is contained in:
parent
80e00740fb
commit
125d221442
|
@ -1,11 +1,12 @@
|
||||||
import base64
|
|
||||||
import json
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from selfprivacy_api.services.service import ServiceStatus
|
||||||
def read_json(file_path):
|
from selfprivacy_api.services.bitwarden import Bitwarden
|
||||||
with open(file_path, "r", encoding="utf-8") as file:
|
from selfprivacy_api.services.gitea import Gitea
|
||||||
return json.load(file)
|
from selfprivacy_api.services.mailserver import MailServer
|
||||||
|
from selfprivacy_api.services.nextcloud import Nextcloud
|
||||||
|
from selfprivacy_api.services.ocserv import Ocserv
|
||||||
|
from selfprivacy_api.services.pleroma import Pleroma
|
||||||
|
|
||||||
|
|
||||||
def call_args_asserts(mocked_object):
|
def call_args_asserts(mocked_object):
|
||||||
|
@ -90,49 +91,21 @@ def mock_broken_service(mocker):
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
|
||||||
def test_unauthorized(client, mock_subproccess_popen):
|
|
||||||
"""Test unauthorized"""
|
|
||||||
response = client.get("/services/status")
|
|
||||||
assert response.status_code == 401
|
|
||||||
|
|
||||||
|
|
||||||
def test_illegal_methods(authorized_client, mock_subproccess_popen):
|
|
||||||
response = authorized_client.post("/services/status")
|
|
||||||
assert response.status_code == 405
|
|
||||||
response = authorized_client.put("/services/status")
|
|
||||||
assert response.status_code == 405
|
|
||||||
response = authorized_client.delete("/services/status")
|
|
||||||
assert response.status_code == 405
|
|
||||||
|
|
||||||
|
|
||||||
def test_dkim_key(authorized_client, mock_subproccess_popen):
|
def test_dkim_key(authorized_client, mock_subproccess_popen):
|
||||||
response = authorized_client.get("/services/status")
|
assert MailServer.get_status() == ServiceStatus.ACTIVE
|
||||||
assert response.status_code == 200
|
assert Bitwarden.get_status() == ServiceStatus.ACTIVE
|
||||||
assert response.json() == {
|
assert Gitea.get_status() == ServiceStatus.ACTIVE
|
||||||
"imap": 0,
|
assert Nextcloud.get_status() == ServiceStatus.ACTIVE
|
||||||
"smtp": 0,
|
assert Ocserv.get_status() == ServiceStatus.ACTIVE
|
||||||
"http": 0,
|
assert Pleroma.get_status() == ServiceStatus.ACTIVE
|
||||||
"bitwarden": 0,
|
|
||||||
"gitea": 0,
|
|
||||||
"nextcloud": 0,
|
|
||||||
"ocserv": 0,
|
|
||||||
"pleroma": 0,
|
|
||||||
}
|
|
||||||
call_args_asserts(mock_subproccess_popen)
|
call_args_asserts(mock_subproccess_popen)
|
||||||
|
|
||||||
|
|
||||||
def test_no_dkim_key(authorized_client, mock_broken_service):
|
def test_no_dkim_key(authorized_client, mock_broken_service):
|
||||||
response = authorized_client.get("/services/status")
|
assert MailServer.get_status() == ServiceStatus.FAILED
|
||||||
assert response.status_code == 200
|
assert Bitwarden.get_status() == ServiceStatus.FAILED
|
||||||
assert response.json() == {
|
assert Gitea.get_status() == ServiceStatus.FAILED
|
||||||
"imap": 1,
|
assert Nextcloud.get_status() == ServiceStatus.FAILED
|
||||||
"smtp": 1,
|
assert Ocserv.get_status() == ServiceStatus.FAILED
|
||||||
"http": 0,
|
assert Pleroma.get_status() == ServiceStatus.FAILED
|
||||||
"bitwarden": 1,
|
|
||||||
"gitea": 1,
|
|
||||||
"nextcloud": 1,
|
|
||||||
"ocserv": 1,
|
|
||||||
"pleroma": 1,
|
|
||||||
}
|
|
||||||
call_args_asserts(mock_broken_service)
|
call_args_asserts(mock_broken_service)
|
Loading…
Reference in a new issue