diff --git a/netbox/users/api/serializers.py b/netbox/users/api/serializers.py index 8d3bffba4..3bb098beb 100644 --- a/netbox/users/api/serializers.py +++ b/netbox/users/api/serializers.py @@ -60,7 +60,7 @@ class UserSerializer(ValidatedModelSerializer): if password is not None: instance.set_password(password) - instance.save() + super().update(instance, validated_data) return instance diff --git a/netbox/users/tests/test_api.py b/netbox/users/tests/test_api.py index a43077442..090ccc263 100644 --- a/netbox/users/tests/test_api.py +++ b/netbox/users/tests/test_api.py @@ -54,24 +54,25 @@ class UserTest(APIViewTestCases.APIViewTestCase): ) User.objects.bulk_create(users) - -class ChangeUserPasswordTest(APITestCase): - - user_permissions = ['auth.change_user'] - def test_that_password_is_changed(self): """ Test that password is changed """ + obj_perm = ObjectPermission( + name='Test permission', + actions=['change'] + ) + obj_perm.save() + obj_perm.users.add(self.user) + obj_perm.object_types.add(ContentType.objects.get_for_model(self.model)) + user_credentials = { 'username': 'user1', 'password': 'abc123', } user = User.objects.create_user(**user_credentials) - print(user.id) - data = { 'password': 'newpassword' }