Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): bump @oclif/core from 3.25.2 to 3.26.0 #917

Merged
merged 2 commits into from
Apr 1, 2024
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Salesforce",
"bugs": "https://github.com/forcedotcom/cli/issues",
"dependencies": {
"@oclif/core": "^3.23.0",
"@oclif/core": "^3.26.0",
"@salesforce/core": "^6.7.1",
"@salesforce/kit": "^3.0.15",
"@salesforce/sf-plugins-core": "^8.0.1",
Expand Down
95 changes: 41 additions & 54 deletions test/commands/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

import fs from 'node:fs';
import { AuthInfo, Connection, DefaultUserFields, Logger, Org, User } from '@salesforce/core';
import { Config } from '@oclif/core';
import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup.js';
import { expect } from 'chai';
import { assert, JsonMap } from '@salesforce/ts-types';
import { Config } from '@oclif/core';
import CreateUserCommand from '../../src/commands/org/create/user.js';

const username = '[email protected]';
Expand Down Expand Up @@ -48,7 +48,9 @@ describe('org:create:user', () => {
})
);

const createCommand = new CreateUserCommand(['-f', 'userConfig.json'], {} as Config);
const createCommand = new CreateUserCommand(['-f', 'userConfig.json'], {
runHook: () => ({ successes: [], failures: [] }),
} as unknown as Config);

// @ts-ignore
createCommand.flags = { 'definition-file': 'testing' };
Expand Down Expand Up @@ -177,19 +179,15 @@ describe('org:create:user', () => {
username: '[email protected]',
},
};
const createCommand = new CreateUserCommand(
[
'--json',
'--target-org',
testOrg.username,
'--definition-file',
'parent/child/file.json',
"permsets='permCLI, permCLI2'",
'generatepassword=true',
],
{} as Config
);
const result = await createCommand.run();
const result = await CreateUserCommand.run([
'--json',
'--target-org',
testOrg.username,
'--definition-file',
'parent/child/file.json',
"permsets='permCLI, permCLI2'",
'generatepassword=true',
]);
expect(result).to.deep.equal(expected);
});

Expand All @@ -212,8 +210,7 @@ describe('org:create:user', () => {
username: '[email protected]',
},
};
const createCommand = new CreateUserCommand(['--json', '--target-org', testOrg.username], {} as Config);
const result = await createCommand.run();
const result = await CreateUserCommand.run(['--json', '--target-org', testOrg.username]);
expect(result).to.deep.equal(expected);
});

Expand All @@ -237,19 +234,16 @@ describe('org:create:user', () => {
username: '[email protected]',
},
};
const createCommand = new CreateUserCommand(
[
'--json',
'--target-org',
testOrg.username,
'--definition-file',
'parent/child/file.json',
'[email protected]',
'generatepassword=false',
],
{} as Config
);
const result = await createCommand.run();
const result = await CreateUserCommand.run([
'--json',
'--target-org',
testOrg.username,
'--definition-file',
'parent/child/file.json',
'[email protected]',
'generatepassword=false',
]);

expect(result).to.deep.equal(expected);
});

Expand All @@ -272,11 +266,14 @@ describe('org:create:user', () => {
username: `[email protected].${testOrg.orgId}`,
},
};
const createCommand = new CreateUserCommand(
['--json', '--target-org', testOrg.username, '[email protected]', '--setuniqueusername'],
{} as Config
);
const result = await createCommand.run();
const result = await CreateUserCommand.run([
'--json',
'--target-org',
testOrg.username,
'[email protected]',
'--setuniqueusername',
]);

expect(result).to.deep.equal(expected);
});

Expand All @@ -299,11 +296,8 @@ describe('org:create:user', () => {
username: '[email protected]',
},
};
const createCommand = new CreateUserCommand(
['--json', '--target-org', testOrg.username, '--setuniqueusername'],
{} as Config
);
const result = await createCommand.run();
const result = await CreateUserCommand.run(['--json', '--target-org', testOrg.username, '--setuniqueusername']);

expect(result).to.deep.equal(expected);
});

Expand All @@ -327,8 +321,7 @@ describe('org:create:user', () => {
username: '[email protected]',
},
};
const createCommand = new CreateUserCommand(['--json', '--target-org', testOrg.username], {} as Config);
const result = await createCommand.run();
const result = await CreateUserCommand.run(['--json', '--target-org', testOrg.username]);
expect(result).to.deep.equal(expected);
});

Expand All @@ -351,8 +344,7 @@ describe('org:create:user', () => {
username: '[email protected]',
},
};
const createCommand = new CreateUserCommand(['--json', '--target-org', testOrg.username], {} as Config);
const result = await createCommand.run();
const result = await CreateUserCommand.run(['--json', '--target-org', testOrg.username]);
expect(result).to.deep.equal(expected);
});

