raw
1use axum::{
2 body::Body,
3 http::{Request, StatusCode},
4};
5use http_body_util::BodyExt as _;
6use tower::util::ServiceExt as _;
7
8fn main() {
9 bile::set_config(bile::config::Config::default().finalize().unwrap());
10
11 afl::fuzz!(|data: &[u8]| {
12 if let Ok(s) = std::str::from_utf8(data) {
13 if let Ok(uri) = http::Uri::try_from(s) {
14 let Ok(rt) = tokio::runtime::Runtime::new() else {
15 println!("failed to create tokio runtime");
16 return;
17 };
18
19 rt.block_on(async {
20 let Ok(req) = Request::builder().uri(uri).body(Body::empty()) else {
21 println!("failed to create http request");
22 return;
23 };
24
25 let Ok(res) = bile::routes().oneshot(req).await else {
26 println!("failed to send http request");
27 return;
28 };
29
30 assert_ne!(res.status(), StatusCode::INTERNAL_SERVER_ERROR);
31 });
32 }
33 }
34 });
35}
36