Skip to content

Commit

Permalink
All entra m365group commands should accept displayName option
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinM85 committed Oct 17, 2024
1 parent 87ec74c commit de1d242
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 64 deletions.
12 changes: 6 additions & 6 deletions docs/docs/cmd/entra/m365group/m365group-user-remove.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ m365 entra m365group user remove [options]

```md definition-list
`-i, --groupId [groupId]`
: The ID of the Microsoft 365 group. Specify only one of the following: `groupId`, `groupDisplayName`, `teamId`, or `teamName`.
: The ID of the Microsoft 365 group. Specify only one of the following: `groupId`, `groupName`, `teamId`, or `teamName`.

`--groupDisplayName [groupDisplayName]`
: The display name of the Microsoft 365 group. Specify only one of the following: `groupId`, `groupDisplayName`, `teamId`, or `teamName`.
`--groupName [groupName]`
: The display name of the Microsoft 365 group. Specify only one of the following: `groupId`, `groupName`, `teamId`, or `teamName`.

`--teamId [teamId]`
: The ID of the Microsoft Teams team. Specify only one of the following: `groupId`, `groupDisplayName`, `teamId`, or `teamName`.
: The ID of the Microsoft Teams team. Specify only one of the following: `groupId`, `groupName`, `teamId`, or `teamName`.

`--teamName [teamName]`
: The display name of the Microsoft Teams team. Specify only one of the following: `groupId`, `groupDisplayName`, `teamId`, or `teamName`.
: The display name of the Microsoft Teams team. Specify only one of the following: `groupId`, `groupName`, `teamId`, or `teamName`.

`-n, --userName [userName]`
: (deprecated) User's UPN (user principal name), eg. `[email protected]`.. Specify only one of the following: `userName`, `ids` or `userNames`.
Expand Down Expand Up @@ -67,7 +67,7 @@ m365 entra m365group user remove --teamName 'Project Team' --userNames 'anne.mat
Removes users specified by a comma separated list of user ids from the specified Microsoft 365 group specified by name.

```sh
m365 entra m365group user remove --groupDisplayName 'Project Team' --ids '5b8e4cb1-ea40-484b-a94e-02a4313fefb4,be7a56d8-b045-4938-af35-917ab6e5309f'
m365 entra m365group user remove --groupName 'Project Team' --ids '5b8e4cb1-ea40-484b-a94e-02a4313fefb4,be7a56d8-b045-4938-af35-917ab6e5309f'
```

## Response
Expand Down
49 changes: 0 additions & 49 deletions src/m365/entra/commands/m365group/m365group-user-remove.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,55 +218,6 @@ describe(commands.M365GROUP_USER_REMOVE, () => {
assert(memberDeleteCallIssued);
});

it('removes the specified owner from owners and members endpoint of the Microsoft 365 Group specified by groupName with accepted prompt', async () => {
let memberDeleteCallIssued = false;

sinon.stub(request, 'get').callsFake(async (opts) => {
if (opts.url === `https://graph.microsoft.com/v1.0/users/anne.matthews%40contoso.onmicrosoft.com/id`) {
return {
"value": "00000000-0000-0000-0000-000000000001"
};
}

if (opts.url === `https://graph.microsoft.com/v1.0/groups/00000000-0000-0000-0000-000000000000/id`) {
return {
response: {
status: 200,
data: {
value: "00000000-0000-0000-0000-000000000000"
}
}
};
}

throw 'Invalid request';
});

sinon.stub(request, 'delete').callsFake(async (opts) => {
memberDeleteCallIssued = true;

if (opts.url === `https://graph.microsoft.com/v1.0/groups/00000000-0000-0000-0000-000000000000/owners/00000000-0000-0000-0000-000000000001/$ref`) {
return {
"value": [{ "id": "00000000-0000-0000-0000-000000000000" }]
};
}

if (opts.url === `https://graph.microsoft.com/v1.0/groups/00000000-0000-0000-0000-000000000000/members/00000000-0000-0000-0000-000000000001/$ref`) {
return {
"value": [{ "id": "00000000-0000-0000-0000-000000000000" }]
};
}

throw 'Invalid request';
});

sinonUtil.restore(cli.promptForConfirmation);
sinon.stub(cli, 'promptForConfirmation').resolves(true);

await command.action(logger, { options: { groupName: "Finance", userName: "[email protected]" } });
assert(memberDeleteCallIssued);
});

it('removes the specified owner from owners and members endpoint of the specified Microsoft 365 Group when prompt confirmed', async () => {
let memberDeleteCallIssued = false;

Expand Down
9 changes: 0 additions & 9 deletions src/m365/entra/commands/m365group/m365group-user-remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,6 @@ class EntraM365GroupUserRemoveCommand extends GraphCommand {
await this.warn(logger, `Option 'userName' is deprecated. Please use 'ids' or 'userNames' instead.`);
}

let groupId = args.options.groupId;

if (args.options.groupName) {
groupId = await entraGroup.getGroupIdByDisplayName(args.options.groupName);
}
else if (args.options.teamId) {
groupId = args.options.teamId;
}

const removeUser = async (): Promise<void> => {
try {
const groupId: string = await this.getGroupId(logger, args.options.groupId, args.options.teamId, args.options.groupName, args.options.teamName);
Expand Down

0 comments on commit de1d242

Please sign in to comment.