Skip to content

Commit

Permalink
added /api/v1/active (#1987)
Browse files Browse the repository at this point in the history
  • Loading branch information
invisig0th authored Dec 7, 2020
1 parent 5a2f0a9 commit 64014fd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions synapse/lib/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,7 @@ async def fini():
def _initCellHttpApis(self):

self.addHttpApi('/api/v1/login', s_httpapi.LoginV1, {'cell': self})
self.addHttpApi('/api/v1/active', s_httpapi.ActiveV1, {'cell': self})
self.addHttpApi('/api/v1/healthcheck', s_httpapi.HealthCheckV1, {'cell': self})

self.addHttpApi('/api/v1/auth/users', s_httpapi.AuthUsersV1, {'cell': self})
Expand Down
6 changes: 6 additions & 0 deletions synapse/lib/httpapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,12 @@ async def get(self):
resp = await self.cell.getHealthCheck()
return self.sendRestRetn(resp)

class ActiveV1(Handler):

async def get(self):
resp = {'active': self.cell.isactive}
return self.sendRestRetn(resp)

class StormVarsGetV1(Handler):

async def get(self):
Expand Down
8 changes: 8 additions & 0 deletions synapse/tests/test_lib_httpapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,14 @@ async def test_healthcheck(self):
host, port = await core.addHttpsPort(0, host='127.0.0.1')

root = await core.auth.getUserByName('root')

async with self.getHttpSess(auth=None, port=port) as sess:
url = f'https://localhost:{port}/api/v1/active'
async with sess.get(url) as resp:
result = await resp.json()
self.eq(result.get('status'), 'ok')
self.true(result['result']['active'])

await root.setPasswd('secret')

url = f'https://localhost:{port}/api/v1/healthcheck'
Expand Down

0 comments on commit 64014fd

Please sign in to comment.