Skip to content

Commit

Permalink
feat: enable copilot access check (#10265)
Browse files Browse the repository at this point in the history
  • Loading branch information
swatDong authored Nov 3, 2023
1 parent ec81da7 commit a86c4a4
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 11 deletions.
3 changes: 2 additions & 1 deletion packages/fx-core/src/common/m365/packageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ export class PackageService {
try {
const serviceUrl = await this.getTitleServiceUrl(token);
this.logger?.debug(`Get active experiences from service URL ${serviceUrl} ...`);
const response = await this.axiosInstance.get("/catalog/v1/users/experiences", {
// users/experiences is deprecating, using users/uitypes instead
const response = await this.axiosInstance.get("/catalog/v1/users/uitypes", {
baseURL: serviceUrl,
headers: {
Authorization: `Bearer ${token}`,
Expand Down
12 changes: 6 additions & 6 deletions packages/fx-core/tests/common/m365/packageService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ describe("Package Service", () => {
titlesServiceUrl: "https://test-url",
},
};
axiosGetResponses["/catalog/v1/users/experiences"] = {
axiosGetResponses["/catalog/v1/users/uitypes"] = {
data: {
activeExperiences: ["foo", "bar"],
},
Expand Down Expand Up @@ -829,7 +829,7 @@ describe("Package Service", () => {
titlesServiceUrl: "https://test-url",
},
};
axiosGetResponses["/catalog/v1/users/experiences"] = new Error("test-get");
axiosGetResponses["/catalog/v1/users/uitypes"] = new Error("test-get");

const packageService = new PackageService("https://test-endpoint");
let actualError: Error | undefined;
Expand All @@ -853,7 +853,7 @@ describe("Package Service", () => {
expectedError.response = {
data: {},
};
axiosGetResponses["/catalog/v1/users/experiences"] = expectedError;
axiosGetResponses["/catalog/v1/users/uitypes"] = expectedError;

let packageService = new PackageService("https://test-endpoint");
let actualError: Error | undefined;
Expand Down Expand Up @@ -884,7 +884,7 @@ describe("Package Service", () => {
titlesServiceUrl: "https://test-url",
},
};
axiosGetResponses["/catalog/v1/users/experiences"] = {
axiosGetResponses["/catalog/v1/users/uitypes"] = {
data: {
activeExperiences: ["foo", "bar"],
},
Expand All @@ -909,7 +909,7 @@ describe("Package Service", () => {
titlesServiceUrl: "https://test-url",
},
};
axiosGetResponses["/catalog/v1/users/experiences"] = {
axiosGetResponses["/catalog/v1/users/uitypes"] = {
foo: "bar",
};

Expand All @@ -932,7 +932,7 @@ describe("Package Service", () => {
titlesServiceUrl: "https://test-url",
},
};
axiosGetResponses["/catalog/v1/users/experiences"] = new Error("test-get");
axiosGetResponses["/catalog/v1/users/uitypes"] = new Error("test-get");

let packageService = new PackageService("https://test-endpoint");
let actualError: Error | undefined;
Expand Down
4 changes: 2 additions & 2 deletions templates/js/message-extension-copilot/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
"Launch App in Copilot (Edge)",
"Attach to Local Service"
],
"preLaunchTask": "Start Teams App Locally",
"preLaunchTask": "Start Teams App Locally (Copilot)",
"presentation": {
"group": "group 2: Copilot",
"order": 1
Expand All @@ -236,7 +236,7 @@
"Launch App in Copilot (Chrome)",
"Attach to Local Service"
],
"preLaunchTask": "Start Teams App Locally",
"preLaunchTask": "Start Teams App Locally (Copilot)",
"presentation": {
"group": "group 2: Copilot",
"order": 2
Expand Down
24 changes: 24 additions & 0 deletions templates/js/message-extension-copilot/.vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@
],
"dependsOrder": "sequence"
},
{
"label": "Start Teams App Locally (Copilot)",
"dependsOn": [
"Validate prerequisites",
"Validate Copilot access",
"Start local tunnel",
"Provision",
"Deploy",
"Start application"
],
"dependsOrder": "sequence"
},
{
// Check all required prerequisites.
// See https://aka.ms/teamsfx-tasks/check-prerequisites to know the details and how to customize the args.
Expand All @@ -33,6 +45,18 @@
]
}
},
{
// Check Copilot access.
// See https://aka.ms/teamsfx-tasks/check-prerequisites to know the details and how to customize the args.
"label": "Validate Copilot access",
"type": "teamsfx",
"command": "debug-check-prerequisites",
"args": {
"prerequisites": [
"copilotAccess" // Validate if the account has Copilot access.
]
}
},
{
// Start the local tunnel service to forward public URL to local port and inspect traffic.
// See https://aka.ms/teamsfx-tasks/local-tunnel for the detailed args definitions.
Expand Down
4 changes: 2 additions & 2 deletions templates/ts/message-extension-copilot/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
"Launch App in Copilot (Edge)",
"Attach to Local Service"
],
"preLaunchTask": "Start Teams App Locally",
"preLaunchTask": "Start Teams App Locally (Copilot)",
"presentation": {
"group": "group 2: Copilot",
"order": 1
Expand All @@ -236,7 +236,7 @@
"Launch App in Copilot (Chrome)",
"Attach to Local Service"
],
"preLaunchTask": "Start Teams App Locally",
"preLaunchTask": "Start Teams App Locally (Copilot)",
"presentation": {
"group": "group 2: Copilot",
"order": 2
Expand Down
24 changes: 24 additions & 0 deletions templates/ts/message-extension-copilot/.vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@
],
"dependsOrder": "sequence"
},
{
"label": "Start Teams App Locally (Copilot)",
"dependsOn": [
"Validate prerequisites",
"Validate Copilot access",
"Start local tunnel",
"Provision",
"Deploy",
"Start application"
],
"dependsOrder": "sequence"
},
{
// Check all required prerequisites.
// See https://aka.ms/teamsfx-tasks/check-prerequisites to know the details and how to customize the args.
Expand All @@ -33,6 +45,18 @@
]
}
},
{
// Check Copilot access.
// See https://aka.ms/teamsfx-tasks/check-prerequisites to know the details and how to customize the args.
"label": "Validate Copilot access",
"type": "teamsfx",
"command": "debug-check-prerequisites",
"args": {
"prerequisites": [
"copilotAccess" // Validate if the account has Copilot access.
]
}
},
{
// Start the local tunnel service to forward public URL to local port and inspect traffic.
// See https://aka.ms/teamsfx-tasks/local-tunnel for the detailed args definitions.
Expand Down

0 comments on commit a86c4a4

Please sign in to comment.