self._ceph_cmd(['dashboard', 'set-user-pwd-expiration-span', '0'])
def test_validate_password_weak(self):
- data = self._post('/api/user/validate_password', {
+ self._post('/api/user/validate_password', {
'password': 'mypassword1'
})
self.assertStatus(200)
- self.assertSchema(data, JObj(sub_elems={
- 'valid': JLeaf(bool),
- 'credits': JLeaf(int),
- 'valuation': JLeaf(str)
- }))
self.assertJsonBody({
'valid': True,
'credits': 11,
'credits': 0,
'valuation': 'Password must not be the same as the previous one.'
})
-
- @DashboardTestCase.RunAs('test', 'test', [{'user': ['read', 'delete']}])
- def test_validate_password_invalid_permissions(self):
- self._post('/api/user/validate_password', {
- 'password': 'foo'
- })
- self.assertStatus(403)
- self.assertError(detail='You don\'t have permissions to access that resource')
import cherrypy
-from . import BaseController, ApiController, RESTController, Endpoint, CreatePermission
+from . import BaseController, ApiController, RESTController, Endpoint
from .. import mgr
from ..exceptions import DashboardException, UserAlreadyExists, \
UserDoesNotExist, PasswordPolicyException, PwdExpirationDateNotValid
@ApiController('/user', Scope.USER)
class User(RESTController):
+
@staticmethod
def _user_to_dict(user):
result = user.to_dict()
return User._user_to_dict(user)
-@ApiController('/user', Scope.USER)
+@ApiController('/user')
class UserPasswordPolicy(RESTController):
@Endpoint('POST')
- @CreatePermission
def validate_password(self, password, username=None, old_password=None):
"""
Check if the password meets the password policy.
@ApiController('/user/{username}')
class UserChangePassword(BaseController):
+
@Endpoint('POST')
def change_password(self, username, old_password, new_password):
session_username = JwtManager.get_username()