httpd: Update /git test to use test helper fns

Update `axum` to 0.6.7 to be able to use fix in:
https://github.com/tokio-rs/axum/pull/1767

Signed-off-by: xphoniex <dj.2dixx@gmail.com>
This commit is contained in:
xphoniex
2023-02-22 17:06:32 +01:00
committed by Alexis Sellier
parent b0b94fea18
commit 8d5d84f31c
2 changed files with 7 additions and 17 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ logfmt = [
[dependencies]
anyhow = { version = "1" }
axum = { version = "0.6.2", default-features = false, features = ["headers", "json", "query", "tokio"] }
axum = { version = "0.6.7", default-features = false, features = ["headers", "json", "query", "tokio"] }
axum-auth = { version= "0.4.0", default-features = false, features = ["auth-bearer"] }
axum-server = { version = "0.4.4", default-features = false }
chrono = { version = "0.4.22" }
+6 -16
View File
@@ -197,29 +197,19 @@ async fn git_http_backend(
mod routes {
use std::net::SocketAddr;
use axum::body::Body;
use axum::extract::ConnectInfo;
use axum::http::Request;
use axum::http::{Method, StatusCode};
use tower::ServiceExt;
use axum::extract::connect_info::MockConnectInfo;
use axum::http::StatusCode;
use crate::test;
use crate::test::{self, get};
#[tokio::test]
async fn test_invalid_route_returns_404() {
let tmp = tempfile::tempdir().unwrap();
let ctx = test::seed(tmp.path());
let app = super::router(ctx.profile().to_owned());
let app = super::router(ctx.profile().to_owned())
.layer(MockConnectInfo(SocketAddr::from(([0, 0, 0, 0], 8080))));
let request = Request::builder()
.method(Method::GET)
.uri("/aa/a".to_string());
let mut request = request.body(Body::empty()).unwrap();
let socket_addr: SocketAddr = "127.0.0.1:8080".parse().unwrap();
request.extensions_mut().insert(ConnectInfo(socket_addr));
let response = app.oneshot(request).await.unwrap();
let response = get(&app, "/aa/a").await;
assert_eq!(response.status(), StatusCode::NOT_FOUND);
}