Skip to content

Commit c3e8745

Browse files
committed
New command: spo brandcenter settings list. Closes #6653
1 parent b2b02ae commit c3e8745

File tree

6 files changed

+403
-0
lines changed

6 files changed

+403
-0
lines changed

.devproxy/api-specs/sharepoint.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,22 @@ components:
5757
User.Read.All: User.Read.All
5858
User.ReadWrite.All: User.ReadWrite.All
5959
paths:
60+
/_api/Brandcenter/Configuration:
61+
get:
62+
security:
63+
- delegated:
64+
- AllSites.Read
65+
- AllSites.Write
66+
- AllSites.Manage
67+
- AllSites.FullControl
68+
- application:
69+
- Sites.Read.All
70+
- Sites.ReadWrite.All
71+
- Sites.Manage.All
72+
- Sites.FullControl.All
73+
responses:
74+
200:
75+
description: OK
6076
/_api/contextinfo:
6177
post:
6278
security:
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
import Global from '/docs/cmd/_global.mdx';
2+
import Tabs from '@theme/Tabs';
3+
import TabItem from '@theme/TabItem';
4+
5+
# spo brandcenter settings list
6+
7+
Lists the brand center configuration
8+
9+
## Usage
10+
11+
```sh
12+
m365 spo brandcenter settings list [options]
13+
```
14+
15+
## Options
16+
17+
<Global />
18+
19+
## Permissions
20+
21+
<Tabs>
22+
<TabItem value="Delegated">
23+
24+
| Resource | Permissions |
25+
|-----------------|-----------------|
26+
| Microsoft Graph | Sites.Read.All |
27+
| SharePoint | AllSites.Read |
28+
29+
</TabItem>
30+
<TabItem value="Application">
31+
32+
| Resource | Permissions |
33+
|-----------------|------------------|
34+
| Microsoft Graph | Sites.Read.All |
35+
| SharePoint | Sites.Read.All |
36+
37+
</TabItem>
38+
</Tabs>
39+
40+
## Examples
41+
42+
List all brand center config
43+
44+
```sh
45+
m365 spo brandcenter settings list
46+
```
47+
48+
## Response
49+
50+
<Tabs>
51+
<TabItem value="JSON">
52+
53+
```json
54+
{
55+
"BrandColorsListId": "00000000-0000-0000-0000-000000000000",
56+
"BrandColorsListUrl": null,
57+
"BrandFontLibraryId": "23af51de-856c-4d00-aa11-0d03af0e46e3",
58+
"BrandFontLibraryUrl": {
59+
"DecodedUrl": "https://contoso.sharepoint.com/sites/BrandGuide/Fonts"
60+
},
61+
"IsBrandCenterSiteFeatureEnabled": true,
62+
"IsPublicCdnEnabled": true,
63+
"OrgAssets": {
64+
"CentralAssetRepositoryLibraries": null,
65+
"Domain": {
66+
"DecodedUrl": "https://contoso.sharepoint.com"
67+
},
68+
"OrgAssetsLibraries": {
69+
"OrgAssetsLibraries": [
70+
{
71+
"DisplayName": "Fonts",
72+
"FileType": "",
73+
"LibraryUrl": {
74+
"DecodedUrl": "sites/BrandGuide/Fonts"
75+
},
76+
"ListId": "23af51de-856c-4d00-aa11-0d03af0e46e3",
77+
"OrgAssetFlags": 0,
78+
"OrgAssetType": 8,
79+
"ThumbnailUrl": null,
80+
"UniqueId": "00000000-0000-0000-0000-000000000000"
81+
}
82+
],
83+
"Items": [
84+
{
85+
"DisplayName": "Fonts",
86+
"FileType": "",
87+
"LibraryUrl": {
88+
"DecodedUrl": "sites/BrandGuide/Fonts"
89+
},
90+
"ListId": "23af51de-856c-4d00-aa11-0d03af0e46e3",
91+
"OrgAssetFlags": 0,
92+
"OrgAssetType": 8,
93+
"ThumbnailUrl": null,
94+
"UniqueId": "00000000-0000-0000-0000-000000000000"
95+
}
96+
]
97+
},
98+
"SiteId": "52b46e48-9c0c-40cb-a955-13eb6c717ff3",
99+
"Url": {
100+
"DecodedUrl": "/sites/BrandGuide"
101+
},
102+
"WebId": "206988d5-e133-4a24-819d-24101f3407ce"
103+
},
104+
"SiteId": "52b46e48-9c0c-40cb-a955-13eb6c717ff3",
105+
"SiteUrl": "https://contoso.sharepoint.com/sites/BrandGuide"
106+
}
107+
```
108+
109+
</TabItem>
110+
<TabItem value="Text">
111+
112+
```txt
113+
BrandColorsListId : 00000000-0000-0000-0000-000000000000
114+
BrandColorsListUrl : null
115+
BrandFontLibraryId : 23af51de-856c-4d00-aa11-0d03af0e46e3
116+
BrandFontLibraryUrl : {"DecodedUrl":"https://contoso.sharepoint.com/sites/BrandGuide/Fonts"}
117+
IsBrandCenterSiteFeatureEnabled: true
118+
IsPublicCdnEnabled : true
119+
OrgAssets : {"CentralAssetRepositoryLibraries":null,"Domain":{"DecodedUrl":"https://contoso.sharepoint.com"},"OrgAssetsLibraries":{"OrgAssetsLibraries":[{"DisplayName":"Fonts","FileType":"","LibraryUrl":{"DecodedUrl":"sites/BrandGuide/Fonts"},"ListId":"23af51de-856c-4d00-aa11-0d03af0e46e3","OrgAssetFlags":0,"OrgAssetType":8,"ThumbnailUrl":null,"UniqueId":"00000000-0000-0000-0000-000000000000"}],"Items":[{"DisplayName":"Fonts","FileType":"","LibraryUrl":{"DecodedUrl":"sites/BrandGuide/Fonts"},"ListId":"23af51de-856c-4d00-aa11-0d03af0e46e3","OrgAssetFlags":0,"OrgAssetType":8,"ThumbnailUrl":null,"UniqueId":"00000000-0000-0000-0000-000000000000"}]},"SiteId":"52b46e48-9c0c-40cb-a955-13eb6c717ff3","Url":{"DecodedUrl":"/sites/BrandGuide"},"WebId":"206988d5-e133-4a24-819d-24101f3407ce"}
120+
SiteId : 52b46e48-9c0c-40cb-a955-13eb6c717ff3
121+
SiteUrl : https://contoso.sharepoint.com/sites/BrandGuide
122+
```
123+
124+
</TabItem>
125+
<TabItem value="CSV">
126+
127+
```csv
128+
BrandColorsListId,BrandColorsListUrl,BrandFontLibraryId,IsBrandCenterSiteFeatureEnabled,IsPublicCdnEnabled,SiteId,SiteUrl
129+
00000000-0000-0000-0000-000000000000,,23af51de-856c-4d00-aa11-0d03af0e46e3,1,1,52b46e48-9c0c-40cb-a955-13eb6c717ff3,https://contoso.sharepoint.com/sites/BrandGuide
130+
```
131+
132+
</TabItem>
133+
<TabItem value="Markdown">
134+
135+
```md
136+
# spo brandcenter settings list --debug "false" --verbose "false"
137+
138+
Date: 12/1/2025
139+
140+
Property | Value
141+
---------|-------
142+
BrandColorsListId | 00000000-0000-0000-0000-000000000000
143+
BrandFontLibraryId | 23af51de-856c-4d00-aa11-0d03af0e46e3
144+
IsBrandCenterSiteFeatureEnabled | true
145+
IsPublicCdnEnabled | true
146+
SiteId | 52b46e48-9c0c-40cb-a955-13eb6c717ff3
147+
SiteUrl | https://contoso.sharepoint.com/sites/BrandGuide
148+
```
149+
150+
</TabItem>
151+
</Tabs>

