diff --git a/ic-utils/src/interfaces/management_canister.rs b/ic-utils/src/interfaces/management_canister.rs index 99336c12..7d833c69 100644 --- a/ic-utils/src/interfaces/management_canister.rs +++ b/ic-utils/src/interfaces/management_canister.rs @@ -149,7 +149,7 @@ pub struct QueryStats { } /// Log visibility for a canister. -#[derive(Default, Clone, Copy, CandidType, Deserialize, Debug, PartialEq, Eq)] +#[derive(Default, Clone, CandidType, Deserialize, Debug, PartialEq, Eq)] pub enum LogVisibility { #[default] #[serde(rename = "controllers")] @@ -158,6 +158,9 @@ pub enum LogVisibility { #[serde(rename = "public")] /// Canister logs are visible to everyone. Public, + #[serde(rename = "allowed_viewers")] + /// Canister logs are visible to a set of principals. + AllowedViewers(Vec), } /// The concrete settings of a canister. diff --git a/ref-tests/tests/ic-ref.rs b/ref-tests/tests/ic-ref.rs index fb4e9f32..3c48cff3 100644 --- a/ref-tests/tests/ic-ref.rs +++ b/ref-tests/tests/ic-ref.rs @@ -1008,7 +1008,7 @@ mod extras { use ic_agent::{ agent::{RejectCode, RejectResponse}, export::Principal, - AgentError, + AgentError, Identity, }; use ic_utils::{ call::AsyncCall, @@ -1017,8 +1017,7 @@ mod extras { ManagementCanister, }, }; - use ref_tests::get_effective_canister_id; - use ref_tests::with_agent; + use ref_tests::{create_basic_identity, get_effective_canister_id, with_agent}; #[ignore] #[test] @@ -1350,6 +1349,7 @@ mod extras { with_agent(|agent| async move { let ic00 = ManagementCanister::create(&agent); + // Create with Controllers. let (canister_id,) = ic00 .create_canister() .as_provisional_create_with_amount(Some(20_000_000_000_000_u128)) @@ -1361,6 +1361,7 @@ mod extras { let result = ic00.canister_status(&canister_id).call_and_wait().await?; assert_eq!(result.0.settings.log_visibility, LogVisibility::Controllers); + // Update to Public. ic00.update_settings(&canister_id) .with_log_visibility(LogVisibility::Public) .call_and_wait() @@ -1369,6 +1370,7 @@ mod extras { let result = ic00.canister_status(&canister_id).call_and_wait().await?; assert_eq!(result.0.settings.log_visibility, LogVisibility::Public); + // Update with no change. let no_change: Option = None; ic00.update_settings(&canister_id) .with_optional_log_visibility(no_change) @@ -1378,6 +1380,19 @@ mod extras { let result = ic00.canister_status(&canister_id).call_and_wait().await?; assert_eq!(result.0.settings.log_visibility, LogVisibility::Public); + // Update to AllowedViewers. + let principals = vec![create_basic_identity()?.sender()?]; + ic00.update_settings(&canister_id) + .with_log_visibility(LogVisibility::AllowedViewers(principals.clone())) + .call_and_wait() + .await?; + + let result = ic00.canister_status(&canister_id).call_and_wait().await?; + assert_eq!( + result.0.settings.log_visibility, + LogVisibility::AllowedViewers(principals) + ); + Ok(()) }) }