Skip to content

Commit

Permalink
Upgrade all deps
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Nov 18, 2024
1 parent 58087ac commit 65e8d43
Show file tree
Hide file tree
Showing 10 changed files with 731 additions and 518 deletions.
1,120 changes: 661 additions & 459 deletions Cargo.lock

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,36 @@ freighter-fs-index = { path = "crates/freighter-fs-index", version = "1.0.0" }
freighter-server = { path = "crates/freighter-server", version = "1.0.0" }
freighter-storage = { path = "crates/freighter-storage", version = "1.0.0" }

anyhow = "1.0.79"
async-trait = "0.1.81"
aws-credential-types = "1.2.0"
aws-sdk-s3 = "1.44.0"
axum = { version = "0.6.20", default-features = false }
axum-extra = { version = "0.7.7", features = ["json-lines"] }
anyhow = "1.0.93"
async-trait = "0.1.83"
aws-credential-types = "1.2.1"
aws-sdk-s3 = "1.61.0"
axum = { version = "0.7.9", default-features = false }
axum-extra = { version = "0.9.6", features = ["json-lines"] }
base64 = "0.22"
bytes = "1.7.1"
chrono = { version = "0.4.38", default-features = false, features = ["std", "serde"] }
clap = { version = "4.5", default-features = false }
deadpool-postgres = { version = "0.14.0", features = ["serde"] }
futures-util = { version = "0.3.30", default-features = false }
hyper = { version = "0.14.30", default-features = false }
metrics = "0.23.0"
metrics-exporter-prometheus = { version = "0.15.0", default-features = false, features = ["http-listener"] }
hyper = { version = "1.5.0", default-features = false }
metrics = "0.24.0"
metrics-exporter-prometheus = { version = "0.16.0", default-features = false, features = ["http-listener"] }
postgres-types = "0.2.7"
rand = { version = "0.8.5", features = ["min_const_gen"] }
reqwest = { version = "0.11.23", default-features = false, features = ["json"] }
semver = { version = "1.0.21", features = ["serde"] }
serde = { version = "1.0.208", features = ["derive"] }
reqwest = { version = "0.12.9", default-features = false, features = ["json"] }
semver = { version = "1.0.23", features = ["serde"] }
serde = { version = "1.0.215", features = ["derive"] }
serde_json = "1.0.125"
serde_yaml = "0.9.34"
sha2 = "0.10.8"
hmac = "0.12.1" # must share digest with sha2
tempfile = "3.9.0"
thiserror = "1.0.56"
tokio = { version = "1.35.1", features = ["rt-multi-thread", "macros", "signal", "sync"] }
tokio-stream = { version = "0.1.14", default-features = false }
tower = { version = "0.4.13", default-features = false }
tower-http = "0.4.4"
thiserror = "2.0.3"
tokio = { version = "1.41.1", features = ["rt-multi-thread", "macros", "signal", "sync"] }
tokio-stream = { version = "0.1.16", default-features = false }
tower = { version = "0.5.1", default-features = false }
tower-http = "0.6.1"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", default-features = false, features = ["std", "fmt"] }

Expand Down
2 changes: 1 addition & 1 deletion crates/freighter-auth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async-trait = { workspace = true }
axum = { workspace = true }
cookie = { version = "0.18.1", optional = true }
deadpool-postgres = { workspace = true, optional = true }
http = "0.2.11"
http = "1.1.0"
jsonwebtoken = { version = "9.3.0", optional = true }
rand = { workspace = true }
reqwest = { workspace = true, optional = true, default-features = false, features = ["json", "default-tls"] }
Expand Down
4 changes: 2 additions & 2 deletions crates/freighter-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ thiserror = { workspace = true }
# bin only
tokio = { workspace = true, optional = true }
clap = { workspace = true, optional = true, features = ["std", "env", "derive", "cargo", "help", "wrap_help", "usage"] }
crate_untar = { version = "1.0.0-rc.1", optional = true }
cargo_toml = { version = "0.20.4", optional = true }
crate_untar = { version = "1.0.0-rc.2", optional = true }
cargo_toml = { version = "0.20.5", optional = true }

