Skip to content
Snippets Groups Projects
Commit 40f71541 authored by Rajmund Hruška's avatar Rajmund Hruška
Browse files

Expose clients via API

parent 05c24209
No related branches found
No related tags found
No related merge requests found
...@@ -142,6 +142,19 @@ class Warden3ServerTest(unittest.TestCase): ...@@ -142,6 +142,19 @@ class Warden3ServerTest(unittest.TestCase):
status, _, _ = Request(self.app, query)() status, _, _ = Request(self.app, query)()
self.assertEqual(status, expected_status) self.assertEqual(status, expected_status)
def test_getClients_interface(self):
"""Tests the getClients method invocation"""
tests_common = [
("/getClients?secret=abc", "200 OK"),
("/getClients?secret=abc&evil=false", "200 OK"),
("/getClients?client=dwadaw", "403 I'm watching. Authenticate."),
("/getClients?client=asdf.blefub&secret=abc", "403 I'm watching. Authenticate."),
]
for query, expected_status in tests_common:
with self.subTest(query=query, expected_status=expected_status):
status, _, _ = Request(self.app, query)()
self.assertEqual(status, expected_status)
def test_getEvents_interface(self): # pylint: disable = locally-disabled, invalid-name def test_getEvents_interface(self): # pylint: disable = locally-disabled, invalid-name
"""Tests the getEvents method invocation""" """Tests the getEvents method invocation"""
tests_common = [ tests_common = [
......
...@@ -1630,6 +1630,11 @@ class WardenHandler(ObjectBase): ...@@ -1630,6 +1630,11 @@ class WardenHandler(ObjectBase):
info["description"] = self.description info["description"] = self.description
return info return info
@expose(read=True)
@json_wrapper
def getClients(self):
return {"clients": self.db.get_clients()}
@expose(read=True) @expose(read=True)
@json_wrapper @json_wrapper
def getEvents( def getEvents(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment