@@ -79,6 +79,24 @@ impl crate::util::MockTokenUser {
79
79
}
80
80
}
81
81
82
+ impl crate :: util:: MockCookieUser {
83
+ /// Yank the specified version of the specified crate and run all pending background jobs
84
+ fn yank ( & self , krate_name : & str , version : & str ) -> crate :: util:: Response < OkBool > {
85
+ let url = format ! ( "/api/v1/crates/{}/{}/yank" , krate_name, version) ;
86
+ let response = self . delete ( & url) ;
87
+ self . app ( ) . run_pending_background_jobs ( ) ;
88
+ response
89
+ }
90
+
91
+ /// Unyank the specified version of the specified crate and run all pending background jobs
92
+ fn unyank ( & self , krate_name : & str , version : & str ) -> crate :: util:: Response < OkBool > {
93
+ let url = format ! ( "/api/v1/crates/{}/{}/unyank" , krate_name, version) ;
94
+ let response = self . put ( & url, & [ ] ) ;
95
+ self . app ( ) . run_pending_background_jobs ( ) ;
96
+ response
97
+ }
98
+ }
99
+
82
100
#[ test]
83
101
fn index ( ) {
84
102
let ( app, anon) = TestApp :: init ( ) . empty ( ) ;
@@ -1574,7 +1592,7 @@ fn following() {
1574
1592
1575
1593
#[ test]
1576
1594
fn yank_works_as_intended ( ) {
1577
- let ( app, anon, _ , token) = TestApp :: full ( ) . with_token ( ) ;
1595
+ let ( app, anon, cookie , token) = TestApp :: full ( ) . with_token ( ) ;
1578
1596
1579
1597
// Upload a new crate, putting it in the git index
1580
1598
let crate_to_publish = PublishBuilder :: new ( "fyk" ) ;
@@ -1608,6 +1626,26 @@ fn yank_works_as_intended() {
1608
1626
1609
1627
let json = anon. show_version ( "fyk" , "1.0.0" ) ;
1610
1628
assert ! ( !json. version. yanked) ;
1629
+
1630
+ // yank it
1631
+ cookie. yank ( "fyk" , "1.0.0" ) . good ( ) ;
1632
+
1633
+ let crates = app. crates_from_index_head ( "3/f/fyk" ) ;
1634
+ assert ! ( crates. len( ) == 1 ) ;
1635
+ assert ! ( crates[ 0 ] . yanked. unwrap( ) ) ;
1636
+
1637
+ let json = anon. show_version ( "fyk" , "1.0.0" ) ;
1638
+ assert ! ( json. version. yanked) ;
1639
+
1640
+ // un-yank it
1641
+ cookie. unyank ( "fyk" , "1.0.0" ) . good ( ) ;
1642
+
1643
+ let crates = app. crates_from_index_head ( "3/f/fyk" ) ;
1644
+ assert ! ( crates. len( ) == 1 ) ;
1645
+ assert ! ( !crates[ 0 ] . yanked. unwrap( ) ) ;
1646
+
1647
+ let json = anon. show_version ( "fyk" , "1.0.0" ) ;
1648
+ assert ! ( !json. version. yanked) ;
1611
1649
}
1612
1650
1613
1651
#[ test]
0 commit comments