Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added unauthenticated HTTP endpoint /api/v1/active #1987

Merged
merged 1 commit into from
Dec 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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