[features]
binary = ["dep:tokio", "dep:clap", "dep:crate_untar", "dep:cargo_toml", "reqwest/default-tls"]
Expand Down
4 changes: 2 additions & 2 deletions crates/freighter-server/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use axum::routing::{delete, get, post, put};
use axum::{Form, Json, Router};
use freighter_api_types::auth::request::AuthForm;
use freighter_api_types::index::request::{Publish, SearchQuery};
use freighter_api_types::index::response::{CompletedPublication, YankResult, SearchResults};
use freighter_api_types::index::response::{CompletedPublication, SearchResults, YankResult};
use freighter_api_types::index::{IndexError, IndexProvider};
use freighter_api_types::ownership::response::{ChangedOwnership, OwnerList};
use freighter_api_types::storage::{StorageError, StorageProvider};
use freighter_api_types::ownership::response::{OwnerList, ChangedOwnership};
use freighter_auth::{AuthError, AuthProvider};
use metrics::counter;
use semver::Version;
Expand Down
8 changes: 4 additions & 4 deletions crates/freighter-server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use axum::body::Body;
use axum::extract::{DefaultBodyLimit, MatchedPath, Query, State};
use axum::http::{HeaderMap, HeaderValue, Request, StatusCode, header};
use axum::http::{header, HeaderMap, HeaderValue, Request, StatusCode};
use axum::middleware::{from_fn, Next};
use axum::response::{Html, IntoResponse, Response};
use axum::routing::get;
Expand Down Expand Up @@ -128,7 +128,7 @@ where
.layer(from_fn(metrics_layer))
}

