소스 검색

use another session to get password update

Guénaël Muller 6 년 전
부모
커밋
ccd6bfd13a
2개의 변경된 파일25개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      backend/tracim_backend/lib/core/user.py
  2. 24 0
      backend/tracim_backend/tests/functional/test_user.py

+ 1 - 1
backend/tracim_backend/lib/core/user.py 파일 보기

@@ -234,7 +234,7 @@ class UserApi(object):
234 234
         )
235 235
         if do_save:
236 236
             # TODO - G.M - 2018-07-24 - Check why commit is needed here
237
-            transaction.commit()
237
+            self.save(user)
238 238
         return user
239 239
 
240 240
     def set_email(

+ 24 - 0
backend/tracim_backend/tests/functional/test_user.py 파일 보기

@@ -1774,6 +1774,12 @@ class TestSetPasswordEndpoint(FunctionalTest):
1774 1774
             status=204,
1775 1775
         )
1776 1776
         # Check After
1777
+        dbsession = get_tm_session(self.session_factory, transaction.manager)
1778
+        uapi = UserApi(
1779
+            current_user=admin,
1780
+            session=dbsession,
1781
+            config=self.app_config,
1782
+        )
1777 1783
         user = uapi.get_one(user_id)
1778 1784
         assert not user.validate_password('pass')
1779 1785
         assert user.validate_password('mynewpassword')
@@ -1829,6 +1835,12 @@ class TestSetPasswordEndpoint(FunctionalTest):
1829 1835
             params=params,
1830 1836
             status=403,
1831 1837
         )
1838
+        dbsession = get_tm_session(self.session_factory, transaction.manager)
1839
+        uapi = UserApi(
1840
+            current_user=admin,
1841
+            session=dbsession,
1842
+            config=self.app_config,
1843
+        )
1832 1844
         # Check After
1833 1845
         user = uapi.get_one(user_id)
1834 1846
         assert user.validate_password('pass')
@@ -1887,6 +1899,12 @@ class TestSetPasswordEndpoint(FunctionalTest):
1887 1899
             status=400,
1888 1900
         )
1889 1901
         # Check After
1902
+        dbsession = get_tm_session(self.session_factory, transaction.manager)
1903
+        uapi = UserApi(
1904
+            current_user=admin,
1905
+            session=dbsession,
1906
+            config=self.app_config,
1907
+        )
1890 1908
         user = uapi.get_one(user_id)
1891 1909
         assert user.validate_password('pass')
1892 1910
         assert not user.validate_password('mynewpassword')
@@ -1944,6 +1962,12 @@ class TestSetPasswordEndpoint(FunctionalTest):
1944 1962
             status=204,
1945 1963
         )
1946 1964
         # Check After
1965
+        dbsession = get_tm_session(self.session_factory, transaction.manager)
1966
+        uapi = UserApi(
1967
+            current_user=admin,
1968
+            session=dbsession,
1969
+            config=self.app_config,
1970
+        )
1947 1971
         user = uapi.get_one(user_id)
1948 1972
         assert not user.validate_password('pass')
1949 1973
         assert user.validate_password('mynewpassword')