|
1 |
| -use crate::builders::{CrateBuilder, PublishBuilder}; |
| 1 | +use crate::builders::PublishBuilder; |
| 2 | +use crate::routes::crates::versions::yank_unyank::YankRequestHelper; |
2 | 3 | use crate::util::{RequestHelper, TestApp};
|
3 |
| -use crate::OkBool; |
4 |
| -use http::StatusCode; |
5 |
| - |
6 |
| -impl crate::util::MockTokenUser { |
7 |
| - /// Yank the specified version of the specified crate and run all pending background jobs |
8 |
| - fn yank(&self, krate_name: &str, version: &str) -> crate::util::Response<OkBool> { |
9 |
| - let url = format!("/api/v1/crates/{krate_name}/{version}/yank"); |
10 |
| - let response = self.delete(&url); |
11 |
| - self.app().run_pending_background_jobs(); |
12 |
| - response |
13 |
| - } |
14 |
| - |
15 |
| - /// Unyank the specified version of the specified crate and run all pending background jobs |
16 |
| - fn unyank(&self, krate_name: &str, version: &str) -> crate::util::Response<OkBool> { |
17 |
| - let url = format!("/api/v1/crates/{krate_name}/{version}/unyank"); |
18 |
| - let response = self.put(&url, &[]); |
19 |
| - self.app().run_pending_background_jobs(); |
20 |
| - response |
21 |
| - } |
22 |
| -} |
23 |
| - |
24 |
| -impl crate::util::MockCookieUser { |
25 |
| - /// Yank the specified version of the specified crate and run all pending background jobs |
26 |
| - fn yank(&self, krate_name: &str, version: &str) -> crate::util::Response<OkBool> { |
27 |
| - let url = format!("/api/v1/crates/{krate_name}/{version}/yank"); |
28 |
| - let response = self.delete(&url); |
29 |
| - self.app().run_pending_background_jobs(); |
30 |
| - response |
31 |
| - } |
32 |
| - |
33 |
| - /// Unyank the specified version of the specified crate and run all pending background jobs |
34 |
| - fn unyank(&self, krate_name: &str, version: &str) -> crate::util::Response<OkBool> { |
35 |
| - let url = format!("/api/v1/crates/{krate_name}/{version}/unyank"); |
36 |
| - let response = self.put(&url, &[]); |
37 |
| - self.app().run_pending_background_jobs(); |
38 |
| - response |
39 |
| - } |
40 |
| -} |
41 | 4 |
|
42 | 5 | #[test]
|
43 | 6 | #[allow(unknown_lints, clippy::bool_assert_comparison)] // for claim::assert_some_eq! with bool
|
@@ -97,26 +60,6 @@ fn yank_works_as_intended() {
|
97 | 60 | assert!(!json.version.yanked);
|
98 | 61 | }
|
99 | 62 |
|
100 |
| -#[test] |
101 |
| -fn yank_by_a_non_owner_fails() { |
102 |
| - let (app, _, _, token) = TestApp::full().with_token(); |
103 |
| - |
104 |
| - let another_user = app.db_new_user("bar"); |
105 |
| - let another_user = another_user.as_model(); |
106 |
| - app.db(|conn| { |
107 |
| - CrateBuilder::new("foo_not", another_user.id) |
108 |
| - .version("1.0.0") |
109 |
| - .expect_build(conn); |
110 |
| - }); |
111 |
| - |
112 |
| - let response = token.yank("foo_not", "1.0.0"); |
113 |
| - assert_eq!(response.status(), StatusCode::OK); |
114 |
| - assert_eq!( |
115 |
| - response.into_json(), |
116 |
| - json!({ "errors": [{ "detail": "must already be an owner to yank or unyank" }] }) |
117 |
| - ); |
118 |
| -} |
119 |
| - |
120 | 63 | #[test]
|
121 | 64 | fn yank_max_version() {
|
122 | 65 | let (_, anon, _, token) = TestApp::full().with_token();
|
@@ -200,48 +143,3 @@ fn publish_after_yank_max_version() {
|
200 | 143 | let json = anon.show_crate("fyk_max");
|
201 | 144 | assert_eq!(json.krate.max_version, "2.0.0");
|
202 | 145 | }
|
203 |
| - |
204 |
| -#[test] |
205 |
| -fn yank_records_an_audit_action() { |
206 |
| - let (_, anon, _, token) = TestApp::full().with_token(); |
207 |
| - |
208 |
| - // Upload a new crate, putting it in the git index |
209 |
| - let crate_to_publish = PublishBuilder::new("fyk"); |
210 |
| - token.publish_crate(crate_to_publish).good(); |
211 |
| - |
212 |
| - // Yank it |
213 |
| - token.yank("fyk", "1.0.0").good(); |
214 |
| - |
215 |
| - // Make sure it has one publish and one yank audit action |
216 |
| - let json = anon.show_version("fyk", "1.0.0"); |
217 |
| - let actions = json.version.audit_actions; |
218 |
| - |
219 |
| - assert_eq!(actions.len(), 2); |
220 |
| - let action = &actions[1]; |
221 |
| - assert_eq!(action.action, "yank"); |
222 |
| - assert_eq!(action.user.id, token.as_model().user_id); |
223 |
| -} |
224 |
| - |
225 |
| -#[test] |
226 |
| -fn unyank_records_an_audit_action() { |
227 |
| - let (_, anon, _, token) = TestApp::full().with_token(); |
228 |
| - |
229 |
| - // Upload a new crate |
230 |
| - let crate_to_publish = PublishBuilder::new("fyk"); |
231 |
| - token.publish_crate(crate_to_publish).good(); |
232 |
| - |
233 |
| - // Yank version 1.0.0 |
234 |
| - token.yank("fyk", "1.0.0").good(); |
235 |
| - |
236 |
| - // Unyank version 1.0.0 |
237 |
| - token.unyank("fyk", "1.0.0").good(); |
238 |
| - |
239 |
| - // Make sure it has one publish, one yank, and one unyank audit action |
240 |
| - let json = anon.show_version("fyk", "1.0.0"); |
241 |
| - let actions = json.version.audit_actions; |
242 |
| - |
243 |
| - assert_eq!(actions.len(), 3); |
244 |
| - let action = &actions[2]; |
245 |
| - assert_eq!(action.action, "unyank"); |
246 |
| - assert_eq!(action.user.id, token.as_model().user_id); |
247 |
| -} |
0 commit comments