async fn metrics_layer<B>(request: Request<B>, next: Next<B>) -> Response {
async fn metrics_layer(request: Request<Body>, next: Next) -> Response {
let timer = Instant::now();

let path = if let Some(path) = request.extensions().get::<MatchedPath>() {
Expand All @@ -149,10 +149,10 @@ async fn metrics_layer<B>(request: Request<B>, next: Next<B>) -> Response {
response
}

async fn x_powered_by<B>(request: Request<B>, next: Next<B>) -> Response {
async fn x_powered_by(request: Request<Body>, next: Next) -> Response {
let mut response = next.run(request).await;
response.headers_mut().insert("x-powered-by", HeaderValue::from_static(concat!("freighter/", env!("CARGO_PKG_VERSION"))));
response.headers_mut().insert(header::SERVER, HeaderValue::from_static("axum/0.6"));
response.headers_mut().insert(header::SERVER, HeaderValue::from_static("axum/0.7"));
response
}

Expand Down
27 changes: 13 additions & 14 deletions crates/freighter-server/tests/api.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
pub mod common;

use crate::common::{
utils::{crate_version, generate_crate_payload},
MockIndexProvider, ServiceStateBuilder,
};
use crate::common::utils::{crate_version, generate_crate_payload};
use crate::common::{MockIndexProvider, ServiceStateBuilder};
use axum::body::{to_bytes, Body};

use axum::http::{Request, StatusCode};
use freighter_api_types::index::response::CrateVersion;
use freighter_server::{api, router};
use hyper::{header::AUTHORIZATION, Body};
use hyper::header::AUTHORIZATION;
use serde_json::Value;
use std::collections::BTreeMap;
use tower::ServiceExt;
Expand All @@ -34,7 +33,7 @@ async fn publish_crate() {
.uri("/new")
.method("PUT")
.header(AUTHORIZATION, TOKEN)
.body(payload.into())
.body(Body::from(payload))
.unwrap(),
)
.await
Expand Down Expand Up @@ -62,7 +61,7 @@ async fn publish_crate_auth_denied() {
.uri("/new")
.method("PUT")
.header(AUTHORIZATION, "1234")
.body(payload.into())
.body(Body::from(payload))
.unwrap(),
)
.await
Expand Down Expand Up @@ -145,7 +144,7 @@ async fn list_all_crates() {

assert_eq!(response.status(), StatusCode::OK);

let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
let body = to_bytes(response.into_body(), 100_000).await.unwrap();
let value: Value = serde_json::from_slice(&body).unwrap();
assert_eq!(
value,
Expand Down Expand Up @@ -226,7 +225,7 @@ async fn one_char_crate_name() {
assert_eq!(response.status(), StatusCode::OK);

// only one version present, this should deserialize
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
let body = to_bytes(response.into_body(), 100_000).await.unwrap();
let value: CrateVersion = serde_json::from_slice(&body).unwrap();

assert_eq!("a", value.name);
Expand Down Expand Up @@ -263,7 +262,7 @@ async fn two_char_crate_name() {
assert_eq!(response.status(), StatusCode::OK);

// only one version present, this should deserialize
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
let body = to_bytes(response.into_body(), 100_000).await.unwrap();
let value: CrateVersion = serde_json::from_slice(&body).unwrap();

assert_eq!("aa", value.name);
Expand Down Expand Up @@ -300,7 +299,7 @@ async fn three_char_crate_name() {
assert_eq!(response.status(), StatusCode::OK);

// only one version present, this should deserialize
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
let body = to_bytes(response.into_body(), 100_000).await.unwrap();
let value: CrateVersion = serde_json::from_slice(&body).unwrap();

assert_eq!("aaa", value.name);
Expand Down Expand Up @@ -337,7 +336,7 @@ async fn four_char_crate_name() {
assert_eq!(response.status(), StatusCode::OK);

// only one version present, this should deserialize
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
let body = to_bytes(response.into_body(), 100_000).await.unwrap();
let value: CrateVersion = serde_json::from_slice(&body).unwrap();

assert_eq!("aaaa", value.name);
Expand Down Expand Up @@ -374,7 +373,7 @@ async fn hyphen_crate_name() {
assert_eq!(response.status(), StatusCode::OK);

// only one version present, this should deserialize
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
let body = to_bytes(response.into_body(), 100_000).await.unwrap();
let value: CrateVersion = serde_json::from_slice(&body).unwrap();

assert_eq!("aa-aa", value.name);
Expand Down Expand Up @@ -411,7 +410,7 @@ async fn underscore_crate_name() {
assert_eq!(response.status(), StatusCode::OK);

// only one version present, this should deserialize
let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
let body = to_bytes(response.into_body(), 100_000).await.unwrap();
let value: CrateVersion = serde_json::from_slice(&body).unwrap();

assert_eq!("aa_aa", value.name);
Expand Down
31 changes: 21 additions & 10 deletions crates/freighter-server/tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
#![cfg(feature = "test_e2e")]
pub mod common;

use std::collections::HashMap;
use std::env::var;

use anyhow::Result;
use axum::{routing::IntoMakeService, Router, Server};
use deadpool_postgres::Config;
use freighter_api_types::index::request::{Publish, PublishDependency};
use freighter_api_types::index::IndexProvider;
Expand All @@ -17,8 +13,15 @@ use freighter_fs_index::FsIndexProvider;
use freighter_pg_index::PgIndexProvider;
use freighter_server::ServiceConfig;
use freighter_storage::s3_client::S3StorageProvider;
use hyper::{server::conn::AddrIncoming, Body};
use semver::{Version, VersionReq};
use std::collections::HashMap;
use std::env::var;
use std::future::Future;
use std::net::SocketAddr;
use std::time::Duration;
use tokio::net::TcpListener;
use tokio::sync::oneshot;
use tokio::time::timeout;
use tracing_subscriber::util::SubscriberInitExt;

#[derive(Clone)]
Expand Down Expand Up @@ -65,7 +68,7 @@ fn server(
config: &TestServerConfig,
index_client: impl IndexProvider + Send + 'static,
auth_client: impl AuthProvider + Send + Sync + 'static,
) -> Result<Server<AddrIncoming, IntoMakeService<Router<(), Body>>>> {
) -> Result<(oneshot::Receiver<()>, impl Future<Output = ()>)> {
let storage_client = S3StorageProvider::new(
&config.bucket_name,
&config.bucket_endpoint_url,
Expand All @@ -74,8 +77,9 @@ fn server(
&config.bucket_access_key_secret,
);

let addr: SocketAddr = config.server_addr.parse()?;
let service = ServiceConfig {
address: config.server_addr.parse()?,
address: addr.clone(),
download_endpoint: format!(
"http://{}/downloads/{{crate}}/{{version}}",
config.server_addr
Expand All @@ -88,8 +92,13 @@ fn server(
};

let router = freighter_server::router(service, index_client, storage_client, auth_client);

Ok(axum::Server::bind(&config.server_addr.parse()?).serve(router.into_make_service()))
let service = router.into_make_service();
let (tx, rx) = oneshot::channel();
Ok((rx, async move {
let listener = TcpListener::bind(addr).await.unwrap();
tx.send(()).unwrap();
axum::serve(listener, service).await.unwrap();
}))
}

#[tokio::test]
Expand Down Expand Up @@ -175,7 +184,9 @@ async fn e2e_publish_crate_in_index(
};

// 0. Start Freighter
let server_spawned = tokio::spawn(server(&config, index_client, auth_client).unwrap());
let (listening, server_future) = server(&config, index_client, auth_client).unwrap();
let server_spawned = tokio::spawn(timeout(Duration::from_secs(5), server_future));
let _ = timeout(Duration::from_secs(5), listening).await;

let mut freighter_client =
Client::new(&format!("http://{server_addr}/index"), default_token).await.unwrap();
Expand Down
14 changes: 7 additions & 7 deletions crates/freighter-server/tests/index.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
pub mod common;

use crate::common::{utils::crate_version, MockIndexProvider, ServiceStateBuilder};
use crate::common::utils::crate_version;
use crate::common::{MockIndexProvider, ServiceStateBuilder};
use axum::body::to_bytes;

use axum::{
body::Body,
http::{Request, StatusCode},
};
use axum::body::Body;
use axum::http::{Request, StatusCode};
use freighter_server::index;
use std::collections::BTreeMap;
use tower::ServiceExt;
Expand All @@ -29,7 +29,7 @@ async fn index_config_endpoint() {

assert_eq!(response.status(), StatusCode::OK);

let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
let body = to_bytes(response.into_body(), 100_000).await.unwrap();
let body = std::str::from_utf8(&body).unwrap();
assert_eq!(
body,
Expand Down Expand Up @@ -89,7 +89,7 @@ async fn valid_crate() {

assert_eq!(response.status(), StatusCode::OK);

let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
let body = to_bytes(response.into_body(), 100_000).await.unwrap();
let body = std::str::from_utf8(&body).unwrap();
assert_eq!(
body,
Expand Down
5 changes: 3 additions & 2 deletions crates/freighter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ cfg_if::cfg_if! {
use freighter_storage::s3_client::S3StorageProvider;
use metrics_exporter_prometheus::PrometheusBuilder;
use std::fs::read_to_string;
use tokio::net::TcpListener;

mod cli;
mod config;
Expand Down Expand Up @@ -89,8 +90,8 @@ async fn main() -> anyhow::Result<()> {
std::any::type_name::<SelectedAuthProvider>()
);

axum::Server::bind(&addr)
.serve(router.into_make_service())
let listener = TcpListener::bind(addr).await?;
axum::serve(listener, router.into_make_service())
.with_graceful_shutdown(shutdown_signal())
.await
.context("Freighter server exited with error")?;
Expand Down

0 comments on commit 65e8d43

Please sign in to comment.