Skip to content
Open
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
10 changes: 10 additions & 0 deletions src/m365/spo/commands/user/user-get.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,16 @@ describe(commands.USER_GET, () => {
assert.notStrictEqual(actual, true);
});

it('fails validation if id is a negative number', async () => {
const actual = await command.validate({ options: { webUrl: validWebUrl, id: -1 } }, commandInfo);
assert.notStrictEqual(actual, true);
});

it('fails validation if id is a float number', async () => {
const actual = await command.validate({ options: { webUrl: validWebUrl, id: 1.5 } }, commandInfo);
assert.notStrictEqual(actual, true);
});

it('fails validation if userName is not a valid user principal name', async () => {
const actual = await command.validate({ options: { webUrl: validWebUrl, userName: 'invalid' } }, commandInfo);
assert.notStrictEqual(actual, true);
Expand Down
7 changes: 3 additions & 4 deletions src/m365/spo/commands/user/user-get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,14 @@ class SpoUserGetCommand extends SpoCommand {
}

#initTypes(): void {
this.types.string.push('webUrl', 'id', 'email', 'loginName', 'userName', 'entraGroupId', 'entraGroupName');
this.types.string.push('webUrl', 'email', 'loginName', 'userName', 'entraGroupId', 'entraGroupName');
}

#initValidators(): void {
this.validators.push(
async (args: CommandArgs) => {
if (args.options.id &&
typeof args.options.id !== 'number') {
return `Specified id ${args.options.id} is not a number`;
if (args.options.id && !validation.isValidPositiveInteger(args.options.id)) {
return `Specified id ${args.options.id} is not a valid number.`;
}
Comment thread
milanholemans marked this conversation as resolved.

if (args.options.entraGroupId && !validation.isValidGuid(args.options.entraGroupId)) {
Expand Down