def test_login_invalid(self):
self._post("/api/auth", {'username': 'admin', 'password': 'inval'})
- self.assertStatus(403)
- self.assertJsonBody({"detail": "Invalid credentials"})
+ self.assertStatus(400)
+ self.assertJsonBody({
+ "component": "auth",
+ "code": "invalid_credentials",
+ "detail": "Invalid credentials"
+ })
def test_logout(self):
self._post("/api/auth", {'username': 'admin', 'password': 'admin'})
from . import ApiController, RESTController
from .. import logger, mgr
+from ..exceptions import DashboardException
from ..tools import Session
logger.debug('Login successful')
return {'username': username}
- cherrypy.response.status = 403
if config_username is None:
logger.warning('No Credentials configured. Need to call `ceph dashboard '
'set-login-credentials <username> <password>` first.')
else:
logger.debug('Login failed')
- return {'detail': 'Invalid credentials'}
+ raise DashboardException(msg='Invalid credentials',
+ code='invalid_credentials',
+ component='auth')
def bulk_delete(self):
logger.debug('Logout successful')