Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ members = [
]

[patch.crates-io.ic-agent]
version = "0.2.0"
version = "0.3.0"
git = "https://github.com/dfinity/agent-rs.git"
branch = "next"
rev = "5472fb610faa6cc1f0c12c82a745e435603fae08"
branch = "pshahi/update-create-settings"
rev = "39b19c7d23b9745ab366d1947d7fc30b286c55f8"

[patch.crates-io.ic-identity-hsm]
version = "0.2.0"
version = "0.2.1"
git = "https://github.com/dfinity/agent-rs.git"
branch = "next"
rev = "5472fb610faa6cc1f0c12c82a745e435603fae08"
branch = "pshahi/update-create-settings"
rev = "39b19c7d23b9745ab366d1947d7fc30b286c55f8"

[patch.crates-io.ic-types]
version = "0.1.2"
git = "https://github.com/dfinity/agent-rs.git"
branch = "next"
rev = "5472fb610faa6cc1f0c12c82a745e435603fae08"
branch = "pshahi/update-create-settings"
rev = "39b19c7d23b9745ab366d1947d7fc30b286c55f8"

[patch.crates-io.ic-utils]
version = "0.2.0"
version = "0.2.1"
git = "https://github.com/dfinity/agent-rs.git"
branch = "next"
rev = "5472fb610faa6cc1f0c12c82a745e435603fae08"
branch = "pshahi/update-create-settings"
rev = "39b19c7d23b9745ab366d1947d7fc30b286c55f8"
68 changes: 0 additions & 68 deletions e2e/tests-dfx/controller.bash

This file was deleted.

72 changes: 72 additions & 0 deletions e2e/tests-dfx/update_settings.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env bats

load utils/_

setup() {
# We want to work from a temporary directory, different for every test.
cd $(mktemp -d -t dfx-e2e-XXXXXXXX)

# Each test gets its own home directory in order to have its own identities.
mkdir $(pwd)/home-for-test
export HOME=$(pwd)/home-for-test

dfx_new hello
}

teardown() {
dfx_stop
rm -rf $(pwd)/home-for-test
}

