From c19d1b6c8e590bffb88444968e401fd15ded0c34 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan <103510076+maksymar@users.noreply.github.com> Date: Fri, 6 Sep 2024 21:10:15 +0200 Subject: [PATCH] feat: add AllowedViewers to LogVisibility enum (#588) --- CHANGELOG.md | 1 + ic-utils/src/interfaces/management_canister.rs | 5 ++++- ref-tests/tests/ic-ref.rs | 6 ++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96d1e030..cf64bc12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Breaking: Removed `Transport` and the `hyper` and `reqwest` features. `ReqwestTransport` is now the default and `HyperTransport` has been removed. Existing `ReqwestTransport` functions have been moved to `AgentBuilder`. * `Url` now implements `RouteProvider`. * Add canister snapshot methods to `ManagementCanister`. +* Add `AllowedViewers` to `LogVisibility` enum. ## [0.37.1] - 2024-07-25 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..b0fb6975 100644 --- a/ref-tests/tests/ic-ref.rs +++ b/ref-tests/tests/ic-ref.rs @@ -1017,8 +1017,7 @@ mod extras { ManagementCanister, }, }; - use ref_tests::get_effective_canister_id; - use ref_tests::with_agent; + use ref_tests::{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)