Skip to content

Commit

Permalink
Merge pull request #2305 from mitre/bleepbop/VIRTS-2881/health-v2-api…
Browse files Browse the repository at this point in the history
…-pytest

[VIRTS-2881] Health API v2 Pytests
  • Loading branch information
wbooth authored Oct 6, 2021
2 parents 72673e0 + 86c3588 commit d742b2b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/api/v2/handlers/test_health_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import pytest
import app

from http import HTTPStatus


@pytest.fixture
def expected_caldera_info():
return {
'application': 'CALDERA',
'plugins': [
{
'address': '/plugin/sandcat/gui',
'description': 'A custom multi-platform RAT',
'enabled': True,
'name': 'sandcat'
},
{
'address': 'plugin/ssl/gui',
'description': 'Run an SSL proxy in front of the server',
'enabled': False,
'name': 'ssl'
}
],
'version': app.get_version()
}


class TestHealthApi:
async def test_get_health(self, api_v2_client, api_cookies, expected_caldera_info):
resp = await api_v2_client.get('/api/v2/health', cookies=api_cookies)
assert resp.status == HTTPStatus.OK
output_info = await resp.json()
assert output_info == expected_caldera_info

async def test_unauthorized_get_health(self, api_v2_client, expected_caldera_info):
resp = await api_v2_client.get('/api/v2/health')
assert resp.status == HTTPStatus.OK
output_info = await resp.json()
assert output_info == expected_caldera_info
2 changes: 2 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from app.api.v2.handlers.operation_api import OperationApi
from app.api.v2.handlers.contact_api import ContactApi
from app.api.v2.handlers.obfuscator_api import ObfuscatorApi
from app.api.v2.handlers.health_api import HealthApi
from app.objects.c_obfuscator import Obfuscator
from app.utility.base_world import BaseWorld
from app.service.app_svc import AppService
Expand Down Expand Up @@ -322,6 +323,7 @@ def make_app(svcs):
AdversaryApi(svcs).add_routes(app)
ContactApi(svcs).add_routes(app)
ObfuscatorApi(svcs).add_routes(app)
HealthApi(svcs).add_routes(app)
return app

async def initialize():
Expand Down

0 comments on commit d742b2b

Please sign in to comment.