Skip to content

Commit ed10042

Browse files
authored
Merge branch 'dev' into gallery-automation-updates
2 parents e054775 + 1ee7bd8 commit ed10042

File tree

8 files changed

+248
-70
lines changed

8 files changed

+248
-70
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ npm install msal@<version>
9696
```typescript
9797
import { UserAgentApplication } from "msal";
9898

99-
import { ImplicitMSALAuthenticationProvider } from "./node_modules/@microsoft/microsoft-graph-client/lib/src/ImplicitMSALAuthenticationProvider";
99+
import { ImplicitMSALAuthenticationProvider } from "@microsoft/microsoft-graph-client/lib/src/ImplicitMSALAuthenticationProvider";
100+
import { MSALAuthenticationProviderOptions } from '@microsoft/microsoft-graph-client/lib/src/MSALAuthenticationProviderOptions';
100101

101102
// An Optional options for initializing the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#configuration-options
102103
const msalConfig = {
@@ -110,7 +111,7 @@ const graphScopes = ["user.read", "mail.send"]; // An array of graph scopes
110111
// Important Note: This library implements loginPopup and acquireTokenPopup flow, remember this while initializing the msal
111112
// Initialize the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js#1-instantiate-the-useragentapplication
112113
const msalApplication = new UserAgentApplication(msalConfig);
113-
const options = new MicrosoftGraph.MSALAuthenticationProviderOptions(graphScopes);
114+
const options = new MSALAuthenticationProviderOptions(graphScopes);
114115
const authProvider = new ImplicitMSALAuthenticationProvider(msalApplication, options);
115116
```
116117

samples/browser/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spec/core/GraphRequestUtil.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,10 @@ describe("GraphRequestUtil.ts", () => {
7171
const val = undefined;
7272
assert.equal(serializeContent(val), undefined);
7373
});
74+
75+
it("Should return 'null' for the case of null content value", () => {
76+
const val = null;
77+
assert.equal(serializeContent(val), "null");
78+
});
7479
});
7580
});

spec/core/urlGeneration.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,59 @@ cases.push({
9191
.query("$search=senior"),
9292
});
9393

94+
cases.push({
95+
url: "https://graph.microsoft.com/beta/me/people?$select=displayName,title,id&$count=false&$expand=a($expand=a,b)",
96+
request: client
97+
.api("/me/people")
98+
.version("beta")
99+
.select(["displayName", "title"])
100+
.count(true)
101+
.expand("a($expand=a,b)")
102+
.query("$select=id")
103+
.query("$count=false"),
104+
});
105+
106+
cases.push({
107+
url: "https://graph.microsoft.com/v1.0/me/people?$select=displayName,title,id&select=value",
108+
request: client
109+
.api("/me/people")
110+
.version("v1.0")
111+
.select(["displayName", "title"])
112+
.query({ select: "value" })
113+
.query({ $select: "id" }),
114+
});
115+
116+
// handling an invalid input
117+
cases.push({
118+
url: "https://graph.microsoft.com/v1.0/me/people?$select=displayName,title&select=value&test",
119+
request: client
120+
.api("/me/people")
121+
.version("v1.0")
122+
.select(["displayName", "title"])
123+
.query({ select: "value" })
124+
.query("test"),
125+
});
126+
127+
// handling an invalid input
128+
cases.push({
129+
url: "https://graph.microsoft.com/v1.0/me/people?$expand=address($select=home,$expand=city)&$select=home,displayName,title&select=value&test",
130+
request: client
131+
.api("/me/people?$expand=address($select=home,$expand=city)&$select=home")
132+
.version("v1.0")
133+
.select(["displayName", "title"])
134+
.query({ select: "value" })
135+
.query("test"),
136+
});
137+
138+
cases.push({
139+
url: "https://graph.microsoft.com/v1.0/me/people?$expand=home($select=home)&name=test",
140+
request: client.api("/me/people").query("?name=test&$expand=home($select=home)"),
141+
});
142+
cases.push({
143+
url: "https://graph.microsoft.com/v1.0/me/people?$expand=home($select=home)&name=test",
144+
request: client.api("/me/people?name=test&$expand=home($select=home)"),
145+
});
146+
94147
cases.push({
95148
url: "https://graph.microsoft.com/v1.0/me/drive/root?$expand=children($select=name),permissions",
96149
request: client

spec/core/urlParsing.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ const testCases = {
2828
"me?$select=displayName": "https://graph.microsoft.com/v1.0/me?$select=displayName",
2929
"me?select=displayName": "https://graph.microsoft.com/v1.0/me?select=displayName",
3030
"https://graph.microsoft.com/beta/me?select=displayName": "https://graph.microsoft.com/beta/me?select=displayName",
31+
32+
// test for nested query parameters
33+
"https://graph.microsoft.com/beta/identityGovernance/entitlementManagement/accessPackages/?$expand=accessPackageAssignmentPolicies,accessPackageResourceRoleScopes($expand=accessPackageResourceRole,accessPackageResourceScope)": "https://graph.microsoft.com/beta/identityGovernance/entitlementManagement/accessPackages/?$expand=accessPackageAssignmentPolicies,accessPackageResourceRoleScopes($expand=accessPackageResourceRole,accessPackageResourceScope)",
34+
"me?$select=displayName&$select=id": "https://graph.microsoft.com/v1.0/me?$select=displayName,id",
35+
"/me?$filter=b&$filter=a": "https://graph.microsoft.com/v1.0/me?$filter=a",
36+
"https://graph.microsoft.com/v1.0/me?$top=4&$expand=4&$iscount=true&$top=2": "https://graph.microsoft.com/v1.0/me?$top=2&$expand=4&$iscount=true",
37+
"/items?$expand=fields($select=Title)&$expand=name($select=firstName)": "https://graph.microsoft.com/v1.0/items?$expand=fields($select=Title),name($select=firstName)",
38+
39+
// Passing invalid parameters
40+
"/me?&test&123": "https://graph.microsoft.com/v1.0/me?&test&123",
41+
"/me?$select($select=name)": "https://graph.microsoft.com/v1.0/me?$select($select=name)",
3142
};
3243

3344
describe("urlParsing.ts", () => {
@@ -42,5 +53,5 @@ describe("urlParsing.ts", () => {
4253
}
4354
}
4455
});
45-
/* tslint:enable: no-string-literal */
4656
});
57+
/* tslint:enable: no-string-literal */

