@@ -1294,24 +1294,38 @@ fn owners_can_remove_self() {
1294
1294
let r: R = :: json ( & mut response) ;
1295
1295
assert_eq ! ( r. users. len( ) , 1 ) ;
1296
1296
1297
+ // Deleting yourself when you're the only owner isn't allowed.
1298
+ let body = r#"{"users":["firstowner"]}"# ;
1299
+ let mut response = ok_resp ! ( middle. call( req. with_method( Method :: Delete ) . with_body(
1300
+ body. as_bytes( ) ,
1301
+ ) ) ) ;
1302
+ let json = :: json :: < :: Bad > ( & mut response) ;
1303
+ assert ! ( json. errors[ 0 ] . detail. contains(
1304
+ "cannot remove the sole owner of a crate" ,
1305
+ ) ) ;
1306
+
1297
1307
let body = r#"{"users":["secondowner"]}"# ;
1298
1308
let mut response = ok_resp ! ( middle. call( req. with_method( Method :: Put ) . with_body(
1299
1309
body. as_bytes( ) ,
1300
1310
) ) ) ;
1301
1311
assert ! ( :: json:: <O >( & mut response) . ok) ;
1302
1312
1303
- // This is a self delete from owners
1313
+ // Deleting yourself when there are other owners is allowed.
1304
1314
let body = r#"{"users":["firstowner"]}"# ;
1305
1315
let mut response = ok_resp ! ( middle. call( req. with_method( Method :: Delete ) . with_body(
1306
1316
body. as_bytes( ) ,
1307
1317
) ) ) ;
1308
1318
assert ! ( :: json:: <O >( & mut response) . ok) ;
1309
1319
1320
+ // After you delete yourself, you no longer have permisions to manage the crate.
1310
1321
let body = r#"{"users":["secondowner"]}"# ;
1311
1322
let mut response = ok_resp ! ( middle. call( req. with_method( Method :: Delete ) . with_body(
1312
1323
body. as_bytes( ) ,
1313
1324
) ) ) ;
1314
- :: json :: < :: Bad > ( & mut response) ;
1325
+ let json = :: json :: < :: Bad > ( & mut response) ;
1326
+ assert ! ( json. errors[ 0 ] . detail. contains(
1327
+ "only owners have permission to modify owners" ,
1328
+ ) ) ;
1315
1329
}
1316
1330
1317
1331
#[ test]
0 commit comments