diff --git a/e2e/tests-dfx/create.bash b/e2e/tests-dfx/create.bash index 9c15e48f77..083958e6e6 100644 --- a/e2e/tests-dfx/create.bash +++ b/e2e/tests-dfx/create.bash @@ -352,3 +352,35 @@ teardown() { assert_contains 'Freezing threshold: 2_592_000' assert_contains 'Log visibility: controllers' } + +@test "create with log allowed viewer list" { + skip + + # Create two identities + assert_command dfx identity new --storage-mode plaintext alice + assert_command dfx identity new --storage-mode plaintext bob + ALICE_PRINCIPAL=$(dfx identity get-principal --identity alice) + BOB_PRINCIPAL=$(dfx identity get-principal --identity bob) + + jq '.canisters.e2e_project_backend.initialization_values={ + "compute_allocation": 5, + "freezing_threshold": "7days", + "memory_allocation": "2 GiB", + "reserved_cycles_limit": 1000000000000, + "wasm_memory_limit": "1 GiB", + "log_visibility": { + "allowed_viewers" : + ['\""$ALICE_PRINCIPAL"\"', '\""$BOB_PRINCIPAL"\"'] + } + }' dfx.json | sponge dfx.json + dfx_start + assert_command dfx deploy e2e_project_backend --no-wallet + assert_command dfx canister status e2e_project_backend + assert_contains 'Memory allocation: 2_147_483_648' + assert_contains 'Compute allocation: 5' + assert_contains 'Reserved cycles limit: 1_000_000_000_000' + assert_contains 'Wasm memory limit: 1_073_741_824' + assert_contains 'Freezing threshold: 604_800' + assert_contains "${ALICE_PRINCIPAL}" + assert_contains "${BOB_PRINCIPAL}" +} diff --git a/e2e/tests-dfx/update_settings.bash b/e2e/tests-dfx/update_settings.bash index 63af5cb86f..95ba451392 100644 --- a/e2e/tests-dfx/update_settings.bash +++ b/e2e/tests-dfx/update_settings.bash @@ -66,6 +66,8 @@ teardown() { dfx_start assert_command dfx deploy e2e_project_backend assert_command dfx canister status e2e_project_backend + + # Test against a single canister. assert_contains "Log visibility: controllers" assert_command dfx canister update-settings e2e_project_backend --log-visibility public assert_command dfx canister status e2e_project_backend @@ -73,6 +75,80 @@ teardown() { assert_command dfx canister update-settings e2e_project_backend --log-visibility controllers assert_command dfx canister status e2e_project_backend assert_contains "Log visibility: controllers" + + # Test --all code path. + assert_command dfx canister update-settings --log-visibility public --all + assert_command dfx canister status e2e_project_backend + assert_contains "Log visibility: public" + assert_command dfx canister update-settings --log-visibility controllers --all + assert_command dfx canister status e2e_project_backend + assert_contains "Log visibility: controllers" +} + +@test "update log allowed viewer list" { + skip + + # Create two identities + assert_command dfx identity new --storage-mode plaintext alice + assert_command dfx identity new --storage-mode plaintext bob + ALICE_PRINCIPAL=$(dfx identity get-principal --identity alice) + BOB_PRINCIPAL=$(dfx identity get-principal --identity bob) + + dfx_new + dfx_start + assert_command dfx deploy e2e_project_backend + assert_command dfx canister status e2e_project_backend + assert_contains "Log visibility: controllers" + + # Test against a single canister. + assert_command dfx canister update-settings --add-log-viewer="${ALICE_PRINCIPAL}" e2e_project_backend + assert_command dfx canister status e2e_project_backend + assert_contains "${ALICE_PRINCIPAL}" + + assert_command dfx canister update-settings --add-log-viewer="${BOB_PRINCIPAL}" --remove-log-viewer="${ALICE_PRINCIPAL}" e2e_project_backend + assert_command dfx canister status e2e_project_backend + assert_contains "${BOB_PRINCIPAL}" + assert_not_contains "${ALICE_PRINCIPAL}" + + assert_command dfx canister update-settings --set-log-viewer="${ALICE_PRINCIPAL}" e2e_project_backend + assert_command dfx canister status e2e_project_backend + assert_contains "${ALICE_PRINCIPAL}" + assert_not_contains "${BOB_PRINCIPAL}" + + 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_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 + assert_contains "${ALICE_PRINCIPAL}" + assert_contains "${BOB_PRINCIPAL}" + + 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_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 + assert_contains "${ALICE_PRINCIPAL}" + assert_contains "${BOB_PRINCIPAL}" + + assert_command dfx canister update-settings --log-visibility controllers e2e_project_backend + assert_command dfx canister status e2e_project_backend + assert_contains "Log visibility: controllers" + + # Test --all code path. + assert_command dfx canister update-settings --add-log-viewer="${ALICE_PRINCIPAL}" --all + assert_command dfx canister status e2e_project_backend + assert_contains "${ALICE_PRINCIPAL}" + + 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_command dfx canister update-settings --set-log-viewer="${ALICE_PRINCIPAL}" --all + assert_command dfx canister status e2e_project_backend + assert_contains "${ALICE_PRINCIPAL}" } @test "set controller" {