Skip to content

Commit 5bc7298

Browse files
authored
controllers/token: Remove obsolete content_length() check (#5873)
We have a global request body size limit these days, so this request handler specific check is somewhat redundant now.
1 parent 90db973 commit 5bc7298

File tree

2 files changed

+0
-19
lines changed

2 files changed

+0
-19
lines changed

src/controllers/token.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,6 @@ pub async fn new(mut req: ConduitRequest) -> AppResult<Json<Value>> {
4040
api_token: NewApiToken,
4141
}
4242

43-
let max_size = 2000;
44-
let length = req.content_length();
45-
46-
if length > max_size {
47-
return Err(bad_request(&format!("max content length is: {max_size}")));
48-
}
49-
5043
let new: NewApiTokenRequest = json::from_reader(req.body_mut())
5144
.map_err(|e| bad_request(&format!("invalid new token request: {e:?}")))?;
5245

src/tests/routes/me/tokens/create.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,6 @@ fn create_token_no_name() {
4141
);
4242
}
4343

44-
#[test]
45-
fn create_token_long_body() {
46-
let (_, _, user) = TestApp::init().with_user();
47-
let too_big = &[5; 5192]; // Send a request with a 5kB body of 5's
48-
let response = user.put::<()>("/api/v1/me/tokens", too_big);
49-
assert_eq!(response.status(), StatusCode::BAD_REQUEST);
50-
assert_eq!(
51-
response.into_json(),
52-
json!({ "errors": [{ "detail": "max content length is: 2000" }] })
53-
);
54-
}
55-
5644
#[test]
5745
fn create_token_exceeded_tokens_per_user() {
5846
let (app, _, user) = TestApp::init().with_user();

0 commit comments

Comments
 (0)