@@ 146-167 (lines=22) @@ | ||
143 | params=params, |
|
144 | ) |
|
145 | ||
146 | def test_api__reset_password_reset__err_400__password_does_not_match(self): |
|
147 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
148 | admin = dbsession.query(models.User) \ |
|
149 | .filter(models.User.email == '[email protected]') \ |
|
150 | .one() |
|
151 | uapi = UserApi( |
|
152 | current_user=admin, |
|
153 | session=dbsession, |
|
154 | config=self.app_config, |
|
155 | ) |
|
156 | reset_password_token = uapi.reset_password_notification(admin, do_save=True) # nopep8 |
|
157 | transaction.commit() |
|
158 | params = { |
|
159 | 'email': '[email protected]', |
|
160 | 'reset_password_token': reset_password_token, |
|
161 | 'new_password': 'mynewpassword', |
|
162 | 'new_password2': 'anotherpassword', |
|
163 | } |
|
164 | self.testapp.post_json( |
|
165 | '/api/v2/reset_password/modify', |
|
166 | status=400, |
|
167 | params=params, |
|
168 | ) |
|
169 | ||
@@ 99-120 (lines=22) @@ | ||
96 | ||
97 | class TestResetPasswordModifyEndpoint(FunctionalTest): |
|
98 | ||
99 | def test_api__reset_password_reset__ok_204__nominal_case(self): |
|
100 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
101 | admin = dbsession.query(models.User) \ |
|
102 | .filter(models.User.email == '[email protected]') \ |
|
103 | .one() |
|
104 | uapi = UserApi( |
|
105 | current_user=admin, |
|
106 | session=dbsession, |
|
107 | config=self.app_config, |
|
108 | ) |
|
109 | reset_password_token = uapi.reset_password_notification(admin, do_save=True) # nopep8 |
|
110 | transaction.commit() |
|
111 | params = { |
|
112 | 'email': '[email protected]', |
|
113 | 'reset_password_token': reset_password_token, |
|
114 | 'new_password': 'mynewpassword', |
|
115 | 'new_password2': 'mynewpassword', |
|
116 | } |
|
117 | self.testapp.post_json( |
|
118 | '/api/v2/reset_password/modify', |
|
119 | status=204, |
|
120 | params=params, |
|
121 | ) |
|
122 | ||
123 | def test_api__reset_password_reset__err_400__invalid_token(self): |
|
@@ 123-143 (lines=21) @@ | ||
120 | params=params, |
|
121 | ) |
|
122 | ||
123 | def test_api__reset_password_reset__err_400__invalid_token(self): |
|
124 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
125 | admin = dbsession.query(models.User) \ |
|
126 | .filter(models.User.email == '[email protected]') \ |
|
127 | .one() |
|
128 | uapi = UserApi( |
|
129 | current_user=admin, |
|
130 | session=dbsession, |
|
131 | config=self.app_config, |
|
132 | ) |
|
133 | reset_password_token = 'wrong_token' |
|
134 | params = { |
|
135 | 'email': '[email protected]', |
|
136 | 'reset_password_token': reset_password_token, |
|
137 | 'new_password': 'mynewpassword', |
|
138 | 'new_password2': 'mynewpassword', |
|
139 | } |
|
140 | self.testapp.post_json( |
|
141 | '/api/v2/reset_password/modify', |
|
142 | status=401, |
|
143 | params=params, |
|
144 | ) |
|
145 | ||
146 | def test_api__reset_password_reset__err_400__password_does_not_match(self): |
|
@@ 74-93 (lines=20) @@ | ||
71 | params=params, |
|
72 | ) |
|
73 | ||
74 | def test_api__reset_password_check_token__err_400__invalid_token(self): |
|
75 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
76 | admin = dbsession.query(models.User) \ |
|
77 | .filter(models.User.email == '[email protected]') \ |
|
78 | .one() |
|
79 | uapi = UserApi( |
|
80 | current_user=admin, |
|
81 | session=dbsession, |
|
82 | config=self.app_config, |
|
83 | ) |
|
84 | reset_password_token = 'wrong_token' |
|
85 | transaction.commit() |
|
86 | params = { |
|
87 | 'email': '[email protected]', |
|
88 | 'reset_password_token': reset_password_token |
|
89 | } |
|
90 | self.testapp.post_json( |
|
91 | '/api/v2/reset_password/check_token', |
|
92 | status=401, |
|
93 | params=params, |
|
94 | ) |
|
95 | ||
96 | ||
@@ 52-71 (lines=20) @@ | ||
49 | ||
50 | class TestResetPasswordCheckTokenEndpoint(FunctionalTest): |
|
51 | ||
52 | def test_api__reset_password_check_token__ok_204__nominal_case(self): |
|
53 | dbsession = get_tm_session(self.session_factory, transaction.manager) |
|
54 | admin = dbsession.query(models.User) \ |
|
55 | .filter(models.User.email == '[email protected]') \ |
|
56 | .one() |
|
57 | uapi = UserApi( |
|
58 | current_user=admin, |
|
59 | session=dbsession, |
|
60 | config=self.app_config, |
|
61 | ) |
|
62 | reset_password_token = uapi.reset_password_notification(admin, do_save=True) # nopep8 |
|
63 | transaction.commit() |
|
64 | params = { |
|
65 | 'email': '[email protected]', |
|
66 | 'reset_password_token': reset_password_token |
|
67 | } |
|
68 | self.testapp.post_json( |
|
69 | '/api/v2/reset_password/check_token', |
|
70 | status=204, |
|
71 | params=params, |
|
72 | ) |
|
73 | ||
74 | def test_api__reset_password_check_token__err_400__invalid_token(self): |