From 7474fc97c12229e7452317949e6935176ac93b00 Mon Sep 17 00:00:00 2001 From: Mr-Leshiy Date: Wed, 29 Oct 2025 16:54:05 +0700 Subject: [PATCH 1/4] update `SignatureKidRule` rule --- rust/signed_doc/Cargo.toml | 2 +- .../src/validator/rules/signature_kid.rs | 71 ++++++++++--------- rust/signed_doc/tests/brand_parameters.rs | 16 ++--- .../tests/brand_parameters_form_template.rs | 12 ++-- rust/signed_doc/tests/campaign_parameters.rs | 20 +++--- .../campaign_parameters_form_template.rs | 16 ++--- rust/signed_doc/tests/category_parameters.rs | 20 +++--- .../category_parameters_form_template.rs | 16 ++--- .../tests/common/brand_parameters.rs | 4 +- .../common/brand_parameters_form_template.rs | 4 +- .../tests/common/campaign_parameters.rs | 4 +- .../campaign_parameters_form_template.rs | 4 +- .../tests/common/category_parameters.rs | 4 +- .../category_parameters_form_template.rs | 4 +- rust/signed_doc/tests/common/mod.rs | 17 ++--- rust/signed_doc/tests/common/proposal.rs | 4 +- .../tests/common/proposal_comment.rs | 4 +- .../common/proposal_comment_form_template.rs | 4 +- .../tests/common/proposal_form_template.rs | 4 +- rust/signed_doc/tests/decoding.rs | 14 ++-- rust/signed_doc/tests/proposal.rs | 15 ++-- rust/signed_doc/tests/proposal_comment.rs | 28 ++++---- .../tests/proposal_comment_form_template.rs | 16 ++--- .../tests/proposal_form_template.rs | 16 ++--- .../tests/proposal_submission_action.rs | 3 +- 25 files changed, 167 insertions(+), 155 deletions(-) diff --git a/rust/signed_doc/Cargo.toml b/rust/signed_doc/Cargo.toml index 70cf1ae3ae..dad8eb185f 100644 --- a/rust/signed_doc/Cargo.toml +++ b/rust/signed_doc/Cargo.toml @@ -11,7 +11,7 @@ license.workspace = true workspace = true [dependencies] -catalyst-types = { version = "0.0.9", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.9" } +catalyst-types = { version = "0.0.10", git = "https://github.com/input-output-hk/catalyst-libs.git", branch = "feat/cat-id-admin" } cbork-utils = { version = "0.0.2", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cbork-utils-v0.0.2" } catalyst-signed-doc-macro = { version = "0.0.1", path = "../catalyst-signed-doc-macro" } diff --git a/rust/signed_doc/src/validator/rules/signature_kid.rs b/rust/signed_doc/src/validator/rules/signature_kid.rs index c940cbb5ae..9368fe7f93 100644 --- a/rust/signed_doc/src/validator/rules/signature_kid.rs +++ b/rust/signed_doc/src/validator/rules/signature_kid.rs @@ -2,7 +2,7 @@ use std::collections::HashSet; -use catalyst_signed_doc_spec::signers::roles::{AdminRole, Roles, UserRole}; +use catalyst_signed_doc_spec::signers::roles::{Roles, UserRole}; use catalyst_types::catalyst_id::role_index::RoleId; use crate::CatalystSignedDocument; @@ -10,13 +10,20 @@ use crate::CatalystSignedDocument; /// COSE signature `kid` (Catalyst Id) role validation #[derive(Debug)] pub(crate) struct SignatureKidRule { - /// expected `RoleId` values for the `kid` field + /// expected `RoleId` values for the `kid` field. + /// if empty, document must be signed by admin kid allowed_roles: HashSet, } impl SignatureKidRule { /// Generating `SignatureKidRule` from specs pub(crate) fn new(spec: &Roles) -> anyhow::Result { + anyhow::ensure!( + spec.user.is_empty() == !spec.admin.is_empty(), + "If 'admin' is not empty 'user' roles cannot been specified'. + And vice versa, if 'user' is not empty 'admin' roles cannot been specified'" + ); + let allowed_roles: HashSet<_> = spec .user .iter() @@ -27,26 +34,8 @@ impl SignatureKidRule { UserRole::Representative => RoleId::DelegatedRepresentative, } }) - .chain(spec.admin.iter().map(|v| { - match v { - AdminRole::RootCA => RoleId::RootCA, - AdminRole::BrandCA => RoleId::BrandCA, - AdminRole::CampaignCA => RoleId::CampaignCA, - AdminRole::CategoryCA => RoleId::CategoryCA, - AdminRole::RootAdmin => RoleId::RootAdmin, - AdminRole::BrandAdmin => RoleId::BrandAdmin, - AdminRole::CampaignAdmin => RoleId::CampaignAdmin, - AdminRole::CategoryAdmin => RoleId::CategoryAdmin, - AdminRole::Moderator => RoleId::Moderator, - } - })) .collect(); - anyhow::ensure!( - !allowed_roles.is_empty(), - "A list of allowed roles cannot be empty" - ); - Ok(Self { allowed_roles }) } @@ -57,20 +46,36 @@ impl SignatureKidRule { doc: &CatalystSignedDocument, ) -> anyhow::Result { let contains_exp_role = doc.authors().iter().enumerate().all(|(i, kid)| { - let (role_index, _) = kid.role_and_rotation(); - let res = self.allowed_roles.contains(&role_index); - if !res { - doc.report().invalid_value( - "kid", - role_index.to_string().as_str(), - format!("{:?}", self.allowed_roles).as_str(), - format!( - "Invalid Catalyst Signed Document signature at position [{i}] `kid` Catalyst Role value" - ) - .as_str(), - ); + if self.allowed_roles.is_empty() { + let res = kid.is_admin(); + if !res { + doc.report().invalid_value( + "kid", + &kid.to_string(), + "Catalyst id must be in admin URI type.", + format!( + "Invalid Catalyst Signed Document signature at position [{i}] `kid` Catalyst Role value" + ) + .as_str(), + ); + } + res + } else { + let (role_index, _) = kid.role_and_rotation(); + let res = self.allowed_roles.contains(&role_index); + if !res { + doc.report().invalid_value( + "kid", + role_index.to_string().as_str(), + format!("{:?}", self.allowed_roles).as_str(), + format!( + "Invalid Catalyst Signed Document signature at position [{i}] `kid` Catalyst Role value" + ) + .as_str(), + ); + } + res } - res }); if !contains_exp_role { return Ok(false); diff --git a/rust/signed_doc/tests/brand_parameters.rs b/rust/signed_doc/tests/brand_parameters.rs index 85e773f0d9..f4efbf4040 100644 --- a/rust/signed_doc/tests/brand_parameters.rs +++ b/rust/signed_doc/tests/brand_parameters.rs @@ -25,8 +25,8 @@ mod common; |provider| { let template = brand_parameters_form_template_doc(provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Role0) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(Some(RoleId::Role0)); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, @@ -51,8 +51,8 @@ mod common; |provider| { let template = brand_parameters_form_template_doc(provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, @@ -77,8 +77,8 @@ mod common; |provider| { let template = brand_parameters_form_template_doc(provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, @@ -102,8 +102,8 @@ mod common; #[test_case( |provider| { let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, diff --git a/rust/signed_doc/tests/brand_parameters_form_template.rs b/rust/signed_doc/tests/brand_parameters_form_template.rs index bfa3e69398..70c1b7f14d 100644 --- a/rust/signed_doc/tests/brand_parameters_form_template.rs +++ b/rust/signed_doc/tests/brand_parameters_form_template.rs @@ -21,8 +21,8 @@ mod common; #[test_case( |provider| { let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Role0) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(Some(RoleId::Role0)); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson, @@ -42,8 +42,8 @@ mod common; #[test_case( |provider| { let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson, @@ -63,8 +63,8 @@ mod common; #[test_case( |provider| { let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson, diff --git a/rust/signed_doc/tests/campaign_parameters.rs b/rust/signed_doc/tests/campaign_parameters.rs index 59d06cea84..265d3af7a7 100644 --- a/rust/signed_doc/tests/campaign_parameters.rs +++ b/rust/signed_doc/tests/campaign_parameters.rs @@ -30,8 +30,8 @@ mod common; let parameters = brand_parameters_doc(&template, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let template = campaign_parameters_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Role0) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(Some(RoleId::Role0)); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, @@ -62,8 +62,8 @@ mod common; let parameters = brand_parameters_doc(&template, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let template = campaign_parameters_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, @@ -94,8 +94,8 @@ mod common; let parameters = brand_parameters_doc(&template, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let template = campaign_parameters_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, @@ -124,8 +124,8 @@ mod common; let template = brand_parameters_form_template_doc(provider).inspect(|v| provider.add_document(None, v).unwrap())?; let parameters = brand_parameters_doc(&template, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, @@ -152,8 +152,8 @@ mod common; let parameters = brand_parameters_doc(&template, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let template = campaign_parameters_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, diff --git a/rust/signed_doc/tests/campaign_parameters_form_template.rs b/rust/signed_doc/tests/campaign_parameters_form_template.rs index 4ebdb72972..7b3ae4897f 100644 --- a/rust/signed_doc/tests/campaign_parameters_form_template.rs +++ b/rust/signed_doc/tests/campaign_parameters_form_template.rs @@ -28,8 +28,8 @@ mod common; let template = brand_parameters_form_template_doc(provider).inspect(|v| provider.add_document(None, v).unwrap())?; let parameters = brand_parameters_doc(&template, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Role0) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(Some(RoleId::Role0)); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson, @@ -55,8 +55,8 @@ mod common; let template = brand_parameters_form_template_doc(provider).inspect(|v| provider.add_document(None, v).unwrap())?; let parameters = brand_parameters_doc(&template, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson, @@ -82,8 +82,8 @@ mod common; let template = brand_parameters_form_template_doc(provider).inspect(|v| provider.add_document(None, v).unwrap())?; let parameters = brand_parameters_doc(&template, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson, @@ -106,8 +106,8 @@ mod common; #[test_case( |provider| { let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson, diff --git a/rust/signed_doc/tests/category_parameters.rs b/rust/signed_doc/tests/category_parameters.rs index 6ceb6a3ed9..0c3a8bc26b 100644 --- a/rust/signed_doc/tests/category_parameters.rs +++ b/rust/signed_doc/tests/category_parameters.rs @@ -35,8 +35,8 @@ mod common; let parameters = campaign_parameters_doc(&template, ¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let template = category_parameters_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Role0) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(Some(RoleId::Role0)); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, @@ -69,8 +69,8 @@ mod common; let parameters = campaign_parameters_doc(&template, ¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let template = category_parameters_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, @@ -103,8 +103,8 @@ mod common; let parameters = campaign_parameters_doc(&template, ¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let template = category_parameters_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, @@ -135,8 +135,8 @@ mod common; let template = campaign_parameters_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let parameters = campaign_parameters_doc(&template, ¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, @@ -165,8 +165,8 @@ mod common; let parameters = campaign_parameters_doc(&template, ¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let template = category_parameters_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, diff --git a/rust/signed_doc/tests/category_parameters_form_template.rs b/rust/signed_doc/tests/category_parameters_form_template.rs index a048b269ce..a2f64d50c9 100644 --- a/rust/signed_doc/tests/category_parameters_form_template.rs +++ b/rust/signed_doc/tests/category_parameters_form_template.rs @@ -33,8 +33,8 @@ mod common; let template = campaign_parameters_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let parameters = campaign_parameters_doc(¶meters, &template, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Role0) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(Some(RoleId::Role0)); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson, @@ -62,8 +62,8 @@ mod common; let template = campaign_parameters_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let parameters = campaign_parameters_doc(¶meters, &template, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson, @@ -91,8 +91,8 @@ mod common; let template = campaign_parameters_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let parameters = campaign_parameters_doc(¶meters, &template, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson, @@ -115,8 +115,8 @@ mod common; #[test_case( |provider| { let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson, diff --git a/rust/signed_doc/tests/common/brand_parameters.rs b/rust/signed_doc/tests/common/brand_parameters.rs index 0f029befc0..ed33a1353a 100644 --- a/rust/signed_doc/tests/common/brand_parameters.rs +++ b/rust/signed_doc/tests/common/brand_parameters.rs @@ -8,8 +8,8 @@ pub fn brand_parameters_doc( provider: &mut TestCatalystProvider, ) -> anyhow::Result { let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, diff --git a/rust/signed_doc/tests/common/brand_parameters_form_template.rs b/rust/signed_doc/tests/common/brand_parameters_form_template.rs index b74acbf2e8..564822c88e 100644 --- a/rust/signed_doc/tests/common/brand_parameters_form_template.rs +++ b/rust/signed_doc/tests/common/brand_parameters_form_template.rs @@ -7,8 +7,8 @@ pub fn brand_parameters_form_template_doc( provider: &mut TestCatalystProvider ) -> anyhow::Result { let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson, diff --git a/rust/signed_doc/tests/common/campaign_parameters.rs b/rust/signed_doc/tests/common/campaign_parameters.rs index bba3421773..9233fbaef8 100644 --- a/rust/signed_doc/tests/common/campaign_parameters.rs +++ b/rust/signed_doc/tests/common/campaign_parameters.rs @@ -9,8 +9,8 @@ pub fn campaign_parameters_doc( provider: &mut TestCatalystProvider, ) -> anyhow::Result { let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, diff --git a/rust/signed_doc/tests/common/campaign_parameters_form_template.rs b/rust/signed_doc/tests/common/campaign_parameters_form_template.rs index f6e62fa838..691931750b 100644 --- a/rust/signed_doc/tests/common/campaign_parameters_form_template.rs +++ b/rust/signed_doc/tests/common/campaign_parameters_form_template.rs @@ -8,8 +8,8 @@ pub fn campaign_parameters_form_template_doc( provider: &mut TestCatalystProvider, ) -> anyhow::Result { let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson, diff --git a/rust/signed_doc/tests/common/category_parameters.rs b/rust/signed_doc/tests/common/category_parameters.rs index ce989d0ebe..202282561a 100644 --- a/rust/signed_doc/tests/common/category_parameters.rs +++ b/rust/signed_doc/tests/common/category_parameters.rs @@ -9,8 +9,8 @@ pub fn category_parameters_doc( provider: &mut TestCatalystProvider, ) -> anyhow::Result { let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, diff --git a/rust/signed_doc/tests/common/category_parameters_form_template.rs b/rust/signed_doc/tests/common/category_parameters_form_template.rs index b6401dd3ce..cb19eb4dea 100644 --- a/rust/signed_doc/tests/common/category_parameters_form_template.rs +++ b/rust/signed_doc/tests/common/category_parameters_form_template.rs @@ -8,8 +8,8 @@ pub fn category_parameters_form_template_doc( provider: &mut TestCatalystProvider, ) -> anyhow::Result { let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson, diff --git a/rust/signed_doc/tests/common/mod.rs b/rust/signed_doc/tests/common/mod.rs index c0028429a0..8013817fd8 100644 --- a/rust/signed_doc/tests/common/mod.rs +++ b/rust/signed_doc/tests/common/mod.rs @@ -43,16 +43,17 @@ pub fn get_doc_kid_and_sk( Ok((sk.clone(), kid.clone())) } +// If `None` make `CatalystId` as admin pub fn create_dummy_key_pair( - role_index: RoleId -) -> anyhow::Result<(ed25519_dalek::SigningKey, CatalystId)> { + role_index: Option +) -> (ed25519_dalek::SigningKey, CatalystId) { let sk = create_signing_key(); - let kid = CatalystId::from_str(&format!( - "id.catalyst://cardano/{}/{role_index}/0", - base64_url::encode(sk.verifying_key().as_bytes()) - ))?; - - Ok((sk, kid)) + let kid = if let Some(role_index) = role_index { + CatalystId::new("cardano", None, sk.verifying_key()).with_role(role_index) + } else { + CatalystId::new("cardano", None, sk.verifying_key()).as_admin() + }; + (sk, kid) } pub fn create_signing_key() -> ed25519_dalek::SigningKey { diff --git a/rust/signed_doc/tests/common/proposal.rs b/rust/signed_doc/tests/common/proposal.rs index 0f1d6e5715..73bff88d57 100644 --- a/rust/signed_doc/tests/common/proposal.rs +++ b/rust/signed_doc/tests/common/proposal.rs @@ -11,8 +11,8 @@ pub fn proposal_doc( provider: &mut TestCatalystProvider, ) -> anyhow::Result { let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Proposer) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(Some(RoleId::Proposer)); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, diff --git a/rust/signed_doc/tests/common/proposal_comment.rs b/rust/signed_doc/tests/common/proposal_comment.rs index ac17d8f691..ec99c6aba8 100644 --- a/rust/signed_doc/tests/common/proposal_comment.rs +++ b/rust/signed_doc/tests/common/proposal_comment.rs @@ -11,8 +11,8 @@ pub fn proposal_comment_doc( provider: &mut TestCatalystProvider, ) -> anyhow::Result { let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Role0) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(Some(RoleId::Role0)); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, diff --git a/rust/signed_doc/tests/common/proposal_comment_form_template.rs b/rust/signed_doc/tests/common/proposal_comment_form_template.rs index 8db499642a..01636e79ec 100644 --- a/rust/signed_doc/tests/common/proposal_comment_form_template.rs +++ b/rust/signed_doc/tests/common/proposal_comment_form_template.rs @@ -8,8 +8,8 @@ pub fn proposal_comment_form_template_doc( provider: &mut TestCatalystProvider, ) -> anyhow::Result { let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson, diff --git a/rust/signed_doc/tests/common/proposal_form_template.rs b/rust/signed_doc/tests/common/proposal_form_template.rs index ff79d634e9..db460c0cc9 100644 --- a/rust/signed_doc/tests/common/proposal_form_template.rs +++ b/rust/signed_doc/tests/common/proposal_form_template.rs @@ -8,8 +8,8 @@ pub fn proposal_form_template_doc( provider: &mut TestCatalystProvider, ) -> anyhow::Result { let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson, diff --git a/rust/signed_doc/tests/decoding.rs b/rust/signed_doc/tests/decoding.rs index 2fdcf52ce2..04d9847019 100644 --- a/rust/signed_doc/tests/decoding.rs +++ b/rust/signed_doc/tests/decoding.rs @@ -532,7 +532,7 @@ fn signed_doc_with_minimal_metadata_fields_case() -> TestCase { bytes_gen: Box::new({ let doc_type = doc_type.clone(); move || { - let (_, kid) = create_dummy_key_pair(RoleId::Role0)?; + let (_, kid) = create_dummy_key_pair(Some(RoleId::Role0)); let mut e = Encoder::new(Vec::new()); e.tag(Tag::new(98))?; @@ -605,7 +605,7 @@ fn signed_doc_with_complete_metadata_fields_case() -> TestCase { bytes_gen: Box::new({ let doc_type = doc_type.clone(); move || { - let (_, kid) = create_dummy_key_pair(RoleId::Role0)?; + let (_, kid) = create_dummy_key_pair(Some(RoleId::Role0)); let mut e = Encoder::new(Vec::new()); e.tag(Tag::new(98))?; @@ -980,7 +980,7 @@ fn signed_doc_with_signatures_non_empty_unprotected_headers() -> TestCase { name: "Catalyst Signed Doc with signatures non empty unprotected headers".to_string(), bytes_gen: Box::new({ move || { - let (_, kid) = create_dummy_key_pair(RoleId::Role0)?; + let (_, kid) = create_dummy_key_pair(Some(RoleId::Role0)); let mut e = Encoder::new(Vec::new()); e.tag(Tag::new(98))?; @@ -1033,7 +1033,7 @@ fn signed_doc_with_strict_deterministic_decoding_wrong_order() -> TestCase { name: "Catalyst Signed Doc with minimally defined metadata fields, with enabled strictly decoded rules, metadata field in the wrong order".to_string(), bytes_gen: Box::new({ move || { - let (_, kid) = create_dummy_key_pair(RoleId::Role0)?; + let (_, kid) = create_dummy_key_pair(Some(RoleId::Role0)); let mut e = Encoder::new(Vec::new()); e.tag(Tag::new(98))?; @@ -1087,7 +1087,7 @@ fn signed_doc_with_non_strict_deterministic_decoding_wrong_order() -> TestCase { bytes_gen: Box::new({ let doc_type = doc_type.clone(); move || { - let (_, kid) = create_dummy_key_pair(RoleId::Role0)?; + let (_, kid) = create_dummy_key_pair(Some(RoleId::Role0)); let mut e = Encoder::new(Vec::new()); e.tag(Tag::new(98))?; @@ -1213,7 +1213,7 @@ fn signed_doc_with_kid_in_id_form_invalid() -> TestCase { bytes_gen: Box::new({ let doc_type = doc_type.clone(); move || { - let (_, kid) = create_dummy_key_pair(RoleId::Role0)?; + let (_, kid) = create_dummy_key_pair(Some(RoleId::Role0)); let mut e = Encoder::new(Vec::new()); e.tag(Tag::new(98))?; @@ -1280,7 +1280,7 @@ fn signed_doc_with_non_supported_protected_signature_header_invalid() -> TestCas .to_string(), bytes_gen: Box::new({ move || { - let (_, kid) = create_dummy_key_pair(RoleId::Role0)?; + let (_, kid) = create_dummy_key_pair(Some(RoleId::Role0)); let mut e = Encoder::new(Vec::new()); e.tag(Tag::new(98))?; diff --git a/rust/signed_doc/tests/proposal.rs b/rust/signed_doc/tests/proposal.rs index 0f6fafd19b..afaac7a411 100644 --- a/rust/signed_doc/tests/proposal.rs +++ b/rust/signed_doc/tests/proposal.rs @@ -61,7 +61,8 @@ mod common; let parameters = brand_parameters_doc(&template, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let template = proposal_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Role0).inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(Some(RoleId::Role0)); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, @@ -92,7 +93,8 @@ mod common; let parameters = brand_parameters_doc(&template, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let template = proposal_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Proposer).inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(Some(RoleId::Proposer)); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, @@ -123,7 +125,8 @@ mod common; let parameters = brand_parameters_doc(&template, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let template = proposal_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Proposer).inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(Some(RoleId::Proposer)); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, @@ -152,7 +155,8 @@ mod common; let template = brand_parameters_form_template_doc(provider).inspect(|v| provider.add_document(None, v).unwrap())?; let parameters = brand_parameters_doc(&template, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Proposer).inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(Some(RoleId::Proposer)); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, @@ -179,7 +183,8 @@ mod common; let parameters = brand_parameters_doc(&template, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let template = proposal_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Proposer).inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(Some(RoleId::Proposer)); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, diff --git a/rust/signed_doc/tests/proposal_comment.rs b/rust/signed_doc/tests/proposal_comment.rs index 71938c8145..72286de39c 100644 --- a/rust/signed_doc/tests/proposal_comment.rs +++ b/rust/signed_doc/tests/proposal_comment.rs @@ -70,8 +70,8 @@ mod common; let template = proposal_comment_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let comment = proposal_comment_doc(&proposal, &template, ¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Role0) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(Some(RoleId::Role0)); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, @@ -112,8 +112,8 @@ mod common; let proposal = proposal_doc(&template, ¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let template = proposal_comment_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Proposer) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(Some(RoleId::Proposer)); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, @@ -150,8 +150,8 @@ mod common; let proposal = proposal_doc(&template, ¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let template = proposal_comment_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Role0) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(Some(RoleId::Role0)); + provider.add_sk(kid.clone(), sk.clone()); let doc = Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, @@ -189,8 +189,8 @@ mod common; let proposal = proposal_doc(&template, ¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let template = proposal_comment_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Role0) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(Some(RoleId::Role0)); + provider.add_sk(kid.clone(), sk.clone()); let doc = Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, @@ -226,8 +226,8 @@ mod common; let template = proposal_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let proposal = proposal_doc(&template, ¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Role0) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(Some(RoleId::Role0)); + provider.add_sk(kid.clone(), sk.clone()); let doc = Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, @@ -261,8 +261,8 @@ mod common; let proposal = proposal_doc(&template, ¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let template = proposal_comment_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Role0) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(Some(RoleId::Role0)); + provider.add_sk(kid.clone(), sk.clone()); let doc = Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, @@ -294,8 +294,8 @@ mod common; let parameters = brand_parameters_doc(&template, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let template = proposal_comment_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Role0) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(Some(RoleId::Role0)); + provider.add_sk(kid.clone(), sk.clone()); let doc = Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, diff --git a/rust/signed_doc/tests/proposal_comment_form_template.rs b/rust/signed_doc/tests/proposal_comment_form_template.rs index 40d9a2c94c..aa9a601234 100644 --- a/rust/signed_doc/tests/proposal_comment_form_template.rs +++ b/rust/signed_doc/tests/proposal_comment_form_template.rs @@ -56,8 +56,8 @@ mod common; let template = brand_parameters_form_template_doc(provider).inspect(|v| provider.add_document(None, v).unwrap())?; let parameters = brand_parameters_doc(&template, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Role0) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(Some(RoleId::Role0)); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson, @@ -83,8 +83,8 @@ mod common; let template = brand_parameters_form_template_doc(provider).inspect(|v| provider.add_document(None, v).unwrap())?; let parameters = brand_parameters_doc(&template, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson, @@ -110,8 +110,8 @@ mod common; let template = brand_parameters_form_template_doc(provider).inspect(|v| provider.add_document(None, v).unwrap())?; let parameters = brand_parameters_doc(&template, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson, @@ -134,8 +134,8 @@ mod common; #[test_case( |provider| { let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Role0) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson, diff --git a/rust/signed_doc/tests/proposal_form_template.rs b/rust/signed_doc/tests/proposal_form_template.rs index 63dd9712d7..f6fec05f5e 100644 --- a/rust/signed_doc/tests/proposal_form_template.rs +++ b/rust/signed_doc/tests/proposal_form_template.rs @@ -55,8 +55,8 @@ mod common; let template = brand_parameters_form_template_doc(provider).inspect(|v| provider.add_document(None, v).unwrap())?; let parameters = brand_parameters_doc(&template, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Role0) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(Some(RoleId::Role0)); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson.to_string(), @@ -82,8 +82,8 @@ mod common; let template = brand_parameters_form_template_doc(provider).inspect(|v| provider.add_document(None, v).unwrap())?; let parameters = brand_parameters_doc(&template, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson.to_string(), @@ -109,8 +109,8 @@ mod common; let template = brand_parameters_form_template_doc(provider).inspect(|v| provider.add_document(None, v).unwrap())?; let parameters = brand_parameters_doc(&template, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::BrandAdmin) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson.to_string(), @@ -133,8 +133,8 @@ mod common; #[test_case( |provider| { let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Role0) - .inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(None); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::SchemaJson.to_string(), diff --git a/rust/signed_doc/tests/proposal_submission_action.rs b/rust/signed_doc/tests/proposal_submission_action.rs index 740c318605..5c199460df 100644 --- a/rust/signed_doc/tests/proposal_submission_action.rs +++ b/rust/signed_doc/tests/proposal_submission_action.rs @@ -101,7 +101,8 @@ mod common; let template = proposal_form_template_doc(¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let proposal = proposal_doc(&template, ¶meters, provider).inspect(|v| provider.add_document(None, v).unwrap())?; let id = UuidV7::new(); - let (sk, kid) = create_dummy_key_pair(RoleId::Proposer).inspect(|(sk, kid)| provider.add_sk(kid.clone(), sk.clone()))?; + let (sk, kid) = create_dummy_key_pair(Some(RoleId::Proposer)); + provider.add_sk(kid.clone(), sk.clone()); Builder::new() .with_json_metadata(serde_json::json!({ "content-type": ContentType::Json, From 9a7bf9da2362fba74c04c3fe42111f5d3b81df93 Mon Sep 17 00:00:00 2001 From: Mr-Leshiy Date: Wed, 29 Oct 2025 19:59:27 +0700 Subject: [PATCH 2/4] wip --- rust/signed_doc/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/signed_doc/Cargo.toml b/rust/signed_doc/Cargo.toml index dad8eb185f..009eb8416e 100644 --- a/rust/signed_doc/Cargo.toml +++ b/rust/signed_doc/Cargo.toml @@ -11,7 +11,7 @@ license.workspace = true workspace = true [dependencies] -catalyst-types = { version = "0.0.10", git = "https://github.com/input-output-hk/catalyst-libs.git", branch = "feat/cat-id-admin" } +catalyst-types = { version = "0.0.10", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "catalyst-types/v0.0.10" } cbork-utils = { version = "0.0.2", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "cbork-utils-v0.0.2" } catalyst-signed-doc-macro = { version = "0.0.1", path = "../catalyst-signed-doc-macro" } From e06cd1c8f797a3cba9fc4ac3ceecb31835dae5d1 Mon Sep 17 00:00:00 2001 From: Mr-Leshiy Date: Wed, 29 Oct 2025 20:05:23 +0700 Subject: [PATCH 3/4] bump version --- rust/signed_doc/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/signed_doc/Cargo.toml b/rust/signed_doc/Cargo.toml index 009eb8416e..127a5dd511 100644 --- a/rust/signed_doc/Cargo.toml +++ b/rust/signed_doc/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "catalyst-signed-doc" -version = "0.0.9" +version = "0.0.10" edition.workspace = true authors.workspace = true homepage.workspace = true From d7fd231867a63e07ae9312af3e52206a5aeed2c1 Mon Sep 17 00:00:00 2001 From: Mr-Leshiy Date: Wed, 29 Oct 2025 21:58:24 +0700 Subject: [PATCH 4/4] fix --- rust/signed_doc/src/validator/rules/signature_kid.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/signed_doc/src/validator/rules/signature_kid.rs b/rust/signed_doc/src/validator/rules/signature_kid.rs index 9368fe7f93..be00ebb174 100644 --- a/rust/signed_doc/src/validator/rules/signature_kid.rs +++ b/rust/signed_doc/src/validator/rules/signature_kid.rs @@ -19,7 +19,7 @@ impl SignatureKidRule { /// Generating `SignatureKidRule` from specs pub(crate) fn new(spec: &Roles) -> anyhow::Result { anyhow::ensure!( - spec.user.is_empty() == !spec.admin.is_empty(), + spec.user.is_empty() != spec.admin.is_empty(), "If 'admin' is not empty 'user' roles cannot been specified'. And vice versa, if 'user' is not empty 'admin' roles cannot been specified'" );