@test "update controller" {
# Create two identities and get their Principals
assert_command dfx identity new jose
assert_command dfx identity new juana
JOSE_PRINCIPAL=$(dfx --identity jose identity get-principal)
JUANA_PRINCIPAL=$(dfx --identity juana identity get-principal)

assert_command dfx identity use jose

dfx_start
dfx canister create hello
dfx build hello
dfx canister install hello
ID=$(dfx canister id hello)

# Set controller using canister name and identity name
assert_command dfx canister update-settings hello --controller juana
assert_match "Updated \"juana\" as controller of \"hello\"."

# Juana is controller, Jose cannot reinstall
assert_command_fail dfx canister install hello -m reinstall
if [ "$USE_IC_REF" ]
then
assert_match "${JOSE_PRINCIPAL} is not authorized to manage canister ${ID}"
else
assert_match "Only the controller of canister ${ID} can control it."
fi

# Juana can reinstall
assert_command dfx --identity juana canister install hello -m reinstall

assert_command dfx identity use juana
# Set controller using canister id and principal
assert_command dfx canister update-settings ${ID} --controller ${JOSE_PRINCIPAL}
assert_match "Updated \"${JOSE_PRINCIPAL}\" as controller of \"${ID}\"."
assert_command_fail dfx canister install hello -m reinstall

# Set controller using combination of name/id and identity/principal
assert_command dfx --identity jose canister update-settings hello --controller ${JUANA_PRINCIPAL}
assert_match "Updated \"${JUANA_PRINCIPAL}\" as controller of \"hello\"."

assert_command dfx --identity juana canister update-settings ${ID} --controller jose
assert_match "Updated \"jose\" as controller of \"${ID}\"."

# Set controller using invalid principal/identity fails
assert_command_fail dfx --identity jose canister update-settings hello --controller bob
assert_match "Identity bob does not exist"

# Set controller using invalid canister name/id fails
assert_command_fail dfx --identity jose canister update-settings hello_assets --controller juana
assert_match "Cannot find canister id. Please issue 'dfx canister create hello_assets'."
}
4 changes: 2 additions & 2 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
},
"ic-ref": {
"repo": "ssh://git@github.com/dfinity-lab/ic-ref",
"rev": "215641629ace2d590013f89bb3f3fe3b0a0d3c3b",
"tag": "0.16.0",
"rev": "a858395300d67685545e945dd4afd4b6af26c1a6",
"tag": "0.17.0",
"type": "git"
},
"motoko": {
Expand Down
22 changes: 11 additions & 11 deletions src/dfx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,29 +73,29 @@ wasmparser = "0.45.0"
webpki-roots = "0.21.0"

[dependencies.ic-agent]
version = "0.2.0"
version = "0.3.0"
git = "https://github.com/dfinity/agent-rs.git"
branch = "next"
rev = "5472fb610faa6cc1f0c12c82a745e435603fae08"
branch = "pshahi/update-create-settings"
rev = "39b19c7d23b9745ab366d1947d7fc30b286c55f8"
features = ["reqwest"]

[dependencies.ic-identity-hsm]
version = "0.2.0"
version = "0.2.1"
git = "https://github.com/dfinity/agent-rs.git"
branch = "next"
rev = "5472fb610faa6cc1f0c12c82a745e435603fae08"
branch = "pshahi/update-create-settings"
rev = "39b19c7d23b9745ab366d1947d7fc30b286c55f8"

[dependencies.ic-types]
version = "0.1.2"
git = "https://github.com/dfinity/agent-rs.git"
branch = "next"
rev = "5472fb610faa6cc1f0c12c82a745e435603fae08"
branch = "pshahi/update-create-settings"
rev = "39b19c7d23b9745ab366d1947d7fc30b286c55f8"

[dependencies.ic-utils]
version = "0.2.0"
version = "0.2.1"
git = "https://github.com/dfinity/agent-rs.git"
branch = "next"
rev = "5472fb610faa6cc1f0c12c82a745e435603fae08"
branch = "pshahi/update-create-settings"
rev = "39b19c7d23b9745ab366d1947d7fc30b286c55f8"

[dev-dependencies]
env_logger = "0.6"
Expand Down
8 changes: 5 additions & 3 deletions src/dfx/src/commands/canister/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ use candid::{CandidType, Decode, Deserialize};
use clap::{ArgSettings, Clap};
use ic_types::principal::Principal as CanisterId;
use ic_utils::canister::{Argument, Canister};
use ic_utils::interfaces::management_canister::{CanisterInstall, MgmtMethod};
use ic_utils::interfaces::management_canister::builders::{CanisterInstall, CanisterSettings};
use ic_utils::interfaces::management_canister::MgmtMethod;
use ic_utils::interfaces::wallet::{CallForwarder, CallResult};
use ic_utils::interfaces::Wallet;
use std::option::Option;
Expand Down Expand Up @@ -123,11 +124,11 @@ pub fn get_effective_canister_id(
let install_args = candid::Decode!(arg_value, CanisterInstall)?;
Ok(install_args.canister_id)
}
MgmtMethod::SetController => {
MgmtMethod::UpdateSettings => {
#[derive(CandidType, Deserialize)]
struct In {
canister_id: CanisterId,
new_controller: CanisterId,
settings: CanisterSettings,
}
let in_args = candid::Decode!(arg_value, In)?;
Ok(in_args.canister_id)
Expand All @@ -137,6 +138,7 @@ pub fn get_effective_canister_id(
| MgmtMethod::CanisterStatus
| MgmtMethod::DeleteCanister
| MgmtMethod::DepositCycles
| MgmtMethod::UninstallCode
| MgmtMethod::ProvisionalTopUpCanister => {
#[derive(CandidType, Deserialize)]
struct In {
Expand Down
Loading