Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions e2e/bats/identity_command.bash
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ teardown() {

@test "identity new: creates a new identity" {
assert_command dfx identity new alice
assert_match 'Creating identity: "alice".' "$stderr"
assert_match 'Created identity: "alice".' "$stderr"
assert_command head $HOME/.config/dfx/identity/alice/identity.pem
assert_match "BEGIN PRIVATE KEY"

Expand Down Expand Up @@ -78,6 +80,8 @@ teardown() {
assert_match 'alice default'

assert_command dfx identity remove alice
assert_match 'Removing identity "alice".' "$stderr"
assert_match 'Removed identity "alice".' "$stderr"
assert_command_fail cat $HOME/.config/dfx/identity/alice/identity.pem

assert_command dfx identity list
Expand Down Expand Up @@ -124,6 +128,8 @@ teardown() {
local key=$(cat $HOME/.config/dfx/identity/alice/identity.pem)

assert_command dfx identity rename alice bob
assert_match 'Renaming identity "alice" to "bob".' "$stderr"
assert_match 'Renamed identity "alice" to "bob".' "$stderr"

assert_command dfx identity list
assert_match 'bob default'
Expand Down Expand Up @@ -209,6 +215,7 @@ teardown() {
assert_command dfx identity whoami
assert_eq 'default' "$stdout"
assert_match 'Creating the "default" identity.' "$stderr"
assert_match 'Created the "default" identity.' "$stderr"
}

@test "identity whoami: shows the current identity" {
Expand Down
5 changes: 4 additions & 1 deletion src/dfx/src/commands/identity/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult {
let log = env.get_logger();
info!(log, r#"Creating identity: "{}"."#, name);

IdentityManager::new(env)?.create_new_identity(name)
IdentityManager::new(env)?.create_new_identity(name)?;

info!(log, r#"Created identity: "{}"."#, name);
Ok(())
}
5 changes: 4 additions & 1 deletion src/dfx/src/commands/identity/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult {
let log = env.get_logger();
info!(log, r#"Removing identity "{}"."#, name);

IdentityManager::new(env)?.remove(name)
IdentityManager::new(env)?.remove(name)?;

info!(log, r#"Removed identity "{}"."#, name);
Ok(())
}
1 change: 1 addition & 0 deletions src/dfx/src/commands/identity/rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult {

let renamed_default = IdentityManager::new(env)?.rename(from, to)?;

info!(log, r#"Renamed identity "{}" to "{}"."#, from, to);
if renamed_default {
info!(log, r#"Now using identity: "{}"."#, to);
}
Expand Down
1 change: 1 addition & 0 deletions src/dfx/src/lib/identity/identity_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ fn initialize(
default: String::from(DEFAULT_IDENTITY_NAME),
};
write_configuration(&identity_json_path, &config)?;
slog::info!(logger, r#"Created the "default" identity."#);

Ok(config)
}
Expand Down