@@ -90,7 +90,7 @@ async fn change_password_should_fail_if_new_password_is_empty() {
90
90
. body (
91
91
serde_json:: to_string ( & LoginData {
92
92
username : "admin" . to_string ( ) ,
93
- password : "xoh7Ongui4oo" . to_string ( ) ,
93
+ password : "xoh7Ongui4oo" . to_string ( ) , // talisman-ignore-line
94
94
} )
95
95
. unwrap ( ) ,
96
96
)
@@ -104,7 +104,7 @@ async fn change_password_should_fail_if_new_password_is_empty() {
104
104
. expect ( "Unable to get cookie" ) ;
105
105
106
106
let password_change_data = PasswordChangeData {
107
- old_password : "xoh7Ongui4oo" . to_string ( ) ,
107
+ old_password : "xoh7Ongui4oo" . to_string ( ) , // talisman-ignore-line
108
108
new_password : "" . to_string ( ) ,
109
109
} ;
110
110
@@ -136,7 +136,7 @@ async fn change_password_should_fail_if_old_password_is_empty() {
136
136
. body (
137
137
serde_json:: to_string ( & LoginData {
138
138
username : "admin" . to_string ( ) ,
139
- password : "xoh7Ongui4oo" . to_string ( ) ,
139
+ password : "xoh7Ongui4oo" . to_string ( ) , // talisman-ignore-line
140
140
} )
141
141
. unwrap ( ) ,
142
142
)
@@ -151,7 +151,7 @@ async fn change_password_should_fail_if_old_password_is_empty() {
151
151
152
152
let password_change_data = PasswordChangeData {
153
153
old_password : "" . to_string ( ) ,
154
- new_password : "new_password" . to_string ( ) ,
154
+ new_password : "new_password" . to_string ( ) , // talisman-ignore-line
155
155
} ;
156
156
157
157
let actual_response = client
@@ -182,7 +182,7 @@ async fn change_password_should_fail_if_old_password_is_invalid() {
182
182
. body (
183
183
serde_json:: to_string ( & LoginData {
184
184
username : "admin" . to_string ( ) ,
185
- password : "xoh7Ongui4oo" . to_string ( ) ,
185
+ password : "xoh7Ongui4oo" . to_string ( ) , // talisman-ignore-line
186
186
} )
187
187
. unwrap ( ) ,
188
188
)
@@ -197,7 +197,7 @@ async fn change_password_should_fail_if_old_password_is_invalid() {
197
197
198
198
let password_change_data = PasswordChangeData {
199
199
old_password : "not the correct password!" . to_string ( ) ,
200
- new_password : "new_password" . to_string ( ) ,
200
+ new_password : "new_password" . to_string ( ) , // talisman-ignore-line
201
201
} ;
202
202
203
203
let actual_response = client
@@ -228,34 +228,85 @@ async fn change_password_should_be_successful_if_new_and_old_passwords_are_valid
228
228
. body (
229
229
serde_json:: to_string ( & LoginData {
230
230
username : "admin" . to_string ( ) ,
231
- password : "xoh7Ongui4oo" . to_string ( ) ,
231
+ password : "xoh7Ongui4oo" . to_string ( ) , // talisman-ignore-line
232
232
} )
233
233
. unwrap ( ) ,
234
234
)
235
235
. send ( )
236
236
. await
237
- . expect ( "Unable to send request. " ) ;
237
+ . expect ( "Unable to send request" ) ;
238
238
239
239
let cookie = login_response
240
240
. cookies ( )
241
241
. next ( )
242
242
. expect ( "Unable to get cookie" ) ;
243
243
244
244
let password_change_data = PasswordChangeData {
245
- old_password : "xoh7Ongui4oo" . to_string ( ) ,
246
- new_password : "new_password" . to_string ( ) ,
245
+ old_password : "xoh7Ongui4oo" . to_string ( ) , // talisman-ignore-line
246
+ new_password : "new_password" . to_string ( ) , // talisman-ignore-line
247
247
} ;
248
248
249
- let actual_response = client
249
+ let change_password_response = client
250
250
. put ( format ! ( "{address}/api/admin/change_password" ) )
251
251
. header ( "Content-Type" , "application/json" )
252
252
. header ( "Cookie" , format ! ( "{}={}" , cookie. name( ) , cookie. value( ) ) )
253
253
. body ( serde_json:: to_string ( & password_change_data) . unwrap ( ) )
254
254
. send ( )
255
255
. await
256
- . expect ( "Unable to send request." ) ;
256
+ . expect ( "Unable to send request" ) ;
257
+
258
+ assert_eq ! (
259
+ change_password_response. status( ) ,
260
+ actix_web:: http:: StatusCode :: OK
261
+ ) ;
262
+
263
+ let logout_response = client
264
+ . post ( format ! ( "{address}/api/admin/logout" ) )
265
+ . header ( "Content-Type" , "application/json" )
266
+ . header ( "Cookie" , format ! ( "{}={}" , cookie. name( ) , cookie. value( ) ) )
267
+ . send ( )
268
+ . await
269
+ . expect ( "Unable to send request" ) ;
270
+
271
+ assert_eq ! (
272
+ logout_response. status( ) ,
273
+ actix_web:: http:: StatusCode :: NO_CONTENT
274
+ ) ;
275
+
276
+ let failed_login_response = client
277
+ . post ( format ! ( "{address}/api/admin/login" ) )
278
+ . header ( "Content-Type" , "application/json" )
279
+ . body (
280
+ serde_json:: to_string ( & LoginData {
281
+ username : "admin" . to_string ( ) ,
282
+ password : "xoh7Ongui4oo" . to_string ( ) , // talisman-ignore-line
283
+ } )
284
+ . unwrap ( ) ,
285
+ )
286
+ . send ( )
287
+ . await
288
+ . expect ( "Unable to send request" ) ;
289
+
290
+ assert_eq ! (
291
+ failed_login_response. status( ) ,
292
+ actix_web:: http:: StatusCode :: FORBIDDEN
293
+ ) ;
294
+
295
+ let new_login_response = client
296
+ . post ( format ! ( "{address}/api/admin/login" ) )
297
+ . header ( "Content-Type" , "application/json" )
298
+ . body (
299
+ serde_json:: to_string ( & LoginData {
300
+ username : "admin" . to_string ( ) ,
301
+ password : "new_password" . to_string ( ) , // talisman-ignore-line
302
+ } )
303
+ . unwrap ( ) ,
304
+ )
305
+ . send ( )
306
+ . await
307
+ . expect ( "Unable to send request" ) ;
257
308
258
- assert_eq ! ( actual_response . status( ) , actix_web:: http:: StatusCode :: OK ) ;
309
+ assert_eq ! ( new_login_response . status( ) , actix_web:: http:: StatusCode :: OK ) ;
259
310
}
260
311
261
312
#[ actix_web:: test]
0 commit comments