Skip to content

Commit

Permalink
Improve the the allowed viewer output.
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-dfinity committed Sep 24, 2024
1 parent af477d3 commit cb345d8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
6 changes: 3 additions & 3 deletions e2e/tests-dfx/update_settings.bash
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ teardown() {

assert_command dfx canister update-settings --remove-log-viewer="${ALICE_PRINCIPAL}" e2e_project_backend
assert_command dfx canister status e2e_project_backend
assert_contains "Allowed List is empty"
assert_contains "allowed viewers list is empty"

assert_command dfx canister update-settings --add-log-viewer="${BOB_PRINCIPAL}" --add-log-viewer="${ALICE_PRINCIPAL}" e2e_project_backend
assert_command dfx canister status e2e_project_backend
Expand All @@ -127,7 +127,7 @@ teardown() {

assert_command dfx canister update-settings --remove-log-viewer="${ALICE_PRINCIPAL}" --remove-log-viewer="${BOB_PRINCIPAL}" e2e_project_backend
assert_command dfx canister status e2e_project_backend
assert_contains "Allowed List is empty"
assert_contains "allowed viewers list is empty"

assert_command dfx canister update-settings --set-log-viewer="${BOB_PRINCIPAL}" --set-log-viewer="${ALICE_PRINCIPAL}" e2e_project_backend
assert_command dfx canister status e2e_project_backend
Expand All @@ -148,7 +148,7 @@ teardown() {

assert_command dfx canister update-settings --remove-log-viewer="${ALICE_PRINCIPAL}" --all
assert_command dfx canister status e2e_project_backend
assert_contains "Allowed List is empty"
assert_contains "allowed viewers list is empty"

assert_command dfx canister update-settings --set-log-viewer="${ALICE_PRINCIPAL}" --all
assert_command dfx canister status e2e_project_backend
Expand Down
15 changes: 6 additions & 9 deletions src/dfx/src/commands/canister/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,13 @@ async fn canister_status(
let log_visibility = match status.settings.log_visibility {
LogVisibility::Controllers => "controllers".to_string(),
LogVisibility::Public => "public".to_string(),
LogVisibility::AllowedViewers(allowed_list) => {
if allowed_list.is_empty() {
"Allowed List is empty".to_string()
LogVisibility::AllowedViewers(viewers) => {
if viewers.is_empty() {
"allowed viewers list is empty".to_string()
} else {
let mut ids_str = "Allowed List:".to_string();
for principal in allowed_list {
ids_str.push(' ');
ids_str.push_str(principal.to_text().as_str());
}
ids_str
let mut viewers: Vec<_> = viewers.iter().map(Principal::to_text).collect();
viewers.sort();
format!("allowed viewers: {}", viewers.join(", "))
}
}
};
Expand Down

0 comments on commit cb345d8

Please sign in to comment.