import time
import jwt
+from teuthology.orchestra.run import \
+ CommandFailedError # pylint: disable=import-error
from .helper import DashboardTestCase, JObj, JLeaf
self.reset_session()
def _validate_jwt_token(self, token, username, permissions):
- payload = jwt.decode(token, verify=False)
+ payload = jwt.decode(token, options={'verify_signature': False})
self.assertIn('username', payload)
self.assertEqual(payload['username'], username)
self.assertIn('create', perms)
self.assertIn('delete', perms)
+ def test_login_without_password(self):
+ with self.assertRaises(CommandFailedError):
+ self.create_user('admin2', '', ['administrator'], force_password=True)
+
def test_a_set_login_credentials(self):
# test with Authorization header
self.create_user('admin2', 'admin2', ['administrator'])
"detail": "Invalid credentials"
})
- def test_login_without_password(self):
- # test with Authorization header
- self.create_user('admin2', '', ['administrator'])
- self._post("/api/auth", {'username': 'admin2', 'password': ''})
- self.assertStatus(400)
- self.assertJsonBody({
- "component": "auth",
- "code": "invalid_credentials",
- "detail": "Invalid credentials"
- })
- self.delete_user('admin2')
-
- # test with Cookies set
- self.create_user('admin2', '', ['administrator'])
- self._post("/api/auth", {'username': 'admin2', 'password': ''}, set_cookies=True)
- self.assertStatus(400)
- self.assertJsonBody({
- "component": "auth",
- "code": "invalid_credentials",
- "detail": "Invalid credentials"
- })
- self.delete_user('admin2')
-
def test_lockout_user(self):
# test with Authorization header
self._ceph_cmd(['dashboard', 'set-account-lockout-attempts', '3'])
self._get("/api/host")
self.assertStatus(200)
time.sleep(1)
- self._ceph_cmd(['dashboard', 'ac-user-set-password', '--force-password',
- 'user', 'user2'])
+ self._ceph_cmd_with_secret(['dashboard', 'ac-user-set-password', '--force-password',
+ 'user'],
+ 'user2')
time.sleep(1)
self._get("/api/host")
self.assertStatus(401)
self._get("/api/host", set_cookies=True)
self.assertStatus(200)
time.sleep(1)
- self._ceph_cmd(['dashboard', 'ac-user-set-password', '--force-password',
- 'user', 'user2'])
+ self._ceph_cmd_with_secret(['dashboard', 'ac-user-set-password', '--force-password',
+ 'user'],
+ 'user2')
time.sleep(1)
self._get("/api/host", set_cookies=True)
self.assertStatus(401)