Skip to content

Commit

Permalink
Changed local wallet name displayed when trying to delete identity (c…
Browse files Browse the repository at this point in the history
…loses IBM-Blockchain#1509). (IBM-Blockchain#1534)

Signed-off-by: Leonor Quintais <lquintai@uk.ibm.com>
  • Loading branch information
lquintai authored and cazfletch committed Oct 15, 2019
1 parent 376788b commit 650498b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cucumber/helpers/walletAndIdentityHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class WalletAndIdentityHelper {

if (identityExists) {
this.userInputUtilHelper.showWalletsQuickPickStub.withArgs('Choose the wallet containing the identity that you want to delete').resolves({
label: FabricWalletUtil.LOCAL_WALLET,
label: FabricWalletUtil.LOCAL_WALLET_DISPLAY_NAME,
data: walletEntry
});
this.userInputUtilHelper.showIdentitiesQuickPickStub.withArgs('Choose the identities to delete').resolves([name]);
Expand Down
3 changes: 2 additions & 1 deletion extension/commands/UserInputUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import { FabricEnvironment } from '../fabric/FabricEnvironment';
import { FabricEnvironmentRegistry } from '../registries/FabricEnvironmentRegistry';
import { FabricRuntimeUtil } from '../fabric/FabricRuntimeUtil';
import { FabricChaincode } from '../fabric/FabricChaincode';
import { FabricWalletUtil } from '../fabric/FabricWalletUtil';

export interface IBlockchainQuickPickItem<T = undefined> extends vscode.QuickPickItem {
data: T;
Expand Down Expand Up @@ -870,7 +871,7 @@ export class UserInputUtil {
const wallets: Array<FabricWalletRegistryEntry> = await FabricWalletRegistry.instance().getAll(showLocalWallet);
for (const walletRegistryEntry of wallets) {
walletQuickPickItems.push({
label: walletRegistryEntry.name,
label: walletRegistryEntry.name !== FabricWalletUtil.LOCAL_WALLET ? walletRegistryEntry.name : FabricWalletUtil.LOCAL_WALLET_DISPLAY_NAME,
data: walletRegistryEntry
});
}
Expand Down
4 changes: 2 additions & 2 deletions extension/commands/deleteIdentityCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ export async function deleteIdentity(treeItem: IdentityTreeItem): Promise<void>
walletPath = wallet.getWalletPath();
let identityNames: string[] = await wallet.getIdentityNames();

if (chosenWallet.label === FabricWalletUtil.LOCAL_WALLET) {
if (chosenWallet.label === FabricWalletUtil.LOCAL_WALLET_DISPLAY_NAME) {
// If the local wallet was selected, we should filter out the admin identity
identityNames = identityNames.filter((identity: string) => {
return identity !== FabricRuntimeUtil.ADMIN_USER;
});
}

if (chosenWallet.label === FabricWalletUtil.LOCAL_WALLET && identityNames.length === 0) {
if (chosenWallet.label === FabricWalletUtil.LOCAL_WALLET_DISPLAY_NAME && identityNames.length === 0) {
outputAdapter.log(LogType.ERROR, `No identities to delete in wallet: ${chosenWallet.label}. The ${FabricRuntimeUtil.ADMIN_USER} identity cannot be deleted.`, `No identities to delete in wallet: ${chosenWallet.label}. The ${FabricRuntimeUtil.ADMIN_USER} identity cannot be deleted.`);
return;
} else if (identityNames.length === 0) {
Expand Down
2 changes: 1 addition & 1 deletion test/commands/UserInputUtil.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1853,7 +1853,7 @@ describe('UserInputUtil', () => {
quickPickStub.resolves();
await UserInputUtil.showWalletsQuickPickBox('Choose a wallet', false, true);
quickPickStub.should.have.been.calledWith([
{ label: localWalletEntry.name, data: localWalletEntry },
{ label: FabricWalletUtil.LOCAL_WALLET_DISPLAY_NAME, data: localWalletEntry },
{ label: walletEntryTwo.name, data: walletEntryTwo },
{ label: walletEntryOne.name, data: walletEntryOne }]);
});
Expand Down
6 changes: 3 additions & 3 deletions test/commands/deleteIdentityCommand.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,12 @@ describe('deleteIdentityCommand', () => {

const runtimeWalletRegistryEntry: FabricWalletRegistryEntry = new FabricWalletRegistryEntry();

runtimeWalletRegistryEntry.name = FabricWalletUtil.LOCAL_WALLET;
runtimeWalletRegistryEntry.name = FabricWalletUtil.LOCAL_WALLET_DISPLAY_NAME;
runtimeWalletRegistryEntry.walletPath = 'wallet_path';
runtimeWalletRegistryEntry.managedWallet = true;

showWalletsQuickPickStub.resolves({
label: FabricWalletUtil.LOCAL_WALLET,
label: runtimeWalletRegistryEntry.name,
data: runtimeWalletRegistryEntry
});
walletIdentitiesStub.resolves([]);
Expand Down Expand Up @@ -255,7 +255,7 @@ describe('deleteIdentityCommand', () => {
runtimeWalletRegistryEntry.managedWallet = true;

showWalletsQuickPickStub.resolves({
label: FabricWalletUtil.LOCAL_WALLET,
label: FabricWalletUtil.LOCAL_WALLET_DISPLAY_NAME,
data: runtimeWalletRegistryEntry
});
walletIdentitiesStub.resolves([FabricRuntimeUtil.ADMIN_USER, identityName]);
Expand Down

0 comments on commit 650498b

Please sign in to comment.