diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3d4d4b06..444bb4e4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 diff --git a/Dockerfile b/Dockerfile index 915ba980..884d83c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/crates/cli/src/commands/manage.rs b/crates/cli/src/commands/manage.rs index 28e600c5..cd87e141 100644 --- a/crates/cli/src/commands/manage.rs +++ b/crates/cli/src/commands/manage.rs @@ -248,10 +248,10 @@ impl Options { .context("User not found")?; let compat_sessions_ids: Vec = 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 = 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 = 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) diff --git a/crates/config/src/sections/database.rs b/crates/config/src/sections/database.rs index 127193a8..5ad79fe4 100644 --- a/crates/config/src/sections/database.rs +++ b/crates/config/src/sections/database.rs @@ -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")?; diff --git a/crates/config/src/sections/matrix.rs b/crates/config/src/sections/matrix.rs index e5718e4c..13a6418c 100644 --- a/crates/config/src/sections/matrix.rs +++ b/crates/config/src/sections/matrix.rs @@ -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")?; diff --git a/crates/config/src/sections/secrets.rs b/crates/config/src/sections/secrets.rs index 9e80216b..a15babc8 100644 --- a/crates/config/src/sections/secrets.rs +++ b/crates/config/src/sections/secrets.rs @@ -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(), ), }; diff --git a/crates/config/src/util.rs b/crates/config/src/util.rs index 9c5bcc8e..b6b6849c 100644 --- a/crates/config/src/util.rs +++ b/crates/config/src/util.rs @@ -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(rng: R) -> anyhow::Result 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

(paths: &[P]) -> Result where P: AsRef, @@ -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

(path: P) -> Result where P: AsRef, diff --git a/crates/handlers/src/graphql/tests.rs b/crates/handlers/src/graphql/tests.rs index 4a5d1574..60fa74b7 100644 --- a/crates/handlers/src/graphql/tests.rs +++ b/crates/handlers/src/graphql/tests.rs @@ -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:*" diff --git a/crates/i18n-scan/src/minijinja.rs b/crates/i18n-scan/src/minijinja.rs index cbae41e4..412d8e0c 100644 --- a/crates/i18n-scan/src/minijinja.rs +++ b/crates/i18n-scan/src/minijinja.rs @@ -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()); diff --git a/crates/iana-codegen/src/gen.rs b/crates/iana-codegen/src/gen.rs index 5f403708..2a7123d8 100644 --- a/crates/iana-codegen/src/gen.rs +++ b/crates/iana-codegen/src/gen.rs @@ -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), ) } diff --git a/crates/iana/src/jose.rs b/crates/iana/src/jose.rs index 37411c3c..54f3b90f 100644 --- a/crates/iana/src/jose.rs +++ b/crates/iana/src/jose.rs @@ -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()), diff --git a/crates/iana/src/oauth.rs b/crates/iana/src/oauth.rs index 76b9b365..daa3d48a 100644 --- a/crates/iana/src/oauth.rs +++ b/crates/iana/src/oauth.rs @@ -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()), diff --git a/crates/router/src/url_builder.rs b/crates/router/src/url_builder.rs index 2883461e..6c9e0049 100644 --- a/crates/router/src/url_builder.rs +++ b/crates/router/src/url_builder.rs @@ -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(),