1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-08-07 17:03:01 +03:00

Upgrade clippy lints to 1.74.0 & fix warnings

This commit is contained in:
Quentin Gliech
2023-12-01 10:50:17 +01:00
parent 5b272dff08
commit df3ca5ae66
13 changed files with 147 additions and 114 deletions

View File

@@ -195,8 +195,8 @@ jobs:
- name: Install toolchain
run: |
rustup toolchain install 1.73.0
rustup default 1.73.0
rustup toolchain install 1.74.0
rustup default 1.74.0
rustup component add clippy
- name: Setup OPA

View File

@@ -8,7 +8,7 @@
# The Debian version and version name must be in sync
ARG DEBIAN_VERSION=12
ARG DEBIAN_VERSION_NAME=bookworm
ARG RUSTC_VERSION=1.73.0
ARG RUSTC_VERSION=1.74.0
# XXX: Upgrade to 0.10.0 blocked by https://github.com/ziglang/zig/issues/10915#issuecomment-1354548110
# XXX: Upgrade to 0.11.0 blocked by https://github.com/rust-cross/cargo-zigbuild/issues/162
ARG ZIG_VERSION=0.9.1

View File

@@ -248,10 +248,10 @@ impl Options {
.context("User not found")?;
let compat_sessions_ids: Vec<Uuid> = sqlx::query_scalar(
r#"
r"
SELECT compat_session_id FROM compat_sessions
WHERE user_id = $1 AND finished_at IS NULL
"#,
",
)
.bind(Uuid::from(user.id))
.fetch_all(&mut **repo)
@@ -276,12 +276,12 @@ impl Options {
}
let oauth2_sessions_ids: Vec<Uuid> = sqlx::query_scalar(
r#"
r"
SELECT oauth2_sessions.oauth2_session_id
FROM oauth2_sessions
INNER JOIN user_sessions USING (user_session_id)
WHERE user_sessions.user_id = $1 AND oauth2_sessions.finished_at IS NULL
"#,
",
)
.bind(Uuid::from(user.id))
.fetch_all(&mut **repo)
@@ -313,10 +313,10 @@ impl Options {
}
let user_sessions_ids: Vec<Uuid> = sqlx::query_scalar(
r#"
r"
SELECT user_session_id FROM user_sessions
WHERE user_id = $1 AND finished_at IS NULL
"#,
",
)
.bind(Uuid::from(user.id))
.fetch_all(&mut **repo)

View File

@@ -173,10 +173,10 @@ mod tests {
Jail::expect_with(|jail| {
jail.create_file(
"config.yaml",
r#"
r"
database:
uri: postgresql://user:password@host/database
"#,
",
)?;
let config = DatabaseConfig::load_from_file("config.yaml")?;

View File

@@ -85,11 +85,11 @@ mod tests {
Jail::expect_with(|jail| {
jail.create_file(
"config.yaml",
r#"
r"
matrix:
homeserver: matrix.org
secret: test
"#,
",
)?;
let config = MatrixConfig::load_from_file("config.yaml")?;

View File

@@ -225,7 +225,7 @@ impl ConfigurationSection for SecretsConfig {
kid: "abcdef".to_owned(),
password: None,
key: KeyOrFile::Key(
indoc::indoc! {r#"
indoc::indoc! {r"
-----BEGIN PRIVATE KEY-----
MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAymS2RkeIZo7pUeEN
QUGCG4GLJru5jzxomO9jiNr5D/oRcerhpQVc9aCpBfAAg4l4a1SmYdBzWqX0X5pU
@@ -236,7 +236,7 @@ impl ConfigurationSection for SecretsConfig {
tPQniMnrBtiN2NxqFXHCev/8Gpc8gAECIBcaPcF59qVeRmYrfqzKBxFm7LmTwlAl
Gh7BNzCeN+D6
-----END PRIVATE KEY-----
"#}
"}
.to_owned(),
),
};
@@ -244,13 +244,13 @@ impl ConfigurationSection for SecretsConfig {
kid: "ghijkl".to_owned(),
password: None,
key: KeyOrFile::Key(
indoc::indoc! {r#"
indoc::indoc! {r"
-----BEGIN PRIVATE KEY-----
MIGEAgEAMBAGByqGSM49AgEGBSuBBAAKBG0wawIBAQQgqfn5mYO/5Qq/wOOiWgHA
NaiDiepgUJ2GI5eq2V8D8nahRANCAARMK9aKUd/H28qaU+0qvS6bSJItzAge1VHn
OhBAAUVci1RpmUA+KdCL5sw9nadAEiONeiGr+28RYHZmlB9qXnjC
-----END PRIVATE KEY-----
"#}
"}
.to_owned(),
),
};

View File

@@ -46,6 +46,11 @@ pub trait ConfigurationSection: Sized + DeserializeOwned + Serialize {
/// export MAS_HTTP_ADDRESS=127.0.0.1:1234
/// matrix-authentication-service config generate
/// ```
///
/// # Errors
///
/// Returns an error if the configuration could not be generated or if the
/// existing configuration could not be loaded
async fn load_and_generate<R>(rng: R) -> anyhow::Result<Self>
where
R: Rng + Send,
@@ -62,6 +67,10 @@ pub trait ConfigurationSection: Sized + DeserializeOwned + Serialize {
}
/// Load configuration from a list of files and environment variables.
///
/// # Errors
///
/// Returns an error if the configuration could not be loaded
fn load_from_files<P>(paths: &[P]) -> Result<Self, FigmentError>
where
P: AsRef<Utf8Path>,
@@ -75,6 +84,10 @@ pub trait ConfigurationSection: Sized + DeserializeOwned + Serialize {
}
/// Load configuration from a file and environment variables.
///
/// # Errors
///
/// Returns an error if the configuration could not be loaded
fn load_from_file<P>(path: P) -> Result<Self, FigmentError>
where
P: AsRef<Utf8Path>,

View File

@@ -159,13 +159,13 @@ async fn test_anonymous_viewer(pool: PgPool) {
let state = TestState::from_pool(pool).await.unwrap();
let req = Request::post("/graphql").json(serde_json::json!({
"query": r#"
"query": r"
query {
viewer {
__typename
}
}
"#,
",
}));
let response = state.request(req).await;
@@ -199,7 +199,7 @@ async fn test_oauth2_viewer(pool: PgPool) {
let req = Request::post("/graphql")
.bearer(&access_token)
.json(serde_json::json!({
"query": r#"
"query": r"
query {
viewer {
__typename
@@ -210,7 +210,7 @@ async fn test_oauth2_viewer(pool: PgPool) {
}
}
}
"#,
",
}));
let response = state.request(req).await;
@@ -246,13 +246,13 @@ async fn test_oauth2_no_scope(pool: PgPool) {
let req = Request::post("/graphql")
.bearer(&access_token)
.json(serde_json::json!({
"query": r#"
"query": r"
query {
viewer {
__typename
}
}
"#,
",
}));
let response = state.request(req).await;
@@ -294,14 +294,14 @@ async fn test_oauth2_admin(pool: PgPool) {
let request = Request::post("/graphql")
.bearer(&access_token)
.json(serde_json::json!({
"query": r#"
"query": r"
query UserQuery($id: ID) {
user(id: $id) {
id
username
}
}
"#,
",
"variables": {
"id": format!("user:{id}", id = user2.id),
},
@@ -324,14 +324,14 @@ async fn test_oauth2_admin(pool: PgPool) {
let request = Request::post("/graphql")
.bearer(&access_token_admin)
.json(serde_json::json!({
"query": r#"
"query": r"
query UserQuery($id: ID) {
user(id: $id) {
id
username
}
}
"#,
",
"variables": {
"id": format!("user:{id}", id = user2.id),
},
@@ -392,7 +392,7 @@ async fn test_oauth2_client_credentials(pool: PgPool) {
let request = Request::post("/graphql")
.bearer(&access_token)
.json(serde_json::json!({
"query": r#"
"query": r"
query {
viewer {
__typename
@@ -402,7 +402,7 @@ async fn test_oauth2_client_credentials(pool: PgPool) {
__typename
}
}
"#,
",
}));
let response = state.request(request).await;
@@ -459,7 +459,7 @@ async fn test_oauth2_client_credentials(pool: PgPool) {
let request = Request::post("/graphql")
.bearer(&access_token)
.json(serde_json::json!({
"query": r#"
"query": r"
query {
viewer {
__typename
@@ -469,7 +469,7 @@ async fn test_oauth2_client_credentials(pool: PgPool) {
__typename
}
}
"#,
",
}));
let response = state.request(request).await;
@@ -535,14 +535,14 @@ async fn test_oauth2_client_credentials(pool: PgPool) {
let request = Request::post("/graphql")
.bearer(&access_token)
.json(serde_json::json!({
"query": r#"
"query": r"
mutation CreateSession($userId: String!, $scope: String!) {
createOauth2Session(input: {userId: $userId, permanent: true, scope: $scope}) {
accessToken
refreshToken
}
}
"#,
",
"variables": {
"userId": user_id,
"scope": "urn:matrix:org.matrix.msc2967.client:device:AABBCCDDEE urn:matrix:org.matrix.msc2967.client:api:* urn:synapse:admin:*"

View File

@@ -323,7 +323,7 @@ mod tests {
fn test_invalid_key_not_string() {
// This is invalid because the key is not a string
let mut context = Context::new("t".to_owned());
let ast = parse(r#"{{ t(5) }}"#, "invalid.txt").unwrap();
let ast = parse(r"{{ t(5) }}", "invalid.txt").unwrap();
let res = find_in_stmt(&mut context, &ast);
assert!(res.is_err());
@@ -343,7 +343,7 @@ mod tests {
fn test_invalid_key_missing() {
// This is invalid because the key argument is missing
let mut context = Context::new("t".to_owned());
let ast = parse(r#"{{ t() }}"#, "invalid.txt").unwrap();
let ast = parse(r"{{ t() }}", "invalid.txt").unwrap();
let res = find_in_stmt(&mut context, &ast);
assert!(res.is_err());

View File

@@ -14,6 +14,14 @@
use crate::traits::{EnumMember, Section};
fn raw_string(string: &str) -> String {
if string.contains('"') {
format!(r##"r#"{string}"#"##)
} else {
format!(r#"r"{string}""#)
}
}
pub fn struct_def(
f: &mut std::fmt::Formatter<'_>,
section: &Section,
@@ -187,14 +195,15 @@ impl schemars::JsonSchema for {} {{
if let Some(description) = &member.description {
write!(
f,
r##"
r#"
metadata: Some(Box::new(schemars::schema::Metadata {{
description: Some(
// ---
r#"{description}"#.to_owned(),
{}.to_owned(),
),
..Default::default()
}})),"##,
}})),"#,
raw_string(description),
)?;
}
@@ -211,10 +220,10 @@ impl schemars::JsonSchema for {} {{
writeln!(
f,
r##"
r#"
];
let description = r#"{}"#;
let description = {};
schemars::schema::SchemaObject {{
metadata: Some(Box::new(schemars::schema::Metadata {{
description: Some(description.to_owned()),
@@ -228,8 +237,8 @@ impl schemars::JsonSchema for {} {{
}}
.into()
}}
}}"##,
section.doc,
}}"#,
raw_string(section.doc),
)
}

View File

@@ -155,7 +155,7 @@ impl schemars::JsonSchema for JsonWebSignatureAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"HMAC using SHA-256"#.to_owned(),
r"HMAC using SHA-256".to_owned(),
),
..Default::default()
})),
@@ -168,7 +168,7 @@ impl schemars::JsonSchema for JsonWebSignatureAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"HMAC using SHA-384"#.to_owned(),
r"HMAC using SHA-384".to_owned(),
),
..Default::default()
})),
@@ -181,7 +181,7 @@ impl schemars::JsonSchema for JsonWebSignatureAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"HMAC using SHA-512"#.to_owned(),
r"HMAC using SHA-512".to_owned(),
),
..Default::default()
})),
@@ -194,7 +194,7 @@ impl schemars::JsonSchema for JsonWebSignatureAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"RSASSA-PKCS1-v1_5 using SHA-256"#.to_owned(),
r"RSASSA-PKCS1-v1_5 using SHA-256".to_owned(),
),
..Default::default()
})),
@@ -207,7 +207,7 @@ impl schemars::JsonSchema for JsonWebSignatureAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"RSASSA-PKCS1-v1_5 using SHA-384"#.to_owned(),
r"RSASSA-PKCS1-v1_5 using SHA-384".to_owned(),
),
..Default::default()
})),
@@ -220,7 +220,7 @@ impl schemars::JsonSchema for JsonWebSignatureAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"RSASSA-PKCS1-v1_5 using SHA-512"#.to_owned(),
r"RSASSA-PKCS1-v1_5 using SHA-512".to_owned(),
),
..Default::default()
})),
@@ -233,7 +233,7 @@ impl schemars::JsonSchema for JsonWebSignatureAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"ECDSA using P-256 and SHA-256"#.to_owned(),
r"ECDSA using P-256 and SHA-256".to_owned(),
),
..Default::default()
})),
@@ -246,7 +246,7 @@ impl schemars::JsonSchema for JsonWebSignatureAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"ECDSA using P-384 and SHA-384"#.to_owned(),
r"ECDSA using P-384 and SHA-384".to_owned(),
),
..Default::default()
})),
@@ -259,7 +259,7 @@ impl schemars::JsonSchema for JsonWebSignatureAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"ECDSA using P-521 and SHA-512"#.to_owned(),
r"ECDSA using P-521 and SHA-512".to_owned(),
),
..Default::default()
})),
@@ -272,7 +272,7 @@ impl schemars::JsonSchema for JsonWebSignatureAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"RSASSA-PSS using SHA-256 and MGF1 with SHA-256"#.to_owned(),
r"RSASSA-PSS using SHA-256 and MGF1 with SHA-256".to_owned(),
),
..Default::default()
})),
@@ -285,7 +285,7 @@ impl schemars::JsonSchema for JsonWebSignatureAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"RSASSA-PSS using SHA-384 and MGF1 with SHA-384"#.to_owned(),
r"RSASSA-PSS using SHA-384 and MGF1 with SHA-384".to_owned(),
),
..Default::default()
})),
@@ -298,7 +298,7 @@ impl schemars::JsonSchema for JsonWebSignatureAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"RSASSA-PSS using SHA-512 and MGF1 with SHA-512"#.to_owned(),
r"RSASSA-PSS using SHA-512 and MGF1 with SHA-512".to_owned(),
),
..Default::default()
})),
@@ -311,7 +311,7 @@ impl schemars::JsonSchema for JsonWebSignatureAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"No digital signature or MAC performed"#.to_owned(),
r"No digital signature or MAC performed".to_owned(),
),
..Default::default()
})),
@@ -324,7 +324,7 @@ impl schemars::JsonSchema for JsonWebSignatureAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"EdDSA signature algorithms"#.to_owned(),
r"EdDSA signature algorithms".to_owned(),
),
..Default::default()
})),
@@ -337,7 +337,7 @@ impl schemars::JsonSchema for JsonWebSignatureAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"ECDSA using secp256k1 curve and SHA-256"#.to_owned(),
r"ECDSA using secp256k1 curve and SHA-256".to_owned(),
),
..Default::default()
})),
@@ -521,7 +521,7 @@ impl schemars::JsonSchema for JsonWebEncryptionAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"RSAES-PKCS1-v1_5"#.to_owned(),
r"RSAES-PKCS1-v1_5".to_owned(),
),
..Default::default()
})),
@@ -534,7 +534,7 @@ impl schemars::JsonSchema for JsonWebEncryptionAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"RSAES OAEP using default parameters"#.to_owned(),
r"RSAES OAEP using default parameters".to_owned(),
),
..Default::default()
})),
@@ -547,7 +547,7 @@ impl schemars::JsonSchema for JsonWebEncryptionAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"RSAES OAEP using SHA-256 and MGF1 with SHA-256"#.to_owned(),
r"RSAES OAEP using SHA-256 and MGF1 with SHA-256".to_owned(),
),
..Default::default()
})),
@@ -560,7 +560,7 @@ impl schemars::JsonSchema for JsonWebEncryptionAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"AES Key Wrap using 128-bit key"#.to_owned(),
r"AES Key Wrap using 128-bit key".to_owned(),
),
..Default::default()
})),
@@ -573,7 +573,7 @@ impl schemars::JsonSchema for JsonWebEncryptionAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"AES Key Wrap using 192-bit key"#.to_owned(),
r"AES Key Wrap using 192-bit key".to_owned(),
),
..Default::default()
})),
@@ -586,7 +586,7 @@ impl schemars::JsonSchema for JsonWebEncryptionAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"AES Key Wrap using 256-bit key"#.to_owned(),
r"AES Key Wrap using 256-bit key".to_owned(),
),
..Default::default()
})),
@@ -599,7 +599,7 @@ impl schemars::JsonSchema for JsonWebEncryptionAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"Direct use of a shared symmetric key"#.to_owned(),
r"Direct use of a shared symmetric key".to_owned(),
),
..Default::default()
})),
@@ -612,7 +612,7 @@ impl schemars::JsonSchema for JsonWebEncryptionAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"ECDH-ES using Concat KDF"#.to_owned(),
r"ECDH-ES using Concat KDF".to_owned(),
),
..Default::default()
})),
@@ -664,7 +664,7 @@ impl schemars::JsonSchema for JsonWebEncryptionAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"Key wrapping with AES GCM using 128-bit key"#.to_owned(),
r"Key wrapping with AES GCM using 128-bit key".to_owned(),
),
..Default::default()
})),
@@ -677,7 +677,7 @@ impl schemars::JsonSchema for JsonWebEncryptionAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"Key wrapping with AES GCM using 192-bit key"#.to_owned(),
r"Key wrapping with AES GCM using 192-bit key".to_owned(),
),
..Default::default()
})),
@@ -690,7 +690,7 @@ impl schemars::JsonSchema for JsonWebEncryptionAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"Key wrapping with AES GCM using 256-bit key"#.to_owned(),
r"Key wrapping with AES GCM using 256-bit key".to_owned(),
),
..Default::default()
})),
@@ -742,7 +742,7 @@ impl schemars::JsonSchema for JsonWebEncryptionAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"RSA-OAEP using SHA-384 and MGF1 with SHA-384"#.to_owned(),
r"RSA-OAEP using SHA-384 and MGF1 with SHA-384".to_owned(),
),
..Default::default()
})),
@@ -755,7 +755,7 @@ impl schemars::JsonSchema for JsonWebEncryptionAlg {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"RSA-OAEP using SHA-512 and MGF1 with SHA-512"#.to_owned(),
r"RSA-OAEP using SHA-512 and MGF1 with SHA-512".to_owned(),
),
..Default::default()
})),
@@ -874,7 +874,7 @@ impl schemars::JsonSchema for JsonWebEncryptionEnc {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"AES_128_CBC_HMAC_SHA_256 authenticated encryption algorithm"#.to_owned(),
r"AES_128_CBC_HMAC_SHA_256 authenticated encryption algorithm".to_owned(),
),
..Default::default()
})),
@@ -887,7 +887,7 @@ impl schemars::JsonSchema for JsonWebEncryptionEnc {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"AES_192_CBC_HMAC_SHA_384 authenticated encryption algorithm"#.to_owned(),
r"AES_192_CBC_HMAC_SHA_384 authenticated encryption algorithm".to_owned(),
),
..Default::default()
})),
@@ -900,7 +900,7 @@ impl schemars::JsonSchema for JsonWebEncryptionEnc {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"AES_256_CBC_HMAC_SHA_512 authenticated encryption algorithm"#.to_owned(),
r"AES_256_CBC_HMAC_SHA_512 authenticated encryption algorithm".to_owned(),
),
..Default::default()
})),
@@ -913,7 +913,7 @@ impl schemars::JsonSchema for JsonWebEncryptionEnc {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"AES GCM using 128-bit key"#.to_owned(),
r"AES GCM using 128-bit key".to_owned(),
),
..Default::default()
})),
@@ -926,7 +926,7 @@ impl schemars::JsonSchema for JsonWebEncryptionEnc {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"AES GCM using 192-bit key"#.to_owned(),
r"AES GCM using 192-bit key".to_owned(),
),
..Default::default()
})),
@@ -939,7 +939,7 @@ impl schemars::JsonSchema for JsonWebEncryptionEnc {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"AES GCM using 256-bit key"#.to_owned(),
r"AES GCM using 256-bit key".to_owned(),
),
..Default::default()
})),
@@ -1033,7 +1033,7 @@ impl schemars::JsonSchema for JsonWebEncryptionCompressionAlgorithm {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"DEFLATE"#.to_owned(),
r"DEFLATE".to_owned(),
),
..Default::default()
})),
@@ -1043,7 +1043,7 @@ impl schemars::JsonSchema for JsonWebEncryptionCompressionAlgorithm {
.into(),
];
let description = r#"JSON Web Encryption Compression Algorithm"#;
let description = r"JSON Web Encryption Compression Algorithm";
schemars::schema::SchemaObject {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(description.to_owned()),
@@ -1142,7 +1142,7 @@ impl schemars::JsonSchema for JsonWebKeyType {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"Elliptic Curve"#.to_owned(),
r"Elliptic Curve".to_owned(),
),
..Default::default()
})),
@@ -1155,7 +1155,7 @@ impl schemars::JsonSchema for JsonWebKeyType {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"RSA"#.to_owned(),
r"RSA".to_owned(),
),
..Default::default()
})),
@@ -1168,7 +1168,7 @@ impl schemars::JsonSchema for JsonWebKeyType {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"Octet sequence"#.to_owned(),
r"Octet sequence".to_owned(),
),
..Default::default()
})),
@@ -1181,7 +1181,7 @@ impl schemars::JsonSchema for JsonWebKeyType {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"Octet string key pairs"#.to_owned(),
r"Octet string key pairs".to_owned(),
),
..Default::default()
})),
@@ -1191,7 +1191,7 @@ impl schemars::JsonSchema for JsonWebKeyType {
.into(),
];
let description = r#"JSON Web Key Type"#;
let description = r"JSON Web Key Type";
schemars::schema::SchemaObject {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(description.to_owned()),
@@ -1290,7 +1290,7 @@ impl schemars::JsonSchema for JsonWebKeyEcEllipticCurve {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"P-256 Curve"#.to_owned(),
r"P-256 Curve".to_owned(),
),
..Default::default()
})),
@@ -1303,7 +1303,7 @@ impl schemars::JsonSchema for JsonWebKeyEcEllipticCurve {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"P-384 Curve"#.to_owned(),
r"P-384 Curve".to_owned(),
),
..Default::default()
})),
@@ -1316,7 +1316,7 @@ impl schemars::JsonSchema for JsonWebKeyEcEllipticCurve {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"P-521 Curve"#.to_owned(),
r"P-521 Curve".to_owned(),
),
..Default::default()
})),
@@ -1329,7 +1329,7 @@ impl schemars::JsonSchema for JsonWebKeyEcEllipticCurve {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"SECG secp256k1 curve"#.to_owned(),
r"SECG secp256k1 curve".to_owned(),
),
..Default::default()
})),
@@ -1339,7 +1339,7 @@ impl schemars::JsonSchema for JsonWebKeyEcEllipticCurve {
.into(),
];
let description = r#"JSON Web Key EC Elliptic Curve"#;
let description = r"JSON Web Key EC Elliptic Curve";
schemars::schema::SchemaObject {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(description.to_owned()),
@@ -1438,7 +1438,7 @@ impl schemars::JsonSchema for JsonWebKeyOkpEllipticCurve {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"Ed25519 signature algorithm key pairs"#.to_owned(),
r"Ed25519 signature algorithm key pairs".to_owned(),
),
..Default::default()
})),
@@ -1451,7 +1451,7 @@ impl schemars::JsonSchema for JsonWebKeyOkpEllipticCurve {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"Ed448 signature algorithm key pairs"#.to_owned(),
r"Ed448 signature algorithm key pairs".to_owned(),
),
..Default::default()
})),
@@ -1464,7 +1464,7 @@ impl schemars::JsonSchema for JsonWebKeyOkpEllipticCurve {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"X25519 function key pairs"#.to_owned(),
r"X25519 function key pairs".to_owned(),
),
..Default::default()
})),
@@ -1477,7 +1477,7 @@ impl schemars::JsonSchema for JsonWebKeyOkpEllipticCurve {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"X448 function key pairs"#.to_owned(),
r"X448 function key pairs".to_owned(),
),
..Default::default()
})),
@@ -1487,7 +1487,7 @@ impl schemars::JsonSchema for JsonWebKeyOkpEllipticCurve {
.into(),
];
let description = r#"JSON Web Key OKP Elliptic Curve"#;
let description = r"JSON Web Key OKP Elliptic Curve";
schemars::schema::SchemaObject {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(description.to_owned()),
@@ -1576,7 +1576,7 @@ impl schemars::JsonSchema for JsonWebKeyUse {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"Digital Signature or MAC"#.to_owned(),
r"Digital Signature or MAC".to_owned(),
),
..Default::default()
})),
@@ -1589,7 +1589,7 @@ impl schemars::JsonSchema for JsonWebKeyUse {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"Encryption"#.to_owned(),
r"Encryption".to_owned(),
),
..Default::default()
})),
@@ -1599,7 +1599,7 @@ impl schemars::JsonSchema for JsonWebKeyUse {
.into(),
];
let description = r#"JSON Web Key Use"#;
let description = r"JSON Web Key Use";
schemars::schema::SchemaObject {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(description.to_owned()),
@@ -1718,7 +1718,7 @@ impl schemars::JsonSchema for JsonWebKeyOperation {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"Compute digital signature or MAC"#.to_owned(),
r"Compute digital signature or MAC".to_owned(),
),
..Default::default()
})),
@@ -1731,7 +1731,7 @@ impl schemars::JsonSchema for JsonWebKeyOperation {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"Verify digital signature or MAC"#.to_owned(),
r"Verify digital signature or MAC".to_owned(),
),
..Default::default()
})),
@@ -1744,7 +1744,7 @@ impl schemars::JsonSchema for JsonWebKeyOperation {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"Encrypt content"#.to_owned(),
r"Encrypt content".to_owned(),
),
..Default::default()
})),
@@ -1757,7 +1757,7 @@ impl schemars::JsonSchema for JsonWebKeyOperation {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"Decrypt content and validate decryption, if applicable"#.to_owned(),
r"Decrypt content and validate decryption, if applicable".to_owned(),
),
..Default::default()
})),
@@ -1770,7 +1770,7 @@ impl schemars::JsonSchema for JsonWebKeyOperation {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"Encrypt key"#.to_owned(),
r"Encrypt key".to_owned(),
),
..Default::default()
})),
@@ -1783,7 +1783,7 @@ impl schemars::JsonSchema for JsonWebKeyOperation {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"Decrypt key and validate decryption, if applicable"#.to_owned(),
r"Decrypt key and validate decryption, if applicable".to_owned(),
),
..Default::default()
})),
@@ -1796,7 +1796,7 @@ impl schemars::JsonSchema for JsonWebKeyOperation {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"Derive key"#.to_owned(),
r"Derive key".to_owned(),
),
..Default::default()
})),
@@ -1809,7 +1809,7 @@ impl schemars::JsonSchema for JsonWebKeyOperation {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(
// ---
r#"Derive bits not to be used as a key"#.to_owned(),
r"Derive bits not to be used as a key".to_owned(),
),
..Default::default()
})),
@@ -1819,7 +1819,7 @@ impl schemars::JsonSchema for JsonWebKeyOperation {
.into(),
];
let description = r#"JSON Web Key Operation"#;
let description = r"JSON Web Key Operation";
schemars::schema::SchemaObject {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(description.to_owned()),

View File

@@ -32,6 +32,9 @@ pub enum OAuthAccessTokenType {
/// `PoP`
PoP,
/// `DPoP`
DPoP,
/// An unknown value.
Unknown(String),
}
@@ -42,6 +45,7 @@ impl core::fmt::Display for OAuthAccessTokenType {
Self::Bearer => write!(f, "Bearer"),
Self::Na => write!(f, "N_A"),
Self::PoP => write!(f, "PoP"),
Self::DPoP => write!(f, "DPoP"),
Self::Unknown(value) => write!(f, "{value}"),
}
}
@@ -55,6 +59,7 @@ impl core::str::FromStr for OAuthAccessTokenType {
"Bearer" => Ok(Self::Bearer),
"N_A" => Ok(Self::Na),
"PoP" => Ok(Self::PoP),
"DPoP" => Ok(Self::DPoP),
value => Ok(Self::Unknown(value.to_owned())),
}
}
@@ -108,9 +113,15 @@ impl schemars::JsonSchema for OAuthAccessTokenType {
..Default::default()
}
.into(),
// ---
schemars::schema::SchemaObject {
const_value: Some("DPoP".into()),
..Default::default()
}
.into(),
];
let description = r#"OAuth Access Token Type"#;
let description = r"OAuth Access Token Type";
schemars::schema::SchemaObject {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(description.to_owned()),
@@ -269,7 +280,7 @@ impl schemars::JsonSchema for OAuthAuthorizationEndpointResponseType {
.into(),
];
let description = r#"OAuth Authorization Endpoint Response Type"#;
let description = r"OAuth Authorization Endpoint Response Type";
schemars::schema::SchemaObject {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(description.to_owned()),
@@ -378,7 +389,7 @@ impl schemars::JsonSchema for OAuthTokenTypeHint {
.into(),
];
let description = r#"OAuth Token Type Hint"#;
let description = r"OAuth Token Type Hint";
schemars::schema::SchemaObject {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(description.to_owned()),
@@ -531,7 +542,7 @@ impl schemars::JsonSchema for OAuthClientAuthenticationMethod {
.into(),
];
let description = r#"OAuth Token Endpoint Authentication Method"#;
let description = r"OAuth Token Endpoint Authentication Method";
schemars::schema::SchemaObject {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(description.to_owned()),
@@ -629,7 +640,7 @@ impl schemars::JsonSchema for PkceCodeChallengeMethod {
.into(),
];
let description = r#"PKCE Code Challenge Method"#;
let description = r"PKCE Code Challenge Method";
schemars::schema::SchemaObject {
metadata: Some(Box::new(schemars::schema::Metadata {
description: Some(description.to_owned()),

View File

@@ -200,13 +200,13 @@ impl UrlBuilder {
#[cfg(test)]
mod tests {
#[test]
#[should_panic]
#[should_panic(expected = "base URL must be HTTP/HTTPS")]
fn test_invalid_base_url_scheme() {
let _ = super::UrlBuilder::new(url::Url::parse("file:///tmp/").unwrap(), None, None);
}
#[test]
#[should_panic]
#[should_panic(expected = "base URL must not contain a query")]
fn test_invalid_base_url_query() {
let _ = super::UrlBuilder::new(
url::Url::parse("https://example.com/?foo=bar").unwrap(),
@@ -216,7 +216,7 @@ mod tests {
}
#[test]
#[should_panic]
#[should_panic(expected = "base URL must not contain a fragment")]
fn test_invalid_base_url_fragment() {
let _ = super::UrlBuilder::new(
url::Url::parse("https://example.com/#foo").unwrap(),
@@ -226,7 +226,7 @@ mod tests {
}
#[test]
#[should_panic]
#[should_panic(expected = "base URL must not contain credentials")]
fn test_invalid_base_url_credentials() {
let _ = super::UrlBuilder::new(
url::Url::parse("https://foo@example.com/").unwrap(),