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
|
||||
|
||||
|
||||
def read_json(file_path):
|
||||
with open(file_path, "r", encoding="utf-8") as file:
|
||||
return json.load(file)
|
||||
from selfprivacy_api.services.service import ServiceStatus
|
||||
from selfprivacy_api.services.bitwarden import Bitwarden
|
||||
from selfprivacy_api.services.gitea import Gitea
|
||||
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):
|
||||
|
@ -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):
|
||||
response = authorized_client.get("/services/status")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {
|
||||
"imap": 0,
|
||||
"smtp": 0,
|
||||
"http": 0,
|
||||
"bitwarden": 0,
|
||||
"gitea": 0,
|
||||
"nextcloud": 0,
|
||||
"ocserv": 0,
|
||||
"pleroma": 0,
|
||||
}
|
||||
assert MailServer.get_status() == ServiceStatus.ACTIVE
|
||||
assert Bitwarden.get_status() == ServiceStatus.ACTIVE
|
||||
assert Gitea.get_status() == ServiceStatus.ACTIVE
|
||||
assert Nextcloud.get_status() == ServiceStatus.ACTIVE
|
||||
assert Ocserv.get_status() == ServiceStatus.ACTIVE
|
||||
assert Pleroma.get_status() == ServiceStatus.ACTIVE
|
||||
call_args_asserts(mock_subproccess_popen)
|
||||
|
||||
|
||||
def test_no_dkim_key(authorized_client, mock_broken_service):
|
||||
response = authorized_client.get("/services/status")
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {
|
||||
"imap": 1,
|
||||
"smtp": 1,
|
||||
"http": 0,
|
||||
"bitwarden": 1,
|
||||
"gitea": 1,
|
||||
"nextcloud": 1,
|
||||
"ocserv": 1,
|
||||
"pleroma": 1,
|
||||
}
|
||||
assert MailServer.get_status() == ServiceStatus.FAILED
|
||||
assert Bitwarden.get_status() == ServiceStatus.FAILED
|
||||
assert Gitea.get_status() == ServiceStatus.FAILED
|
||||
assert Nextcloud.get_status() == ServiceStatus.FAILED
|
||||
assert Ocserv.get_status() == ServiceStatus.FAILED
|
||||
assert Pleroma.get_status() == ServiceStatus.FAILED
|
||||
call_args_asserts(mock_broken_service)
|
Loading…
Reference in a new issue