Skip to content

Commit

Permalink
rename method ExchangeTeamsUserAadToken to GetTokenForTeamsUser (Azur…
Browse files Browse the repository at this point in the history
…e#24951)

* rename method ExchangeTeamsUserAadToken to GetTokenForTeamsUser

* regenerated test recordings

* regenerate api

* Update sdk/communication/Azure.Communication.Identity/tests/samples/Sample1_CommunicationIdentityClient.cs

Co-authored-by: Petr Švihlík <rocky.intel@gmail.com>

* Update sdk/communication/Azure.Communication.Identity/tests/samples/Sample1_CommunicationIdentityClient.cs

Co-authored-by: Petr Švihlík <rocky.intel@gmail.com>

Co-authored-by: Petr Švihlík <rocky.intel@gmail.com>
  • Loading branch information
martinbarnas-ms and petrsvihlik authored Oct 27, 2021
1 parent 11c9741 commit 6713b9c
Show file tree
Hide file tree
Showing 50 changed files with 786 additions and 630 deletions.
4 changes: 2 additions & 2 deletions sdk/communication/Azure.Communication.Identity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ Response deleteResponse = client.DeleteUser(user);

### Exchanging AAD access token of a Teams User for a Communication Identity access token

```C# Snippet:ExchangeTeamsTokenAsync
Response<AccessToken> tokenResponse = await client.ExchangeTeamsUserAadTokenAsync(teamsToken);
```C# Snippet:GetTokenForTeamsUserAsync
Response<AccessToken> tokenResponse = await client.GetTokenForTeamsUserAsync(teamsToken);
string token = tokenResponse.Value.Token;
Console.WriteLine($"Token: {token}");
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public CommunicationIdentityClient(System.Uri endpoint, Azure.Core.TokenCredenti
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Communication.CommunicationUserIdentifier>> CreateUserAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response DeleteUser(Azure.Communication.CommunicationUserIdentifier communicationUser, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> DeleteUserAsync(Azure.Communication.CommunicationUserIdentifier communicationUser, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response<Azure.Core.AccessToken> ExchangeTeamsUserAadToken(string teamsUserAadToken, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Core.AccessToken>> ExchangeTeamsUserAadTokenAsync(string teamsUserAadToken, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response<Azure.Core.AccessToken> GetToken(Azure.Communication.CommunicationUserIdentifier communicationUser, System.Collections.Generic.IEnumerable<Azure.Communication.Identity.CommunicationTokenScope> scopes, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Core.AccessToken>> GetTokenAsync(Azure.Communication.CommunicationUserIdentifier communicationUser, System.Collections.Generic.IEnumerable<Azure.Communication.Identity.CommunicationTokenScope> scopes, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response<Azure.Core.AccessToken> GetTokenForTeamsUser(string teamsUserAadToken, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Core.AccessToken>> GetTokenForTeamsUserAsync(string teamsUserAadToken, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response RevokeTokens(Azure.Communication.CommunicationUserIdentifier communicationUser, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> RevokeTokensAsync(Azure.Communication.CommunicationUserIdentifier communicationUser, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ Console.WriteLine($"Expires On: {expiresOn}");

The `CommunicationIdentityClient` can be used to exchange an AAD access token of a Teams user for a new Communication Identity access token with a matching expiration time.

```C# Snippet:ExchangeTeamsToken
Response<AccessToken> tokenResponse = client.ExchangeTeamsUserAadToken(teamsToken);
```C# Snippet:GetTokenForTeamsUser
Response<AccessToken> tokenResponse = client.GetTokenForTeamsUser(teamsToken);
string token = tokenResponse.Value.Token;
Console.WriteLine($"Token: {token}");
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ Console.WriteLine($"Expires On: {expiresOn}");

The `CommunicationIdentityClient` can be used to exchange an AAD access token of a Teams user for a new Communication Identity access token with a matching expiration time.

```C# Snippet:ExchangeTeamsTokenAsync
Response<AccessToken> tokenResponse = await client.ExchangeTeamsUserAadTokenAsync(teamsToken);
```C# Snippet:GetTokenForTeamsUserAsync
Response<AccessToken> tokenResponse = await client.GetTokenForTeamsUserAsync(teamsToken);
string token = tokenResponse.Value.Token;
Console.WriteLine($"Token: {token}");
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ public virtual async Task<Response> RevokeTokensAsync(CommunicationUserIdentifie
/// <param name="teamsUserAadToken">AAD access token of a Teams User to acquire a new Communication Identity access token.</param>
/// <param name="cancellationToken">The cancellation token to use.</param>
/// <exception cref="RequestFailedException">The server returned an error.</exception>
public virtual Response<AccessToken> ExchangeTeamsUserAadToken(string teamsUserAadToken, CancellationToken cancellationToken = default)
public virtual Response<AccessToken> GetTokenForTeamsUser(string teamsUserAadToken, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CommunicationIdentityClient)}.{nameof(ExchangeTeamsUserAadToken)}");
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CommunicationIdentityClient)}.{nameof(GetTokenForTeamsUser)}");
scope.Start();
try
{
Expand All @@ -304,9 +304,9 @@ public virtual Response<AccessToken> ExchangeTeamsUserAadToken(string teamsUserA
/// <summary>Asynchronously exchange an AAD access token of a Teams User for a Communication Identity access token.</summary>
/// <param name="teamsUserAadToken">AAD access token of a Teams User to acquire a new Communication Identity access token.</param>
/// <param name="cancellationToken">The cancellation token to use.</param>
public virtual async Task<Response<AccessToken>> ExchangeTeamsUserAadTokenAsync(String teamsUserAadToken, CancellationToken cancellationToken = default)
public virtual async Task<Response<AccessToken>> GetTokenForTeamsUserAsync(String teamsUserAadToken, CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CommunicationIdentityClient)}.{nameof(ExchangeTeamsUserAadToken)}");
using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(CommunicationIdentityClient)}.{nameof(GetTokenForTeamsUser)}");
scope.Start();
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public async Task RevokeTokenWithNullUserShouldThrow()
}

[Test]
public async Task ExchangeTeamsUserAadTokenWithValidToken()
public async Task GetTokenForTeamsUserWithValidToken()
{
if (TestEnvironment.ShouldIgnoreIdentityExchangeTokenTest) {
Assert.Ignore("Ignore exchange teams token test if flag is enabled.");
Expand All @@ -140,18 +140,18 @@ public async Task ExchangeTeamsUserAadTokenWithValidToken()
string token = await generateTeamsToken();

CommunicationIdentityClient client = CreateClientWithConnectionString();
Response<AccessToken> tokenResponse = await client.ExchangeTeamsUserAadTokenAsync(token);
Response<AccessToken> tokenResponse = await client.GetTokenForTeamsUserAsync(token);
Assert.IsNotNull(tokenResponse.Value);
Assert.IsFalse(string.IsNullOrWhiteSpace(tokenResponse.Value.Token));
}

[Test]
public async Task ExchangeTeamsUserAadTokenWithEmptyTokenShouldThrow()
public async Task GetTokenForTeamsUserWithEmptyTokenShouldThrow()
{
try
{
CommunicationIdentityClient client = CreateClientWithConnectionString();
Response<AccessToken> tokenResponse = await client.ExchangeTeamsUserAadTokenAsync("");
Response<AccessToken> tokenResponse = await client.GetTokenForTeamsUserAsync("");
}
catch (RequestFailedException ex)
{
Expand All @@ -164,12 +164,12 @@ public async Task ExchangeTeamsUserAadTokenWithEmptyTokenShouldThrow()
}

[Test]
public async Task ExchangeTeamsUserAadTokenWithNullTokenShouldThrow()
public async Task GetTokenForTeamsUserWithNullTokenShouldThrow()
{
try
{
CommunicationIdentityClient client = CreateClientWithConnectionString();
Response<AccessToken> tokenResponse = await client.ExchangeTeamsUserAadTokenAsync(null);
Response<AccessToken> tokenResponse = await client.GetTokenForTeamsUserAsync(null);
}
catch (ArgumentNullException ex)
{
Expand All @@ -180,12 +180,12 @@ public async Task ExchangeTeamsUserAadTokenWithNullTokenShouldThrow()
}

[Test]
public async Task ExchangeTeamsUserAadTokenWithInvalidTokenShouldThrow()
public async Task GetTokenForTeamsUserWithInvalidTokenShouldThrow()
{
try
{
CommunicationIdentityClient client = CreateClientWithConnectionString();
Response<AccessToken> tokenResponse = await client.ExchangeTeamsUserAadTokenAsync("invalid");
Response<AccessToken> tokenResponse = await client.GetTokenForTeamsUserAsync("invalid");
}
catch (RequestFailedException ex)
{
Expand All @@ -198,12 +198,12 @@ public async Task ExchangeTeamsUserAadTokenWithInvalidTokenShouldThrow()
}

[Test]
public async Task ExchangeTeamsUserAadTokenWithExpiredTokenShouldThrow()
public async Task GetTokenForTeamsUserWithExpiredTokenShouldThrow()
{
try
{
CommunicationIdentityClient client = CreateClientWithConnectionString();
Response<AccessToken> tokenResponse = await client.ExchangeTeamsUserAadTokenAsync(TestEnvironment.CommunicationExpiredTeamsToken);
Response<AccessToken> tokenResponse = await client.GetTokenForTeamsUserAsync(TestEnvironment.CommunicationExpiredTeamsToken);
}
catch (RequestFailedException ex)
{
Expand Down

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

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

This file was deleted.

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

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

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

Loading

0 comments on commit 6713b9c

Please sign in to comment.