Expand All @@ -375,18 +367,16 @@ describe('org:create:user', () => {
username: '[email protected]',
},
};
const createCommand = new CreateUserCommand(['--json', '--target-org', testOrg.username], {} as Config);
const result = await createCommand.run();
const result = await CreateUserCommand.run(['--json', '--target-org', testOrg.username]);
expect(result).to.deep.equal(expected);
});
});

describe('exceptions', () => {
it('throws if org is not a scratchOrg', async () => {
await prepareStubs({ nonScratch: true }, false);
const createCommand = new CreateUserCommand(['--json', '--target-org', testOrg.username], {} as Config);
try {
await createCommand.run();
await CreateUserCommand.run(['--json', '--target-org', testOrg.username]);
expect.fail('should have thrown an error');
} catch (e) {
assert(e instanceof Error);
Expand All @@ -396,9 +386,8 @@ describe('org:create:user', () => {

it('throws if JWT and hyperforce', async () => {
await prepareStubs({ isJWT: true, createdOrgInstance: 'USA100S' }, false);
const createCommand = new CreateUserCommand(['--json', '--target-org', testOrg.username], {} as Config);
try {
await createCommand.run();
await CreateUserCommand.run(['--json', '--target-org', testOrg.username]);
expect.fail('should have thrown an error');
} catch (e) {
assert(e instanceof Error);
Expand All @@ -408,9 +397,8 @@ describe('org:create:user', () => {

it('will handle a failed `createUser` call with a licenseLimitExceeded error', async () => {
await prepareStubs({ license: true }, false);
const createCommand = new CreateUserCommand(['--json', '--target-org', testOrg.username], {} as Config);
try {
await createCommand.run();
await CreateUserCommand.run(['--json', '--target-org', testOrg.username]);
expect.fail('should have thrown an error');
} catch (e) {
assert(e instanceof Error);
Expand All @@ -421,9 +409,8 @@ describe('org:create:user', () => {

it('will handle a failed `createUser` call with a DuplicateUsername error', async () => {
await prepareStubs({ duplicate: true }, true);
const createCommand = new CreateUserCommand(['--json', '--target-org', testOrg.username], {} as Config);
try {
await createCommand.run();
await CreateUserCommand.run(['--json', '--target-org', testOrg.username]);
expect.fail('should have thrown an error');
} catch (e) {
assert(e instanceof Error);
Expand Down
10 changes: 2 additions & 8 deletions test/commands/display.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import { AuthInfo, Connection, Org } from '@salesforce/core';
import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup.js';
import { expect } from 'chai';
import { Config } from '@oclif/core';
import { DisplayUserCommand } from '../../src/commands/org/display/user.js';

const username = '[email protected]';
Expand Down Expand Up @@ -81,8 +80,7 @@ describe('org:display:user', () => {
profileName: 'profileName',
username: '[email protected]',
};
const displayCommand = new DisplayUserCommand(['--json', '--target-org', defaultOrg.username], {} as Config);
const result = await displayCommand.run();
const result = await DisplayUserCommand.run(['--json', '--target-org', defaultOrg.username]);
expect(result).to.deep.equal(expected);
});

Expand All @@ -99,11 +97,7 @@ describe('org:display:user', () => {
profileName: 'QueriedName',
username: defaultOrg.username,
};
const displayCommand = new DisplayUserCommand(
['--json', '--targetusername', '[email protected]'],
{} as Config
);
const result = await displayCommand.run();
const result = await DisplayUserCommand.run(['--json', '--targetusername', '[email protected]']);
expect(result).to.deep.equal(expected);
});
});
7 changes: 2 additions & 5 deletions test/commands/list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import { Connection, Org } from '@salesforce/core';
import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup.js';
import { Config } from '@oclif/core';
import { expect } from 'chai';
import { ListUsersCommand } from '../../src/commands/org/list/users.js';

Expand Down Expand Up @@ -131,14 +130,12 @@ describe('org:list:users', () => {
});

it('should display the correct information invoked with an alias', async () => {
const listComm = new ListUsersCommand(['--json', '--target-org', 'testAlias'], {} as Config);
const result = await listComm.run();
const result = await ListUsersCommand.run(['--json', '--target-org', 'testAlias']);
expect(result).to.deep.equal(expected);
});

it('should display the correct information invoked by name', async () => {
const listComm = new ListUsersCommand(['--json', '--target-org', user1], {} as Config);
const result = await listComm.run();
const result = await ListUsersCommand.run(['--json', '--target-org', user1]);
expect(result).to.deep.equal(expected);
});
});
43 changes: 18 additions & 25 deletions test/commands/password/generate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { Connection, Messages, User } from '@salesforce/core';
import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup.js';
import { SecureBuffer } from '@salesforce/core/lib/crypto/secureBuffer.js';
import { assert, expect } from 'chai';
import { Config } from '@oclif/core';
import { PasswordData, GenerateUserPasswordCommand } from '../../../src/commands/org/generate/password.js';

Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
Expand All @@ -18,16 +17,6 @@ const messages = Messages.loadMessages('@salesforce/plugin-user', 'password.gene
describe('org:generate:password', () => {
const $$ = new TestContext();

class GenerateUserPasswordCommandTest extends GenerateUserPasswordCommand {
public constructor(argv: string[], config: Config) {
super(argv, config);
}

public async run(): Promise<PasswordData | PasswordData[]> {
return super.run();
}
}

const testOrg = new MockTestOrgData();
let queryStub: sinon.SinonStub;

Expand Down Expand Up @@ -65,36 +54,40 @@ describe('org:generate:password', () => {
password: 'abc',
},
];
const passwordGenerate = new GenerateUserPasswordCommandTest(
['--target-org', testOrg.username, '--json', '--on-behalf-of', '[email protected]', '[email protected]'],
{} as Config
);
const result = await passwordGenerate.run();

const result = await GenerateUserPasswordCommand.run([
'--target-org',
testOrg.username,
'--json',
'--on-behalf-of',
'[email protected]',
'[email protected]',
]);
expect(result).to.deep.equal(expected);
expect(queryStub.callCount).to.equal(2);
});
it('should generate a new password for the default user', async () => {
await prepareStubs();
const expected = { username: testOrg.username, password: 'abc' };
const passwordGenerate = new GenerateUserPasswordCommandTest(['--json'], {} as Config);
const result = await passwordGenerate.run();
const result = await GenerateUserPasswordCommand.run(['--json']);
expect(result).to.deep.equal(expected);
expect(queryStub.callCount).to.equal(1);
});
it('should generate a new passsword of length 12', async () => {
await prepareStubs(false, false);
const passwordGenerate = new GenerateUserPasswordCommandTest(
['--target-org', testOrg.username, '-l', '12', '--json'],
{} as Config
);
const result = (await passwordGenerate.run()) as PasswordData;
const result = (await GenerateUserPasswordCommand.run([
'--target-org',
testOrg.username,
'-l',
'12',
'--json',
])) as PasswordData;
expect(result.password.length).to.equal(12);
});
it('should throw the correct error with warning message', async () => {
await prepareStubs(true);
const passwordGenerate = new GenerateUserPasswordCommandTest(['--json'], {} as Config);
try {
await passwordGenerate.run();
await GenerateUserPasswordCommand.run(['--json']);
expect.fail('should have thrown an error');
} catch (result) {
assert(result instanceof Error);
Expand Down
29 changes: 10 additions & 19 deletions test/commands/permset/assign.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,11 @@
import { Connection, User } from '@salesforce/core';
import { MockTestOrgData, TestContext } from '@salesforce/core/lib/testSetup.js';
import { expect } from 'chai';
import { Config } from '@oclif/core';
import { AssignPermSetCommand } from '../../../src/commands/org/assign/permset.js';
import { PermsetAssignResult } from '../../../src/baseCommands/user/permset/assign.js';

describe('org:assign:permset', () => {
const $$ = new TestContext();

class AssignPermSetCommandTest extends AssignPermSetCommand {
public constructor(argv: string[], config: Config) {
super(argv, config);
}

public async run(): Promise<PermsetAssignResult> {
return super.run();
}
}

const testOrg = new MockTestOrgData();
testOrg.username = '[email protected]';

Expand Down Expand Up @@ -69,11 +57,15 @@ describe('org:assign:permset', () => {
value: 'LargeDreamHouse',
},
];
const userPermSetAssign = new AssignPermSetCommandTest(
['--json', '--on-behalf-of', 'testAlias', '[email protected]', '--name', 'DreamHouse', 'LargeDreamHouse'],
{} as Config
);
const result = await userPermSetAssign.run();
const result = await AssignPermSetCommand.run([
'--json',
'--on-behalf-of',
'testAlias',
'[email protected]',
'--name',
'DreamHouse',
'LargeDreamHouse',
]);
expect(result.successes).to.deep.equal(expected);
});
it('should fail with the correct error message', async () => {
Expand All @@ -85,8 +77,7 @@ describe('org:assign:permset', () => {
message: 'Permission set "abc" not found in target org. Do you need to push source?',
},
];
const userPermSetAssign = new AssignPermSetCommandTest(['--json', '--permsetname', 'PERM2'], {} as Config);
const result = await userPermSetAssign.run();
const result = await AssignPermSetCommand.run(['--json', '--permsetname', 'PERM2']);
expect(result.failures).to.deep.equal(expected);
});
});
Loading
Loading