|
4 | 4 | import { assert } from "chai";
|
5 | 5 | import { matrix } from "@azure/test-utils";
|
6 | 6 | import { env, isPlaybackMode, Recorder } from "@azure/test-utils-recorder";
|
7 |
| -import * as msal from "@azure/msal-node"; |
| 7 | +import { UsernamePasswordCredential } from "@azure/identity"; |
8 | 8 | import { CommunicationAccessToken, CommunicationIdentityClient } from "../../../src";
|
9 | 9 | import {
|
10 | 10 | createRecordedCommunicationIdentityClient,
|
@@ -47,26 +47,18 @@ matrix([[true, false]], async function(useAad) {
|
47 | 47 | it("successfully exchanges a Teams token for an ACS token", async function() {
|
48 | 48 | recorder.skip();
|
49 | 49 |
|
50 |
| - const msalConfig = { |
51 |
| - auth: { |
52 |
| - clientId: env.COMMUNICATION_M365_APP_ID, |
53 |
| - authority: `${env.COMMUNICATION_M365_AAD_AUTHORITY}/${env.COMMUNICATION_M365_AAD_TENANT}` |
54 |
| - } |
55 |
| - }; |
56 |
| - |
57 |
| - const request = { |
58 |
| - username: env.COMMUNICATION_MSAL_USERNAME, |
59 |
| - password: env.COMMUNICATION_MSAL_PASSWORD, |
60 |
| - scopes: [env.COMMUNICATION_M365_SCOPE] |
61 |
| - }; |
62 |
| - |
63 |
| - const pca = new msal.PublicClientApplication(msalConfig); |
| 50 | + const credential = new UsernamePasswordCredential( |
| 51 | + env.COMMUNICATION_M365_AAD_TENANT, |
| 52 | + env.COMMUNICATION_M365_APP_ID, |
| 53 | + env.COMMUNICATION_MSAL_USERNAME, |
| 54 | + env.COMMUNICATION_MSAL_PASSWORD |
| 55 | + ); |
64 | 56 |
|
65 |
| - const response = await pca.acquireTokenByUsernamePassword(request); |
| 57 | + const response = await credential.getToken([env.COMMUNICATION_M365_SCOPE]); |
66 | 58 | assert.isNotNull(response);
|
67 | 59 |
|
68 | 60 | const { token, expiresOn }: CommunicationAccessToken = await client.exchangeTeamsToken(
|
69 |
| - response!.accessToken |
| 61 | + response!.token |
70 | 62 | );
|
71 | 63 | assert.isString(token);
|
72 | 64 | assert.instanceOf(expiresOn, Date);
|
|
0 commit comments