Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ops new endpoints #32375

Open
wants to merge 3 commits into
base: feature/communication/entra-identity
Choose a base branch
from

Conversation

sofiar-msft
Copy link
Member

Packages impacted by this PR

Issues associated with this PR

Describe the problem that is addressed by this PR

What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen?

Are there test cases added in this PR? (If not, why?)

Provide a list of related PRs (if any)

Command used to generate this PR:**(Applicable only to SDK release request PRs)

Checklists

  • Added impacted package name to the issue description
  • Does this PR needs any fixes in the SDK Generator?** (If so, create an Issue in the Autorest/typescript repository and link it here)
  • Added a changelog (if necessary)


const entraTokenCredentialOptions: EntraCommunicationTokenCredentialOptions = {
resourceEndpoint: "https://<your-resource>.communication.azure.com",
tokenCredential: entraTokenCredential,
Copy link
Member

@AikoBB AikoBB Dec 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's inform clients using js to install the @azure/identity package

@@ -106,6 +106,25 @@ const entraTokenCredentialOptions: EntraCommunicationTokenCredentialOptions = {
const credential = new AzureCommunicationTokenCredential(entraTokenCredentialOptions);
```

The same approach can be used for authorizing an Entra user with a Teams license to use Teams Phone Extensibility features through your Azure Communication Services resource.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we also update changelog.md file with the upcoming changes

@@ -16,6 +16,13 @@ import {
createPipelineRequest,
} from "@azure/core-rest-pipeline";

const TeamsExtensionScopePrefix = "https://auth.msft.communication.azure.com/";
const ComunicationClientsScopePrefix = "https://communication.azure.com/clients/";
const TeamsExtensionEndpoint = "/access/teamsPhone/:exchangeTeamsAccessToken";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const TeamsExtensionEndpoint = "/access/teamsPhone/:exchangeTeamsAccessToken";
const TeamsExtensionEndpoint = "/access/teamsPhone/:exchangeAccessToken";

wrong endpoint, it should be this one


constructor(private options: EntraCommunicationTokenCredentialOptions) {
constructor(options: EntraCommunicationTokenCredentialOptions) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the private keyword was removed?

this.client = getClient(options.resourceEndpoint);
this.httpClient = createDefaultHttpClient();
this.options = options;
this.options.scopes = this.options.scopes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.options.scopes = this.options.scopes
this.options.scopes = this.options.scopes || ["https://communication.azure.com/clients/.default"];

can we simplify as follow?

return requestUri;
}

private DetermineEndpointAndApiVersion() : [string, string] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private DetermineEndpointAndApiVersion() : [string, string] {
private determineEndpointAndApiVersion() : [string, string] {

const scopes = ["https://communication.azure.com/clients/VoIP"];
const comunicationClientsEndpoint = "/access/entra/:exchangeAccessToken?api-version=2024-04-01-preview";
const communicationClientsScope = "https://communication.azure.com/clients/VoIP";
const teamsExtensionEndpoint = "/access/teamsPhone/:exchangeTeamsAccessToken?api-version=2025-03-02-preview";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const teamsExtensionEndpoint = "/access/teamsPhone/:exchangeTeamsAccessToken?api-version=2025-03-02-preview";
const teamsExtensionEndpoint = "/access/teamsPhone/:exchangeAccessToken?api-version=2025-03-02-preview";


it("Token exchange is not called again when Entra token stays the same", async function () {
let scope = successApiMock();
it("Token exchange is not called again when Entra token stays the same " + apiVersion, async function () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of the apiVersion can we use the endpoint, so we can differentiate between two endpoints

const credential = new AzureCommunicationTokenCredential(entraTokenCredentialOptions);

const tokenResult = (await credential.getToken()).token;
assert.strictEqual(tokenResult, acsToken);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we verify that the Entra endpoint is being called?

assert.isTrue(getTokenSpy.alwaysCalledWithExactly([scopes], undefined));
assert.isTrue(getTokenSpy.callCount > 0);
assert.isTrue(apiMock.isDone());
getTokenSpy.restore();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we verify if the correct endpoint is being called based on the provided scopes?

}

private DetermineEndpointAndApiVersion() : [string, string] {
if (!this.options.scopes || this.options.scopes.length === 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this if condition and the last else condition are not covered by unit tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants