Skip to content

Commit

Permalink
[Identity] Adding one test to confirm that specifying permissions wor…
Browse files Browse the repository at this point in the history
…ks (#15779)

* [Identity] Adding one test to confirm that specifying permissions works

* lint fix
  • Loading branch information
sadasant authored Jun 18, 2021
1 parent f99402d commit d9c0cf4
Show file tree
Hide file tree
Showing 2 changed files with 162 additions and 0 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ describe("DeviceCodeCredential", function() {
assert.ok(token?.expiresOnTimestamp! > Date.now());
});

it("authenticates with specific permissions", async function(this: Context) {
// These tests should not run live because this credential requires user interaction.
if (isLiveMode()) {
this.skip();
}
const credential = new DeviceCodeCredential({
tenantId: env.AZURE_TENANT_ID,
clientId: env.AZURE_CLIENT_ID
});

// Important: Specifying permissions on the scope parameter of getToken won't work on client credential flows.
const token = await credential.getToken("https://graph.microsoft.com/Calendars.Read");
assert.ok(token?.token);
assert.ok(token?.expiresOnTimestamp! > Date.now());
});

it("authenticates and allows the customization of the prompt callback", async function(this: Context) {
// These tests should not run live because this credential requires user interaction.
if (isLiveMode()) {
Expand Down

0 comments on commit d9c0cf4

Please sign in to comment.