docs/src/config/sidebars.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2373,6 +2373,15 @@ const sidebars: SidebarsConfig = {
23732373
}
23742374
]
23752375
},
2376+
{
2377+
brandcenter: [
2378+
{
2379+
type: 'doc',
2380+
label: 'brandcenter settings list',
2381+
id: 'cmd/spo/brandcenter/brandcenter-settings-list'
2382+
}
2383+
]
2384+
},
23762385
{
23772386
cdn: [
23782387
{

src/m365/spo/commands.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default {
1919
APPLICATIONCUSTOMIZER_SET: `${prefix} applicationcustomizer set`,
2020
APPPAGE_ADD: `${prefix} apppage add`,
2121
APPPAGE_SET: `${prefix} apppage set`,
22+
BRANDCENTER_SETTINGS_LIST: `${prefix} brandcenter settings list`,
2223
CDN_GET: `${prefix} cdn get`,
2324
CDN_ORIGIN_ADD: `${prefix} cdn origin add`,
2425
CDN_ORIGIN_LIST: `${prefix} cdn origin list`,
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
import assert from 'assert';
2+
import sinon from 'sinon';
3+
import auth from '../../../../Auth.js';
4+
import { cli } from '../../../../cli/cli.js';
5+
import { CommandInfo } from '../../../../cli/CommandInfo.js';
6+
import { Logger } from '../../../../cli/Logger.js';
7+
import { CommandError } from '../../../../Command.js';
8+
import request from '../../../../request.js';
9+
import { telemetry } from '../../../../telemetry.js';
10+
import { pid } from '../../../../utils/pid.js';
11+
import { session } from '../../../../utils/session.js';
12+
import { sinonUtil } from '../../../../utils/sinonUtil.js';
13+
import { z } from 'zod';
14+
import commands from '../../commands.js';
15+
import command from './brandcenter-settings-list.js';
16+
17+
describe(commands.BRANDCENTER_SETTINGS_LIST, () => {
18+
let log: any[];
19+
let logger: Logger;
20+
let loggerLogSpy: sinon.SinonSpy;
21+
let commandInfo: CommandInfo;
22+
let commandOptionsSchema: z.ZodTypeAny;
23+
24+
const successReponse = {
25+
"BrandColorsListId": "00000000-0000-0000-0000-000000000000",
26+
"BrandColorsListUrl": null,
27+
"BrandFontLibraryId": "23af51de-856c-4d00-aa11-0d03af0e46e3",
28+
"BrandFontLibraryUrl": {
29+
"DecodedUrl": "https://contoso.sharepoint.com/sites/BrandGuide/Fonts"
30+
},
31+
"IsBrandCenterSiteFeatureEnabled": true,
32+
"IsPublicCdnEnabled": true,
33+
"OrgAssets": {
34+
"CentralAssetRepositoryLibraries": null,
35+
"Domain": {
36+
"DecodedUrl": "https://contoso.sharepoint.com"
37+
},
38+
"OrgAssetsLibraries": {
39+
"OrgAssetsLibraries": [
40+
{
41+
"DisplayName": "Fonts",
42+
"FileType": "",
43+
"LibraryUrl": {
44+
"DecodedUrl": "sites/BrandGuide/Fonts"
45+
},
46+
"ListId": "23af51de-856c-4d00-aa11-0d03af0e46e3",
47+
"OrgAssetFlags": 0,
48+
"OrgAssetType": 8,
49+
"ThumbnailUrl": null,
50+
"UniqueId": "00000000-0000-0000-0000-000000000000"
51+
}
52+
],
53+
"Items": [
54+
{
55+
"DisplayName": "Fonts",
56+
"FileType": "",
57+
"LibraryUrl": {
58+
"DecodedUrl": "sites/BrandGuide/Fonts"
59+
},
60+
"ListId": "23af51de-856c-4d00-aa11-0d03af0e46e3",
61+
"OrgAssetFlags": 0,
62+
"OrgAssetType": 8,
63+
"ThumbnailUrl": null,
64+
"UniqueId": "00000000-0000-0000-0000-000000000000"
65+
}
66+
]
67+
},
68+
"SiteId": "52b46e48-9c0c-40cb-a955-13eb6c717ff3",
69+
"Url": {
70+
"DecodedUrl": "/sites/BrandGuide"
71+
},
72+
"WebId": "206988d5-e133-4a24-819d-24101f3407ce"
73+
},
74+
"SiteId": "52b46e48-9c0c-40cb-a955-13eb6c717ff3",
75+
"SiteUrl": "https://contoso.sharepoint.com/sites/BrandGuide"
76+
};
77+
78+
before(() => {
79+
sinon.stub(auth, 'restoreAuth').resolves();
80+
sinon.stub(telemetry, 'trackEvent').resolves();
81+
sinon.stub(pid, 'getProcessName').returns('');
82+
sinon.stub(session, 'getId').returns('');
83+
84+
auth.connection.active = true;
85+
auth.connection.spoUrl = 'https://contoso.sharepoint.com';
86+
commandInfo = cli.getCommandInfo(command);
87+
commandOptionsSchema = commandInfo.command.getSchemaToParse()!;
88+
});
89+
90+
beforeEach(() => {
91+
log = [];
92+
logger = {
93+
log: async (msg: string) => {
94+
log.push(msg);
95+
},
96+
logRaw: async (msg: string) => {
97+
log.push(msg);
98+
},
99+
logToStderr: async (msg: string) => {
100+
log.push(msg);
101+
}
102+
};
103+
loggerLogSpy = sinon.spy(logger, 'log');
104+
});
105+
106+
afterEach(() => {
107+
sinonUtil.restore([
108+
request.get
109+
]);
110+
});
111+
112+
after(() => {
113+
sinon.restore();
114+
auth.connection.active = false;
115+
auth.connection.spoUrl = undefined;
116+
});
117+
118+
it('has correct name', () => {
119+
assert.strictEqual(command.name, commands.BRANDCENTER_SETTINGS_LIST);
120+
});
121+
122+
it('has a description', () => {
123+
assert.notStrictEqual(command.description, null);
124+
});
125+
126+
it('passes validation with no options', () => {
127+
const actual = commandOptionsSchema.safeParse({});
128+
assert.strictEqual(actual.success, true);
129+
});
130+
131+
it('fails validation with unknown options', () => {
132+
const actual = commandOptionsSchema.safeParse({ option: "value" });
133+
assert.strictEqual(actual.success, false);
134+
});
135+
136+
it('successfully lists brand center settings', async () => {
137+
const getStub = sinon.stub(request, 'get').callsFake(async (opts: any) => {
138+
if (opts.url === `https://contoso.sharepoint.com/_api/Brandcenter/Configuration`) {
139+
return successReponse;
140+
}
141+
142+
throw 'Invalid request';
143+
});
144+
145+
await command.action(logger, { options: {} });
146+
assert(getStub.calledOnce);
147+
assert(loggerLogSpy.calledWith(successReponse));
148+
});
149+
150+
it('successfully lists brand center settings with verbose output', async () => {
151+
const getStub = sinon.stub(request, 'get').callsFake(async (opts: any) => {
152+
if (opts.url === `https://contoso.sharepoint.com/_api/Brandcenter/Configuration`) {
153+
return successReponse;
154+
}
155+
156+
throw 'Invalid request';
157+
});
158+
159+
await command.action(logger, { options: { verbose: true } });
160+
assert(getStub.calledOnce);
161+
assert(loggerLogSpy.calledWith(successReponse));
162+
});
163+
164+
it('correctly handles error when retrieving settings', async () => {
165+
sinon.stub(request, 'get').callsFake(async (opts) => {
166+
if (opts.url === 'https://contoso.sharepoint.com/_api/Brandcenter/Configuration') {
167+
throw 'An unknown error has occurred';
168+
}
169+
170+
throw 'Invalid request';
171+
});
172+
173+
await assert.rejects(command.action(logger, { options: {} }),
174+
new CommandError(`An unknown error has occurred`));
175+
});
176+
});

0 commit comments

Comments
 (0)