Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.

Commit dcb9bde

Browse files
committed
Remove the client features from mas-oidc-client and replace it in tests
1 parent ea85be5 commit dcb9bde

File tree

6 files changed

+20
-105
lines changed

6 files changed

+20
-105
lines changed

Cargo.lock

Lines changed: 1 addition & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/http/src/layers/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::time::Duration;
1616

1717
use headers::{ContentLength, HeaderMapExt, Host, UserAgent};
1818
use http::{header::USER_AGENT, HeaderValue, Request, Response};
19-
use hyper::client::connect::HttpInfo;
19+
use hyper_util::client::legacy::connect::HttpInfo;
2020
use mas_tower::{
2121
DurationRecorderLayer, DurationRecorderService, EnrichSpan, InFlightCounterLayer,
2222
InFlightCounterService, MakeSpan, MetricsAttributes, TraceContextLayer, TraceContextService,

crates/oidc-client/Cargo.toml

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,7 @@ repository.workspace = true
1212
workspace = true
1313

1414
[features]
15-
default = ["hyper", "keystore"]
16-
hyper = [
17-
"dep:http-body",
18-
"dep:hyper",
19-
"dep:hyper-rustls",
20-
"dep:rustls",
21-
"dep:rustls-platform-verifier",
22-
"dep:tower-http",
23-
"tower/limit",
24-
]
15+
default = ["keystore"]
2516
keystore = ["dep:mas-keystore"]
2617

2718
[dependencies]
@@ -50,22 +41,13 @@ mas-jose.workspace = true
5041
mas-keystore = { workspace = true, optional = true }
5142
oauth2-types.workspace = true
5243

53-
# Default http service
54-
http-body = { workspace = true, optional = true }
55-
hyper = { workspace = true, optional = true }
56-
hyper-rustls = { workspace = true, optional = true }
57-
rustls = { workspace = true, optional = true }
58-
rustls-platform-verifier = { workspace = true, optional = true }
59-
60-
[dependencies.tower-http]
61-
version = "0.4.4"
62-
features = ["follow-redirect", "set-header", "timeout", "map-request-body", "util"]
63-
optional = true
64-
6544
[dev-dependencies]
6645
assert_matches = "1.5.0"
6746
bitflags = "2.6.0"
6847
mas-keystore.workspace = true
6948
rand_chacha = "0.3.1"
7049
tokio.workspace = true
7150
wiremock = "0.6.0"
51+
http-body-util.workspace = true
52+
53+
mas-http = { workspace = true, features = ["client"] }

crates/oidc-client/src/http_service/mod.rs renamed to crates/oidc-client/src/http_service.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,4 @@
1515
//! Reexports of traits to implement to provide a custom HTTP service for
1616
//! `Client`.
1717
18-
#[cfg(feature = "hyper")]
19-
pub mod hyper;
20-
2118
pub use mas_http::{BoxCloneSyncService, HttpService};

crates/oidc-client/src/http_service/hyper.rs

Lines changed: 0 additions & 69 deletions
This file was deleted.

crates/oidc-client/tests/it/main.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use std::collections::HashMap;
1616

1717
use chrono::{DateTime, Duration, Utc};
18+
use http_body_util::Full;
19+
use mas_http::{BodyToBytesResponseLayer, BoxCloneSyncService};
1820
use mas_iana::{jose::JsonWebSignatureAlg, oauth::OAuthClientAuthenticationMethod};
1921
use mas_jose::{
2022
claims::{self, hash_token},
@@ -24,7 +26,7 @@ use mas_jose::{
2426
};
2527
use mas_keystore::{JsonWebKey, JsonWebKeySet, Keystore, PrivateKey};
2628
use mas_oidc_client::{
27-
http_service::{hyper::hyper_service, HttpService},
29+
http_service::HttpService,
2830
types::{
2931
client_credentials::{ClientCredentials, JwtSigningFn, JwtSigningMethod},
3032
IdToken,
@@ -34,6 +36,10 @@ use rand::{
3436
distributions::{Alphanumeric, DistString},
3537
SeedableRng,
3638
};
39+
use tower::{
40+
util::{MapErrLayer, MapRequestLayer},
41+
BoxError, Layer,
42+
};
3743
use url::Url;
3844
use wiremock::MockServer;
3945

@@ -58,7 +64,13 @@ fn now() -> DateTime<Utc> {
5864
}
5965

6066
async fn init_test() -> (HttpService, MockServer, Url) {
61-
let http_service = hyper_service();
67+
let http_service = (
68+
MapErrLayer::new(BoxError::from),
69+
MapRequestLayer::new(|req: http::Request<_>| req.map(Full::new)),
70+
BodyToBytesResponseLayer,
71+
)
72+
.layer(mas_http::make_untraced_client());
73+
let http_service = BoxCloneSyncService::new(http_service);
6274
let mock_server = MockServer::start().await;
6375
let issuer = Url::parse(&mock_server.uri()).expect("Couldn't parse URL");
6476

0 commit comments

Comments
 (0)