spec/development/workload/OneNote.ts

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,27 @@ describe("OneNote", function() {
7070
}
7171
});
7272
it("Create a OneNote page with html page content", async () => {
73-
try {
74-
const formData = new FormData();
75-
formData.append("Presentation", fs.createReadStream("./spec/sample_files/onenotepage.html"));
76-
const json = await client.api(`/me/onenote/sections/${section.id}/pages`).post(formData);
77-
const createdPageFromHTML = json as OnenotePage;
73+
const formData = new FormData();
74+
formData.append("Presentation", fs.createReadStream("./spec/sample_files/onenotepage.html"));
75+
const json = await client.api(`/me/onenote/sections/${section.id}/pages`).post(formData);
76+
const createdPageFromHTML = json as OnenotePage;
7877

79-
assert.isDefined(createdPage.id);
80-
assert.isDefined(createdPage.contentUrl);
81-
assert.equal("New Page", createdPageFromHTML.title);
82-
assert.isUndefined(createdPage["random fake property that should be null"]);
83-
} catch (error) {
84-
throw error;
85-
}
78+
assert.isDefined(createdPage.id);
79+
assert.isDefined(createdPage.contentUrl);
80+
assert.equal("New Page", createdPageFromHTML.title);
81+
assert.isUndefined(createdPage["random fake property that should be null"]);
82+
});
83+
84+
it("Create a OneNote page with application/xhtml+xml page content", async () => {
85+
const body = "<!DOCTYPE html><html><head><title>A page with a block of HTML</title></head><body><p>This page contains some <i>formatted</i> <b>text</b>.</p></body></html>";
86+
const json = await client
87+
.api(`/me/onenote/sections/${section.id}/pages`)
88+
.header("content-type", "application/xhtml+xml")
89+
.post(body);
90+
const createdPageFromHTML = json as OnenotePage;
91+
assert.isDefined(createdPage.id);
92+
assert.isDefined(createdPage.contentUrl);
93+
assert.isUndefined(createdPage["random fake property that should be null"]);
8694
});
8795

8896
it("create a OneNote page with html page content and file attachment", async () => {

0 commit comments

Comments
 (0)