-
Notifications
You must be signed in to change notification settings - Fork 330
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhances 'entra m365group set' with displayName. Closes #6146
- Loading branch information
1 parent
979b9b7
commit da6c933
Showing
4 changed files
with
59 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,11 +19,14 @@ m365 aad m365group set [options] | |
## Options | ||
|
||
```md definition-list | ||
`-i, --id <id>` | ||
`-i, --id [id]` | ||
: The ID of the Microsoft 365 Group to update | ||
|
||
`-n, --displayName [displayName]` | ||
: Display name for the Microsoft 365 Group | ||
: Display name of the Microsoft 365 Group to update | ||
|
||
`--newDisplayName [newDisplayName]` | ||
: New display name for the Microsoft 365 Group | ||
|
||
`-d, --description [description]` | ||
: Description for the Microsoft 365 Group | ||
|
@@ -72,7 +75,7 @@ Options `allowExternalSenders` and `autoSubscribeNewMembers` can only be set usi | |
Update Microsoft 365 Group display name. | ||
|
||
```sh | ||
m365 entra m365group set --id 28beab62-7540-4db1-a23f-29a6018a3848 --displayName Finance | ||
m365 entra m365group set --id 28beab62-7540-4db1-a23f-29a6018a3848 --newDisplayName Finance | ||
``` | ||
|
||
Change Microsoft 365 Group visibility to public. | ||
|
@@ -81,16 +84,16 @@ Change Microsoft 365 Group visibility to public. | |
m365 entra m365group set --id 28beab62-7540-4db1-a23f-29a6018a3848 --isPrivate `false` | ||
``` | ||
|
||
Add new Microsoft 365 Group owners. | ||
Add new Microsoft 365 Group owners of group. | ||
|
||
```sh | ||
m365 entra m365group set --id 28beab62-7540-4db1-a23f-29a6018a3848 --owners "[email protected],[email protected]" | ||
m365 entra m365group set --displayName 'Project Team' --owners "[email protected],[email protected]" | ||
``` | ||
|
||
Add new Microsoft 365 Group members. | ||
|
||
```sh | ||
m365 entra m365group set --id 28beab62-7540-4db1-a23f-29a6018a3848 --members "[email protected],[email protected]" | ||
m365 entra m365group set --displayName 'Project Team' --members "[email protected],[email protected]" | ||
``` | ||
|
||
Update Microsoft 365 Group logo. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,7 +98,8 @@ describe(commands.M365GROUP_SET, () => { | |
fs.readFileSync, | ||
fs.existsSync, | ||
fs.lstatSync, | ||
accessToken.isAppOnlyAccessToken | ||
accessToken.isAppOnlyAccessToken, | ||
entraGroup.getGroupIdByDisplayName | ||
]); | ||
}); | ||
|
||
|
@@ -125,21 +126,19 @@ describe(commands.M365GROUP_SET, () => { | |
assert.deepStrictEqual(alias, [aadCommands.M365GROUP_SET]); | ||
}); | ||
|
||
it('updates Microsoft 365 Group display name', async () => { | ||
sinon.stub(request, 'patch').callsFake(async (opts) => { | ||
if (opts.url === 'https://graph.microsoft.com/v1.0/groups/28beab62-7540-4db1-a23f-29a6018a3848') { | ||
if (JSON.stringify(opts.data) === JSON.stringify(<Group>{ | ||
displayName: 'My group' | ||
})) { | ||
return; | ||
} | ||
it('updates Microsoft 365 Group display name while group is being retrieved by display name', async () => { | ||
const groupName = 'Project A'; | ||
sinon.stub(entraGroup, 'getGroupIdByDisplayName').withArgs(groupName).resolves(groupId); | ||
const patchStub = sinon.stub(request, 'patch').callsFake(async (opts) => { | ||
if (opts.url === `https://graph.microsoft.com/v1.0/groups/${groupId}`) { | ||
return; | ||
} | ||
|
||
throw 'Invalid request'; | ||
}); | ||
|
||
await command.action(logger, { options: { id: '28beab62-7540-4db1-a23f-29a6018a3848', displayName: 'My group' } }); | ||
assert(loggerLogSpy.notCalled); | ||
await command.action(logger, { options: { displayName: groupName, newDisplayName: 'My group', verbose: true } }); | ||
assert(patchStub.calledOnce); | ||
}); | ||
|
||
it('updates Microsoft 365 Group description (debug)', async () => { | ||
|
@@ -497,15 +496,15 @@ describe(commands.M365GROUP_SET, () => { | |
} | ||
}); | ||
|
||
await assert.rejects(command.action(logger, { options: { id: '28beab62-7540-4db1-a23f-29a6018a3848', displayName: 'My group' } } as any), | ||
await assert.rejects(command.action(logger, { options: { id: '28beab62-7540-4db1-a23f-29a6018a3848', newDisplayName: 'My group' } } as any), | ||
new CommandError('An error has occurred')); | ||
}); | ||
|
||
it('throws error when the group is not a unified group', async () => { | ||
sinonUtil.restore(entraGroup.isUnifiedGroup); | ||
sinon.stub(entraGroup, 'isUnifiedGroup').resolves(false); | ||
|
||
await assert.rejects(command.action(logger, { options: { id: groupId, displayName: 'Updated title' } }), | ||
await assert.rejects(command.action(logger, { options: { id: groupId, newDisplayName: 'Updated title' } }), | ||
new CommandError(`Specified group with id '${groupId}' is not a Microsoft 365 group.`)); | ||
}); | ||
|
||
|
@@ -532,7 +531,7 @@ describe(commands.M365GROUP_SET, () => { | |
}); | ||
|
||
it('passes validation when the id is a valid GUID and displayName specified', async () => { | ||
const actual = await command.validate({ options: { id: '28beab62-7540-4db1-a23f-29a6018a3848', displayName: 'My group' } }, commandInfo); | ||
const actual = await command.validate({ options: { id: '28beab62-7540-4db1-a23f-29a6018a3848', newDisplayName: 'My group' } }, commandInfo); | ||
assert.strictEqual(actual, true); | ||
}); | ||
|
||
|
@@ -622,7 +621,7 @@ describe(commands.M365GROUP_SET, () => { | |
sinon.stub(stats, 'isDirectory').returns(false); | ||
sinon.stub(fs, 'existsSync').returns(true); | ||
sinon.stub(fs, 'lstatSync').returns(stats); | ||
const actual = await command.validate({ options: { id: '28beab62-7540-4db1-a23f-29a6018a3848', displayName: 'Title', description: 'Description', logoPath: 'logo.png', owners: '[email protected]', members: '[email protected]', isPrivate: false, allowExternalSenders: false, autoSubscribeNewMembers: false, hideFromAddressLists: false, hideFromOutlookClients: false } }, commandInfo); | ||
const actual = await command.validate({ options: { id: '28beab62-7540-4db1-a23f-29a6018a3848', newDisplayName: 'Title', description: 'Description', logoPath: 'logo.png', owners: '[email protected]', members: '[email protected]', isPrivate: false, allowExternalSenders: false, autoSubscribeNewMembers: false, hideFromAddressLists: false, hideFromOutlookClients: false } }, commandInfo); | ||
assert.strictEqual(actual, true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters