@@ -31,18 +31,18 @@ async fn body_json(body: Body) -> Value {
3131 serde_json:: from_slice ( & body_bytes ( body) . await ) . expect ( "body parses as JSON" )
3232}
3333
34- fn put_json ( path : & str , body : Value ) -> Request < Body > {
34+ fn put_json ( path : & str , body : & Value ) -> Request < Body > {
3535 Request :: put ( path)
3636 . header ( "content-type" , "application/json" )
37- . body ( Body :: from ( serde_json:: to_vec ( & body) . unwrap ( ) ) )
37+ . body ( Body :: from ( serde_json:: to_vec ( body) . unwrap ( ) ) )
3838 . unwrap ( )
3939}
4040
41- fn put_json_with_token ( path : & str , body : Value , token : & str ) -> Request < Body > {
41+ fn put_json_with_token ( path : & str , body : & Value , token : & str ) -> Request < Body > {
4242 Request :: put ( path)
4343 . header ( "content-type" , "application/json" )
4444 . header ( "Authorization" , format ! ( "Bearer {token}" ) )
45- . body ( Body :: from ( serde_json:: to_vec ( & body) . unwrap ( ) ) )
45+ . body ( Body :: from ( serde_json:: to_vec ( body) . unwrap ( ) ) )
4646 . unwrap ( )
4747}
4848
@@ -56,7 +56,7 @@ async fn add_user_and_get_token(app: axum::Router, username: &str, password: &st
5656 "type" : "user" ,
5757 "roles" : [ ] ,
5858 } ) ;
59- let response = app. oneshot ( put_json ( & path, body) ) . await . unwrap ( ) ;
59+ let response = app. oneshot ( put_json ( & path, & body) ) . await . unwrap ( ) ;
6060 assert_eq ! ( response. status( ) , StatusCode :: CREATED ) ;
6161 let payload = body_json ( response. into_body ( ) ) . await ;
6262 payload[ "token" ] . as_str ( ) . expect ( "token in response" ) . to_string ( )
@@ -106,8 +106,11 @@ async fn batch_publish_writes_every_package_in_one_request() {
106106 publish_doc( "batch-b" , "2.0.0" , bytes_b) ,
107107 ] ,
108108 } ) ;
109- let response =
110- app. clone ( ) . oneshot ( put_json_with_token ( "/-/pnpm/v1/publish" , body, & token) ) . await . unwrap ( ) ;
109+ let response = app
110+ . clone ( )
111+ . oneshot ( put_json_with_token ( "/-/pnpm/v1/publish" , & body, & token) )
112+ . await
113+ . unwrap ( ) ;
111114 assert_eq ! ( response. status( ) , StatusCode :: CREATED ) ;
112115 let payload = body_json ( response. into_body ( ) ) . await ;
113116 assert_eq ! ( payload[ "ok" ] , true ) ;
@@ -175,8 +178,11 @@ async fn batch_publish_supports_scoped_packages_with_libnpmpublish_attachment_na
175178 } ,
176179 } ] ,
177180 } ) ;
178- let response =
179- app. clone ( ) . oneshot ( put_json_with_token ( "/-/pnpm/v1/publish" , body, & token) ) . await . unwrap ( ) ;
181+ let response = app
182+ . clone ( )
183+ . oneshot ( put_json_with_token ( "/-/pnpm/v1/publish" , & body, & token) )
184+ . await
185+ . unwrap ( ) ;
180186 assert_eq ! ( response. status( ) , StatusCode :: CREATED ) ;
181187
182188 // On disk: canonical `<basename>-<version>.tgz` under the scope dir.
@@ -215,7 +221,7 @@ async fn anonymous_batch_publish_is_rejected() {
215221 let app = router ( static_config ( storage. clone ( ) ) ) ;
216222
217223 let body = json ! ( { "packages" : [ publish_doc( "anon-batch" , "1.0.0" , b"bytes" ) ] } ) ;
218- let response = app. oneshot ( put_json ( "/-/pnpm/v1/publish" , body) ) . await . unwrap ( ) ;
224+ let response = app. oneshot ( put_json ( "/-/pnpm/v1/publish" , & body) ) . await . unwrap ( ) ;
219225 assert_eq ! ( response. status( ) , StatusCode :: UNAUTHORIZED ) ;
220226 assert ! ( !storage. join( "anon-batch" ) . exists( ) ) ;
221227}
@@ -236,7 +242,7 @@ async fn batch_publish_rolls_back_every_package_when_one_fails_integrity() {
236242
237243 let body = json ! ( { "packages" : [ good, bad] } ) ;
238244 let response =
239- app. oneshot ( put_json_with_token ( "/-/pnpm/v1/publish" , body, & token) ) . await . unwrap ( ) ;
245+ app. oneshot ( put_json_with_token ( "/-/pnpm/v1/publish" , & body, & token) ) . await . unwrap ( ) ;
240246 assert_eq ! ( response. status( ) , StatusCode :: BAD_REQUEST ) ;
241247 let body_text = String :: from_utf8 ( body_bytes ( response. into_body ( ) ) . await ) . unwrap ( ) ;
242248 assert ! ( body_text. contains( "EINTEGRITY" ) , "error should carry EINTEGRITY: {body_text}" ) ;
@@ -270,7 +276,7 @@ async fn batch_publish_rejects_duplicate_package_names() {
270276 ] ,
271277 } ) ;
272278 let response =
273- app. oneshot ( put_json_with_token ( "/-/pnpm/v1/publish" , body, & token) ) . await . unwrap ( ) ;
279+ app. oneshot ( put_json_with_token ( "/-/pnpm/v1/publish" , & body, & token) ) . await . unwrap ( ) ;
274280 assert_eq ! ( response. status( ) , StatusCode :: BAD_REQUEST ) ;
275281 let body_text = String :: from_utf8 ( body_bytes ( response. into_body ( ) ) . await ) . unwrap ( ) ;
276282 assert ! ( body_text. contains( "duplicate package" ) , "got: {body_text}" ) ;
@@ -286,7 +292,7 @@ async fn batch_publish_rejects_bodies_without_a_packages_array() {
286292 for body in [ json ! ( { } ) , json ! ( { "packages" : [ ] } ) , json ! ( { "packages" : "nope" } ) , json ! ( [ ] ) ] {
287293 let response = app
288294 . clone ( )
289- . oneshot ( put_json_with_token ( "/-/pnpm/v1/publish" , body. clone ( ) , & token) )
295+ . oneshot ( put_json_with_token ( "/-/pnpm/v1/publish" , & body, & token) )
290296 . await
291297 . unwrap ( ) ;
292298 assert_eq ! ( response. status( ) , StatusCode :: BAD_REQUEST , "body: {body}" ) ;
@@ -301,7 +307,7 @@ async fn batch_publish_rejects_entries_without_a_name() {
301307
302308 let body = json ! ( { "packages" : [ { "versions" : { } } ] } ) ;
303309 let response =
304- app. oneshot ( put_json_with_token ( "/-/pnpm/v1/publish" , body, & token) ) . await . unwrap ( ) ;
310+ app. oneshot ( put_json_with_token ( "/-/pnpm/v1/publish" , & body, & token) ) . await . unwrap ( ) ;
305311 assert_eq ! ( response. status( ) , StatusCode :: BAD_REQUEST ) ;
306312}
307313
@@ -317,14 +323,14 @@ async fn batch_publish_merges_with_previously_published_versions() {
317323 let first = json ! ( { "packages" : [ publish_doc( "merge-pkg" , "1.0.0" , b"v1" ) ] } ) ;
318324 let response = app
319325 . clone ( )
320- . oneshot ( put_json_with_token ( "/-/pnpm/v1/publish" , first, & token) )
326+ . oneshot ( put_json_with_token ( "/-/pnpm/v1/publish" , & first, & token) )
321327 . await
322328 . unwrap ( ) ;
323329 assert_eq ! ( response. status( ) , StatusCode :: CREATED ) ;
324330
325331 let second = json ! ( { "packages" : [ publish_doc( "merge-pkg" , "2.0.0" , b"v2" ) ] } ) ;
326332 let response =
327- app. oneshot ( put_json_with_token ( "/-/pnpm/v1/publish" , second, & token) ) . await . unwrap ( ) ;
333+ app. oneshot ( put_json_with_token ( "/-/pnpm/v1/publish" , & second, & token) ) . await . unwrap ( ) ;
328334 assert_eq ! ( response. status( ) , StatusCode :: CREATED ) ;
329335
330336 let packument: Value =
0 commit comments