Skip to content

Commit d742b2b

Browse files
authored
Merge pull request #2305 from mitre/bleepbop/VIRTS-2881/health-v2-api-pytest
[VIRTS-2881] Health API v2 Pytests
2 parents 72673e0 + 86c3588 commit d742b2b

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import pytest
2+
import app
3+
4+
from http import HTTPStatus
5+
6+
7+
@pytest.fixture
8+
def expected_caldera_info():
9+
return {
10+
'application': 'CALDERA',
11+
'plugins': [
12+
{
13+
'address': '/plugin/sandcat/gui',
14+
'description': 'A custom multi-platform RAT',
15+
'enabled': True,
16+
'name': 'sandcat'
17+
},
18+
{
19+
'address': 'plugin/ssl/gui',
20+
'description': 'Run an SSL proxy in front of the server',
21+
'enabled': False,
22+
'name': 'ssl'
23+
}
24+
],
25+
'version': app.get_version()
26+
}
27+
28+
29+
class TestHealthApi:
30+
async def test_get_health(self, api_v2_client, api_cookies, expected_caldera_info):
31+
resp = await api_v2_client.get('/api/v2/health', cookies=api_cookies)
32+
assert resp.status == HTTPStatus.OK
33+
output_info = await resp.json()
34+
assert output_info == expected_caldera_info
35+
36+
async def test_unauthorized_get_health(self, api_v2_client, expected_caldera_info):
37+
resp = await api_v2_client.get('/api/v2/health')
38+
assert resp.status == HTTPStatus.OK
39+
output_info = await resp.json()
40+
assert output_info == expected_caldera_info

tests/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from app.api.v2.handlers.operation_api import OperationApi
1919
from app.api.v2.handlers.contact_api import ContactApi
2020
from app.api.v2.handlers.obfuscator_api import ObfuscatorApi
21+
from app.api.v2.handlers.health_api import HealthApi
2122
from app.objects.c_obfuscator import Obfuscator
2223
from app.utility.base_world import BaseWorld
2324
from app.service.app_svc import AppService
@@ -322,6 +323,7 @@ def make_app(svcs):
322323
AdversaryApi(svcs).add_routes(app)
323324
ContactApi(svcs).add_routes(app)
324325
ObfuscatorApi(svcs).add_routes(app)
326+
HealthApi(svcs).add_routes(app)
325327
return app
326328

327329
async def initialize():

0 commit comments

Comments
 (0)