1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-08-06 06:02:40 +03:00

Fix mas-cli

This does a few things:

 - move `bytes` to workspace dependencies
 - write an hyper-based transport for Sentry
 - ignore OTEL errors related to propagations
 - fix everything else in mas-cli
This commit is contained in:
Quentin Gliech
2024-07-02 15:12:35 +02:00
parent dafc781957
commit 798ca90241
13 changed files with 104 additions and 111 deletions

View File

@@ -1,4 +1,4 @@
// Copyright 2022 The Matrix.org Foundation C.I.C.
// Copyright 2022-2024 The Matrix.org Foundation C.I.C.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -14,6 +14,7 @@
use clap::Parser;
use figment::Figment;
use http_body_util::BodyExt;
use hyper::{Response, Uri};
use mas_config::{ConfigurationSection, PolicyConfig};
use mas_handlers::HttpClientFactory;
@@ -79,7 +80,7 @@ impl Options {
let mut client = http_client_factory.client("debug");
let request = hyper::Request::builder()
.uri(url)
.body(hyper::Body::empty())?;
.body(axum::body::Body::empty())?;
let response = client.ready().await?.call(request).await?;
let (parts, body) = response.into_parts();
@@ -88,7 +89,7 @@ impl Options {
print_headers(&parts);
}
let mut body = hyper::body::aggregate(body).await?;
let mut body = body.collect().await?.to_bytes();
let mut stdout = tokio::io::stdout();
stdout.write_all_buf(&mut body).await?;
}
@@ -105,7 +106,7 @@ impl Options {
.json_response();
let request = hyper::Request::builder()
.uri(url)
.body(hyper::Body::empty())?;
.body(axum::body::Body::empty())?;
let response: Response<serde_json::Value> =
client.ready().await?.call(request).await?;

View File

@@ -68,7 +68,7 @@ This means some clients will refuse to use it."#
let request = hyper::Request::builder()
.uri(&well_known_uri)
.body(hyper::Body::empty())?;
.body(axum::body::Body::empty())?;
let result = client.ready().await?.call(request).await;
let expected_well_known = serde_json::json!({
@@ -180,7 +180,7 @@ Error details: {e}
let client_versions = hs_api.join("/_matrix/client/versions")?;
let request = hyper::Request::builder()
.uri(client_versions.as_str())
.body(hyper::Body::empty())?;
.body(axum::body::Body::empty())?;
let result = client.ready().await?.call(request).await;
let can_reach_cs = match result {
Ok(response) => {
@@ -234,7 +234,7 @@ Error details: {e}
"Bearer averyinvalidtokenireallyhopethisisnotvalid",
)
.uri(whoami.as_str())
.body(hyper::Body::empty())?;
.body(axum::body::Body::empty())?;
let result = client.ready().await?.call(request).await;
match result {
Ok(response) => {
@@ -284,7 +284,7 @@ Error details: {e}
let server_version = hs_api.join("/_synapse/admin/v1/server_version")?;
let request = hyper::Request::builder()
.uri(server_version.as_str())
.body(hyper::Body::empty())?;
.body(axum::body::Body::empty())?;
let result = client.ready().await?.call(request).await;
match result {
Ok(response) => {
@@ -313,7 +313,7 @@ Error details: {e}
let request = hyper::Request::builder()
.uri(background_updates.as_str())
.header("Authorization", format!("Bearer {admin_token}"))
.body(hyper::Body::empty())?;
.body(axum::body::Body::empty())?;
let result = client.ready().await?.call(request).await;
match result {
Ok(response) => {
@@ -361,7 +361,7 @@ Error details: {e}
let compat_login = compat_login.as_str();
let request = hyper::Request::builder()
.uri(compat_login)
.body(hyper::Body::empty())?;
.body(axum::body::Body::empty())?;
let result = client.ready().await?.call(request).await;
match result {
Ok(response) => {