diff --git a/core/test/Microsoft.Teams.Bot.Core.Tests/AgenticIdentitiyFromEnv.cs b/core/test/Microsoft.Teams.Bot.Core.Tests/AgenticIdentitiyFromEnv.cs new file mode 100644 index 00000000..6e39dd3f --- /dev/null +++ b/core/test/Microsoft.Teams.Bot.Core.Tests/AgenticIdentitiyFromEnv.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Text; +using Microsoft.Teams.Bot.Core.Schema; + +namespace Microsoft.Teams.Bot.Core.Tests +{ + internal class AgenticIdentitiyFromEnv + { + + internal static ConversationAccount GetConversationAccountWithAgenticProperties() + { + var agenticUserId = Environment.GetEnvironmentVariable("TEST_AGENTIC_USERID"); + var agenticAppId = Environment.GetEnvironmentVariable("TEST_AGENTIC_APPID"); + var agenticAppBlueprintId = Environment.GetEnvironmentVariable("AzureAd__ClientId"); + + if (string.IsNullOrEmpty(agenticUserId)) + { + return new ConversationAccount(); + } + + ConversationAccount account = new() + { + Id = agenticUserId, + Name = "Agentic User", + Properties = + { + { "agenticUserId", agenticUserId }, + { "agenticAppId", agenticAppId }, + { "agenticAppBlueprintId", agenticAppBlueprintId } + } + }; + return account; + } + + internal static AgenticIdentity GetAgenticIdentity() + { + var agenticUserId = Environment.GetEnvironmentVariable("TEST_AGENTIC_USERID"); + var agenticAppId = Environment.GetEnvironmentVariable("TEST_AGENTIC_APPID"); + var agenticAppBlueprintId = Environment.GetEnvironmentVariable("AzureAd__ClientId"); + + if (string.IsNullOrEmpty(agenticUserId)) + { + return null!; + } + + AgenticIdentity identity = new() + { + AgenticUserId = agenticUserId, + AgenticAppId = agenticAppId, + AgenticAppBlueprintId = agenticAppBlueprintId + }; + return identity; + } + } +} diff --git a/core/test/Microsoft.Teams.Bot.Core.Tests/CompatTeamsInfoTests.cs b/core/test/Microsoft.Teams.Bot.Core.Tests/CompatTeamsInfoTests.cs index 0546c7da..a919b14d 100644 --- a/core/test/Microsoft.Teams.Bot.Core.Tests/CompatTeamsInfoTests.cs +++ b/core/test/Microsoft.Teams.Bot.Core.Tests/CompatTeamsInfoTests.cs @@ -178,7 +178,7 @@ await adapter.ContinueConversationAsync( CancellationToken.None); } - [Fact] + [Fact(Skip = "Require special permissions")] public async Task GetMeetingInfoAsync_WithMeetingId_ReturnsMeetingInfo() { var adapter = InitializeCompatAdapter(); @@ -224,7 +224,7 @@ await adapter.ContinueConversationAsync( CancellationToken.None); } - [Fact] + [Fact(Skip = "Require special permissions")] public async Task SendMeetingNotificationAsync_SendsNotification() { var adapter = InitializeCompatAdapter(); @@ -323,7 +323,7 @@ await adapter.ContinueConversationAsync( CancellationToken.None); } - [Fact] + [Fact(Skip = "Require special permissions")] public async Task SendMessageToListOfUsersAsync_ReturnsOperationId() { var adapter = InitializeCompatAdapter(); @@ -362,7 +362,7 @@ await adapter.ContinueConversationAsync( CancellationToken.None); } - [Fact] + [Fact(Skip = "Require special permissions")] public async Task SendMessageToListOfChannelsAsync_ReturnsOperationId() { var adapter = InitializeCompatAdapter(); @@ -396,7 +396,7 @@ await adapter.ContinueConversationAsync( CancellationToken.None); } - [Fact] + [Fact(Skip = "Require special permissions")] public async Task SendMessageToAllUsersInTeamAsync_ReturnsOperationId() { var adapter = InitializeCompatAdapter(); @@ -455,7 +455,7 @@ await adapter.ContinueConversationAsync( CancellationToken.None); } - [Fact] + [Fact(Skip = "Require special permissions")] public async Task SendMessageToTeamsChannelAsync_CreatesConversationAndSendsMessage() { var adapter = InitializeCompatAdapter(); @@ -487,7 +487,7 @@ await adapter.ContinueConversationAsync( CancellationToken.None); } - [Fact] + [Fact(Skip = "Require special permissions")] public async Task GetOperationStateAsync_WithOperationId_ReturnsState() { var adapter = InitializeCompatAdapter(); @@ -510,7 +510,7 @@ await adapter.ContinueConversationAsync( CancellationToken.None); } - [Fact] + [Fact(Skip = "Require special permissions")] public async Task GetPagedFailedEntriesAsync_WithOperationId_ReturnsFailedEntries() { var adapter = InitializeCompatAdapter(); @@ -532,7 +532,7 @@ await adapter.ContinueConversationAsync( CancellationToken.None); } - [Fact] + [Fact(Skip = "Requires valid operation ID from batch operation")] public async Task CancelOperationAsync_WithOperationId_CancelsOperation() { var adapter = InitializeCompatAdapter(); diff --git a/core/test/Microsoft.Teams.Bot.Core.Tests/ConversationClientTest.cs b/core/test/Microsoft.Teams.Bot.Core.Tests/ConversationClientTest.cs index 85a583a6..ff9aad1d 100644 --- a/core/test/Microsoft.Teams.Bot.Core.Tests/ConversationClientTest.cs +++ b/core/test/Microsoft.Teams.Bot.Core.Tests/ConversationClientTest.cs @@ -1,11 +1,14 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using Microsoft.Teams.Bot.Core.Hosting; -using Microsoft.Teams.Bot.Core.Schema; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using Microsoft.Teams.Bot.Core; +using Microsoft.Teams.Bot.Core.Hosting; +using Microsoft.Teams.Bot.Core.Schema; +using Microsoft.Teams.Bot.Core.Tests; +using Xunit.Abstractions; namespace Microsoft.Bot.Core.Tests; @@ -14,9 +17,11 @@ public class ConversationClientTest private readonly ServiceProvider _serviceProvider; private readonly ConversationClient _conversationClient; private readonly Uri _serviceUrl; + private readonly ITestOutputHelper testOutput; - public ConversationClientTest() + public ConversationClientTest(ITestOutputHelper outputHelper) { + testOutput = outputHelper; IConfigurationBuilder builder = new ConfigurationBuilder() .SetBasePath(AppDomain.CurrentDomain.BaseDirectory) .AddEnvironmentVariables(); @@ -24,7 +29,12 @@ public ConversationClientTest() IConfiguration configuration = builder.Build(); ServiceCollection services = new(); - services.AddLogging(); + services.AddLogging((builder) => { + builder.AddXUnit(outputHelper); + builder.AddFilter("System.Net", LogLevel.Warning); + builder.AddFilter("Microsoft.Identity", LogLevel.Warning); + builder.AddFilter("Microsoft.Teams", LogLevel.Information); + }); services.AddSingleton(configuration); services.AddBotApplication(); _serviceProvider = services.BuildServiceProvider(); @@ -40,6 +50,28 @@ public async Task SendActivityDefault() Type = ActivityType.Message, Properties = { { "text", $"Message from Automated tests, running in SDK `{BotApplication.Version}` at `{DateTime.UtcNow:s}`" } }, ServiceUrl = _serviceUrl, + From = AgenticIdentitiyFromEnv.GetConversationAccountWithAgenticProperties(), + Conversation = new() + { + Id = Environment.GetEnvironmentVariable("TEST_CONVERSATIONID") ?? throw new InvalidOperationException("TEST_ConversationId environment variable not set") + } + }; + SendActivityResponse res = await _conversationClient.SendActivityAsync(activity, cancellationToken: CancellationToken.None); + Assert.NotNull(res); + Assert.NotNull(res.Id); + } + + + + [Fact] + public async Task SendActivityDefaultWithAgentic() + { + CoreActivity activity = new() + { + Type = ActivityType.Message, + Properties = { { "text", $"Message from Automated tests, running in SDK `{BotApplication.Version}` at `{DateTime.UtcNow:s}`" } }, + ServiceUrl = _serviceUrl, + From = AgenticIdentitiyFromEnv.GetConversationAccountWithAgenticProperties(), Conversation = new() { Id = Environment.GetEnvironmentVariable("TEST_CONVERSATIONID") ?? throw new InvalidOperationException("TEST_ConversationId environment variable not set") @@ -59,6 +91,7 @@ public async Task SendActivityToChannel() Type = ActivityType.Message, Properties = { { "text", $"Message from Automated tests, running in SDK `{BotApplication.Version}` at `{DateTime.UtcNow:s}`" } }, ServiceUrl = _serviceUrl, + From = AgenticIdentitiyFromEnv.GetConversationAccountWithAgenticProperties(), Conversation = new() { Id = Environment.GetEnvironmentVariable("TEST_CHANNELID") ?? throw new InvalidOperationException("TEST_CHANNELID environment variable not set") @@ -77,6 +110,7 @@ public async Task SendActivityToPersonalChat_FailsWithBad_ConversationId() Type = ActivityType.Message, Properties = { { "text", $"Message from Automated tests, running in SDK `{BotApplication.Version}` at `{DateTime.UtcNow:s}`" } }, ServiceUrl = _serviceUrl, + From = AgenticIdentitiyFromEnv.GetConversationAccountWithAgenticProperties(), Conversation = new() { Id = "a:1" @@ -96,6 +130,7 @@ public async Task UpdateActivity() Type = ActivityType.Message, Properties = { { "text", $"Original message from Automated tests at `{DateTime.UtcNow:s}`" } }, ServiceUrl = _serviceUrl, + From = AgenticIdentitiyFromEnv.GetConversationAccountWithAgenticProperties(), Conversation = new() { Id = Environment.GetEnvironmentVariable("TEST_CONVERSATIONID") ?? throw new InvalidOperationException("TEST_ConversationId environment variable not set") @@ -111,6 +146,7 @@ public async Task UpdateActivity() { Type = ActivityType.Message, Properties = { { "text", $"Updated message from Automated tests at `{DateTime.UtcNow:s}`" } }, + From = AgenticIdentitiyFromEnv.GetConversationAccountWithAgenticProperties(), ServiceUrl = _serviceUrl, }; @@ -133,6 +169,7 @@ public async Task DeleteActivity() Type = ActivityType.Message, Properties = { { "text", $"Message to delete from Automated tests at `{DateTime.UtcNow:s}`" } }, ServiceUrl = _serviceUrl, + From = AgenticIdentitiyFromEnv.GetConversationAccountWithAgenticProperties(), Conversation = new() { Id = Environment.GetEnvironmentVariable("TEST_CONVERSATIONID") ?? throw new InvalidOperationException("TEST_ConversationId environment variable not set") @@ -151,6 +188,7 @@ await _conversationClient.DeleteActivityAsync( activity.Conversation.Id, sendResponse.Id, _serviceUrl, + AgenticIdentitiyFromEnv.GetAgenticIdentity(), cancellationToken: CancellationToken.None); // If no exception was thrown, the delete was successful @@ -164,16 +202,17 @@ public async Task GetConversationMembers() IList members = await _conversationClient.GetConversationMembersAsync( conversationId, _serviceUrl, + AgenticIdentitiyFromEnv.GetAgenticIdentity(), cancellationToken: CancellationToken.None); Assert.NotNull(members); Assert.NotEmpty(members); // Log members - Console.WriteLine($"Found {members.Count} members in conversation {conversationId}:"); + testOutput.WriteLine($"Found {members.Count} members in conversation {conversationId}:"); foreach (ConversationAccount member in members) { - Console.WriteLine($" - Id: {member.Id}, Name: {member.Name}"); + testOutput.WriteLine($" - Id: {member.Id}, Name: {member.Name}"); Assert.NotNull(member); Assert.NotNull(member.Id); } @@ -189,13 +228,14 @@ public async Task GetConversationMember() conversationId, userId, _serviceUrl, + AgenticIdentitiyFromEnv.GetAgenticIdentity(), cancellationToken: CancellationToken.None); Assert.NotNull(member); // Log member - Console.WriteLine($"Found member in conversation {conversationId}:"); - Console.WriteLine($" - Id: {member.Id}, Name: {member.Name}"); + testOutput.WriteLine($"Found member in conversation {conversationId}:"); + testOutput.WriteLine($" - Id: {member.Id}, Name: {member.Name}"); Assert.NotNull(member); Assert.NotNull(member.Id); } @@ -209,16 +249,17 @@ public async Task GetConversationMembersInChannel() IList members = await _conversationClient.GetConversationMembersAsync( channelId, _serviceUrl, + AgenticIdentitiyFromEnv.GetAgenticIdentity(), cancellationToken: CancellationToken.None); Assert.NotNull(members); Assert.NotEmpty(members); // Log members - Console.WriteLine($"Found {members.Count} members in channel {channelId}:"); + testOutput.WriteLine($"Found {members.Count} members in channel {channelId}:"); foreach (ConversationAccount member in members) { - Console.WriteLine($" - Id: {member.Id}, Name: {member.Name}"); + testOutput.WriteLine($" - Id: {member.Id}, Name: {member.Name}"); Assert.NotNull(member); Assert.NotNull(member.Id); } @@ -233,6 +274,7 @@ public async Task GetActivityMembers() Type = ActivityType.Message, Properties = { { "text", $"Message for GetActivityMembers test at `{DateTime.UtcNow:s}`" } }, ServiceUrl = _serviceUrl, + From = AgenticIdentitiyFromEnv.GetConversationAccountWithAgenticProperties(), Conversation = new() { Id = Environment.GetEnvironmentVariable("TEST_CONVERSATIONID") ?? throw new InvalidOperationException("TEST_ConversationId environment variable not set") @@ -248,16 +290,17 @@ public async Task GetActivityMembers() activity.Conversation.Id, sendResponse.Id, _serviceUrl, + AgenticIdentitiyFromEnv.GetAgenticIdentity(), cancellationToken: CancellationToken.None); Assert.NotNull(members); Assert.NotEmpty(members); // Log activity members - Console.WriteLine($"Found {members.Count} members for activity {sendResponse.Id}:"); + testOutput.WriteLine($"Found {members.Count} members for activity {sendResponse.Id}:"); foreach (ConversationAccount member in members) { - Console.WriteLine($" - Id: {member.Id}, Name: {member.Name}"); + testOutput.WriteLine($" - Id: {member.Id}, Name: {member.Name}"); Assert.NotNull(member); Assert.NotNull(member.Id); } @@ -276,19 +319,19 @@ public async Task GetConversations() Assert.NotEmpty(response.Conversations); // Log conversations - Console.WriteLine($"Found {response.Conversations.Count} conversations:"); + testOutput.WriteLine($"Found {response.Conversations.Count} conversations:"); foreach (ConversationMembers conversation in response.Conversations) { - Console.WriteLine($" - Conversation Id: {conversation.Id}"); + testOutput.WriteLine($" - Conversation Id: {conversation.Id}"); Assert.NotNull(conversation); Assert.NotNull(conversation.Id); if (conversation.Members != null && conversation.Members.Any()) { - Console.WriteLine($" Members ({conversation.Members.Count}):"); + testOutput.WriteLine($" Members ({conversation.Members.Count}):"); foreach (ConversationAccount member in conversation.Members) { - Console.WriteLine($" - Id: {member.Id}, Name: {member.Name}"); + testOutput.WriteLine($" - Id: {member.Id}, Name: {member.Name}"); } } } @@ -315,14 +358,15 @@ public async Task CreateConversation_WithMembers() CreateConversationResponse response = await _conversationClient.CreateConversationAsync( parameters, _serviceUrl, + AgenticIdentitiyFromEnv.GetAgenticIdentity(), cancellationToken: CancellationToken.None); Assert.NotNull(response); Assert.NotNull(response.Id); - Console.WriteLine($"Created conversation: {response.Id}"); - Console.WriteLine($" ActivityId: {response.ActivityId}"); - Console.WriteLine($" ServiceUrl: {response.ServiceUrl}"); + testOutput.WriteLine($"Created conversation: {response.Id}"); + testOutput.WriteLine($" ActivityId: {response.ActivityId}"); + testOutput.WriteLine($" ServiceUrl: {response.ServiceUrl}"); // Send a message to the newly created conversation CoreActivity activity = new() @@ -340,7 +384,7 @@ public async Task CreateConversation_WithMembers() Assert.NotNull(sendResponse); Assert.NotNull(sendResponse.Id); - Console.WriteLine($" Sent message with activity ID: {sendResponse.Id}"); + testOutput.WriteLine($" Sent message with activity ID: {sendResponse.Id}"); } // TODO: This doesn't work @@ -368,12 +412,13 @@ public async Task CreateConversation_WithGroup() CreateConversationResponse response = await _conversationClient.CreateConversationAsync( parameters, _serviceUrl, + AgenticIdentitiyFromEnv.GetAgenticIdentity(), cancellationToken: CancellationToken.None); Assert.NotNull(response); Assert.NotNull(response.Id); - Console.WriteLine($"Created group conversation: {response.Id}"); + testOutput.WriteLine($"Created group conversation: {response.Id}"); // Send a message to the newly created group conversation CoreActivity activity = new() @@ -391,7 +436,7 @@ public async Task CreateConversation_WithGroup() Assert.NotNull(sendResponse); Assert.NotNull(sendResponse.Id); - Console.WriteLine($" Sent message with activity ID: {sendResponse.Id}"); + testOutput.WriteLine($" Sent message with activity ID: {sendResponse.Id}"); } // TODO: This doesn't work @@ -421,7 +466,7 @@ public async Task CreateConversation_WithTopicName() Assert.NotNull(response); Assert.NotNull(response.Id); - Console.WriteLine($"Created conversation with topic '{parameters.TopicName}': {response.Id}"); + testOutput.WriteLine($"Created conversation with topic '{parameters.TopicName}': {response.Id}"); // Send a message to the newly created conversation CoreActivity activity = new() @@ -439,7 +484,7 @@ public async Task CreateConversation_WithTopicName() Assert.NotNull(sendResponse); Assert.NotNull(sendResponse.Id); - Console.WriteLine($" Sent message with activity ID: {sendResponse.Id}"); + testOutput.WriteLine($" Sent message with activity ID: {sendResponse.Id}"); } // TODO: This doesn't fail, but doesn't actually create the initial activity @@ -468,14 +513,15 @@ public async Task CreateConversation_WithInitialActivity() CreateConversationResponse response = await _conversationClient.CreateConversationAsync( parameters, _serviceUrl, + AgenticIdentitiyFromEnv.GetAgenticIdentity(), cancellationToken: CancellationToken.None); Assert.NotNull(response); Assert.NotNull(response.Id); // Assert.NotNull(response.ActivityId); // Should have an activity ID since we sent an initial message - Console.WriteLine($"Created conversation with initial activity: {response.Id}"); - Console.WriteLine($" Initial activity ID: {response.ActivityId}"); + testOutput.WriteLine($"Created conversation with initial activity: {response.Id}"); + testOutput.WriteLine($" Initial activity ID: {response.ActivityId}"); } [Fact] @@ -502,12 +548,13 @@ public async Task CreateConversation_WithChannelData() CreateConversationResponse response = await _conversationClient.CreateConversationAsync( parameters, _serviceUrl, + AgenticIdentitiyFromEnv.GetAgenticIdentity(), cancellationToken: CancellationToken.None); Assert.NotNull(response); Assert.NotNull(response.Id); - Console.WriteLine($"Created conversation with channel data: {response.Id}"); + testOutput.WriteLine($"Created conversation with channel data: {response.Id}"); } [Fact] @@ -518,23 +565,26 @@ public async Task GetConversationPagedMembers() PagedMembersResult result = await _conversationClient.GetConversationPagedMembersAsync( conversationId, _serviceUrl, + 10, + null!, + AgenticIdentitiyFromEnv.GetAgenticIdentity(), cancellationToken: CancellationToken.None); Assert.NotNull(result); Assert.NotNull(result.Members); Assert.NotEmpty(result.Members); - Console.WriteLine($"Found {result.Members.Count} members in page:"); + testOutput.WriteLine($"Found {result.Members.Count} members in page:"); foreach (ConversationAccount member in result.Members) { - Console.WriteLine($" - Id: {member.Id}, Name: {member.Name}"); + testOutput.WriteLine($" - Id: {member.Id}, Name: {member.Name}"); Assert.NotNull(member); Assert.NotNull(member.Id); } if (!string.IsNullOrWhiteSpace(result.ContinuationToken)) { - Console.WriteLine($"Continuation token: {result.ContinuationToken}"); + testOutput.WriteLine($"Continuation token: {result.ContinuationToken}"); } } @@ -554,16 +604,16 @@ public async Task GetConversationPagedMembers_WithPageSize() Assert.NotEmpty(result.Members); Assert.Single(result.Members); - Console.WriteLine($"Found {result.Members.Count} members with pageSize=1:"); + testOutput.WriteLine($"Found {result.Members.Count} members with pageSize=1:"); foreach (ConversationAccount member in result.Members) { - Console.WriteLine($" - Id: {member.Id}, Name: {member.Name}"); + testOutput.WriteLine($" - Id: {member.Id}, Name: {member.Name}"); } // If there's a continuation token, get the next page if (!string.IsNullOrWhiteSpace(result.ContinuationToken)) { - Console.WriteLine($"Getting next page with continuation token..."); + testOutput.WriteLine($"Getting next page with continuation token..."); PagedMembersResult nextPage = await _conversationClient.GetConversationPagedMembersAsync( conversationId, @@ -575,10 +625,10 @@ public async Task GetConversationPagedMembers_WithPageSize() Assert.NotNull(nextPage); Assert.NotNull(nextPage.Members); - Console.WriteLine($"Found {nextPage.Members.Count} members in next page:"); + testOutput.WriteLine($"Found {nextPage.Members.Count} members in next page:"); foreach (ConversationAccount member in nextPage.Members) { - Console.WriteLine($" - Id: {member.Id}, Name: {member.Name}"); + testOutput.WriteLine($" - Id: {member.Id}, Name: {member.Name}"); } } } @@ -597,10 +647,10 @@ public async Task DeleteConversationMember() Assert.NotNull(membersBefore); Assert.NotEmpty(membersBefore); - Console.WriteLine($"Members before deletion: {membersBefore.Count}"); + testOutput.WriteLine($"Members before deletion: {membersBefore.Count}"); foreach (ConversationAccount member in membersBefore) { - Console.WriteLine($" - Id: {member.Id}, Name: {member.Name}"); + testOutput.WriteLine($" - Id: {member.Id}, Name: {member.Name}"); } // Delete the test user @@ -615,7 +665,7 @@ await _conversationClient.DeleteConversationMemberAsync( _serviceUrl, cancellationToken: CancellationToken.None); - Console.WriteLine($"Deleted member: {memberToDelete}"); + testOutput.WriteLine($"Deleted member: {memberToDelete}"); // Get members after deletion IList membersAfter = await _conversationClient.GetConversationMembersAsync( @@ -625,10 +675,10 @@ await _conversationClient.DeleteConversationMemberAsync( Assert.NotNull(membersAfter); - Console.WriteLine($"Members after deletion: {membersAfter.Count}"); + testOutput.WriteLine($"Members after deletion: {membersAfter.Count}"); foreach (ConversationAccount member in membersAfter) { - Console.WriteLine($" - Id: {member.Id}, Name: {member.Name}"); + testOutput.WriteLine($" - Id: {member.Id}, Name: {member.Name}"); } // Verify the member was deleted @@ -680,8 +730,8 @@ public async Task SendConversationHistory() Assert.NotNull(response); - Console.WriteLine($"Sent conversation history with {transcript.Activities?.Count} activities"); - Console.WriteLine($"Response ID: {response.Id}"); + testOutput.WriteLine($"Sent conversation history with {transcript.Activities?.Count} activities"); + testOutput.WriteLine($"Response ID: {response.Id}"); } [Fact(Skip = "Attachment upload endpoint not found")] @@ -709,9 +759,11 @@ public async Task UploadAttachment() Assert.NotNull(response); Assert.NotNull(response.Id); - Console.WriteLine($"Uploaded attachment: {attachmentData.Name}"); - Console.WriteLine($" Attachment ID: {response.Id}"); - Console.WriteLine($" Content-Type: {attachmentData.Type}"); - Console.WriteLine($" Size: {fileBytes.Length} bytes"); + testOutput.WriteLine($"Uploaded attachment: {attachmentData.Name}"); + testOutput.WriteLine($" Attachment ID: {response.Id}"); + testOutput.WriteLine($" Content-Type: {attachmentData.Type}"); + testOutput.WriteLine($" Size: {fileBytes.Length} bytes"); } + + } diff --git a/core/test/Microsoft.Teams.Bot.Core.Tests/Microsoft.Teams.Bot.Core.Tests.csproj b/core/test/Microsoft.Teams.Bot.Core.Tests/Microsoft.Teams.Bot.Core.Tests.csproj index b7aad5b2..722bb12d 100644 --- a/core/test/Microsoft.Teams.Bot.Core.Tests/Microsoft.Teams.Bot.Core.Tests.csproj +++ b/core/test/Microsoft.Teams.Bot.Core.Tests/Microsoft.Teams.Bot.Core.Tests.csproj @@ -11,6 +11,7 @@ + diff --git a/core/test/Microsoft.Teams.Bot.Core.Tests/TeamsApiClientTests.cs b/core/test/Microsoft.Teams.Bot.Core.Tests/TeamsApiClientTests.cs index 861a4ad2..24035ed7 100644 --- a/core/test/Microsoft.Teams.Bot.Core.Tests/TeamsApiClientTests.cs +++ b/core/test/Microsoft.Teams.Bot.Core.Tests/TeamsApiClientTests.cs @@ -1,12 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -using Microsoft.Teams.Bot.Core; -using Microsoft.Teams.Bot.Core.Hosting; -using Microsoft.Teams.Bot.Core.Schema; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using Microsoft.Teams.Bot.Apps; +using Microsoft.Teams.Bot.Core; +using Microsoft.Teams.Bot.Core.Hosting; +using Microsoft.Teams.Bot.Core.Schema; +using Microsoft.Teams.Bot.Core.Tests; +using Xunit.Abstractions; namespace Microsoft.Bot.Core.Tests; @@ -15,9 +18,11 @@ public class TeamsApiClientTests private readonly ServiceProvider _serviceProvider; private readonly TeamsApiClient _teamsClient; private readonly Uri _serviceUrl; + private readonly ITestOutputHelper testOutput; - public TeamsApiClientTests() + public TeamsApiClientTests(ITestOutputHelper outputHelper) { + testOutput = outputHelper; IConfigurationBuilder builder = new ConfigurationBuilder() .SetBasePath(AppDomain.CurrentDomain.BaseDirectory) .AddEnvironmentVariables(); @@ -25,7 +30,12 @@ public TeamsApiClientTests() IConfiguration configuration = builder.Build(); ServiceCollection services = new(); - services.AddLogging(); + services.AddLogging((builder) => { + builder.AddXUnit(outputHelper); + builder.AddFilter("System.Net", LogLevel.Warning); + builder.AddFilter("Microsoft.Identity", LogLevel.Warning); + builder.AddFilter("Microsoft.Teams", LogLevel.Information); + }); services.AddSingleton(configuration); services.AddTeamsBotApplication(); _serviceProvider = services.BuildServiceProvider(); @@ -43,16 +53,17 @@ public async Task FetchChannelList() ChannelList result = await _teamsClient.FetchChannelListAsync( teamId, _serviceUrl, + AgenticIdentitiyFromEnv.GetAgenticIdentity(), cancellationToken: CancellationToken.None); Assert.NotNull(result); Assert.NotNull(result.Channels); Assert.NotEmpty(result.Channels); - Console.WriteLine($"Found {result.Channels.Count} channels in team {teamId}:"); + testOutput.WriteLine($"Found {result.Channels.Count} channels in team {teamId}:"); foreach (var channel in result.Channels) { - Console.WriteLine($" - Id: {channel.Id}, Name: {channel.Name}"); + testOutput.WriteLine($" - Id: {channel.Id}, Name: {channel.Name}"); Assert.NotNull(channel); Assert.NotNull(channel.Id); } @@ -62,7 +73,7 @@ public async Task FetchChannelList() public async Task FetchChannelList_FailsWithInvalidTeamId() { await Assert.ThrowsAsync(() - => _teamsClient.FetchChannelListAsync("invalid-team-id", _serviceUrl)); + => _teamsClient.FetchChannelListAsync("invalid-team-id", _serviceUrl, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } [Fact] @@ -73,25 +84,26 @@ public async Task FetchTeamDetails() TeamDetails result = await _teamsClient.FetchTeamDetailsAsync( teamId, _serviceUrl, + AgenticIdentitiyFromEnv.GetAgenticIdentity(), cancellationToken: CancellationToken.None); Assert.NotNull(result); Assert.NotNull(result.Id); - Console.WriteLine($"Team details for {teamId}:"); - Console.WriteLine($" - Id: {result.Id}"); - Console.WriteLine($" - Name: {result.Name}"); - Console.WriteLine($" - AAD Group Id: {result.AadGroupId}"); - Console.WriteLine($" - Channel Count: {result.ChannelCount}"); - Console.WriteLine($" - Member Count: {result.MemberCount}"); - Console.WriteLine($" - Type: {result.Type}"); + testOutput.WriteLine($"Team details for {teamId}:"); + testOutput.WriteLine($" - Id: {result.Id}"); + testOutput.WriteLine($" - Name: {result.Name}"); + testOutput.WriteLine($" - AAD Group Id: {result.AadGroupId}"); + testOutput.WriteLine($" - Channel Count: {result.ChannelCount}"); + testOutput.WriteLine($" - Member Count: {result.MemberCount}"); + testOutput.WriteLine($" - Type: {result.Type}"); } [Fact] public async Task FetchTeamDetails_FailsWithInvalidTeamId() { await Assert.ThrowsAsync(() - => _teamsClient.FetchTeamDetailsAsync("invalid-team-id", _serviceUrl)); + => _teamsClient.FetchTeamDetailsAsync("invalid-team-id", _serviceUrl, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } #endregion @@ -106,24 +118,25 @@ public async Task FetchMeetingInfo() MeetingInfo result = await _teamsClient.FetchMeetingInfoAsync( meetingId, _serviceUrl, + AgenticIdentitiyFromEnv.GetAgenticIdentity(), cancellationToken: CancellationToken.None); Assert.NotNull(result); //Assert.NotNull(result.Id); - Console.WriteLine($"Meeting info for {meetingId}:"); + testOutput.WriteLine($"Meeting info for {meetingId}:"); if (result.Details != null) { - Console.WriteLine($" - Title: {result.Details.Title}"); - Console.WriteLine($" - Type: {result.Details.Type}"); - Console.WriteLine($" - Join URL: {result.Details.JoinUrl}"); - Console.WriteLine($" - Scheduled Start: {result.Details.ScheduledStartTime}"); - Console.WriteLine($" - Scheduled End: {result.Details.ScheduledEndTime}"); + testOutput.WriteLine($" - Title: {result.Details.Title}"); + testOutput.WriteLine($" - Type: {result.Details.Type}"); + testOutput.WriteLine($" - Join URL: {result.Details.JoinUrl}"); + testOutput.WriteLine($" - Scheduled Start: {result.Details.ScheduledStartTime}"); + testOutput.WriteLine($" - Scheduled End: {result.Details.ScheduledEndTime}"); } if (result.Organizer != null) { - Console.WriteLine($" - Organizer: {result.Organizer.Name} ({result.Organizer.Id})"); + testOutput.WriteLine($" - Organizer: {result.Organizer.Name} ({result.Organizer.Id})"); } } @@ -146,24 +159,25 @@ public async Task FetchParticipant() participantId, tenantId, _serviceUrl, + AgenticIdentitiyFromEnv.GetAgenticIdentity(), cancellationToken: CancellationToken.None); Assert.NotNull(result); - Console.WriteLine($"Participant info for {participantId} in meeting {meetingId}:"); + testOutput.WriteLine($"Participant info for {participantId} in meeting {meetingId}:"); if (result.User != null) { - Console.WriteLine($" - User Id: {result.User.Id}"); - Console.WriteLine($" - User Name: {result.User.Name}"); + testOutput.WriteLine($" - User Id: {result.User.Id}"); + testOutput.WriteLine($" - User Name: {result.User.Name}"); } if (result.Meeting != null) { - Console.WriteLine($" - Role: {result.Meeting.Role}"); - Console.WriteLine($" - In Meeting: {result.Meeting.InMeeting}"); + testOutput.WriteLine($" - Role: {result.Meeting.Role}"); + testOutput.WriteLine($" - In Meeting: {result.Meeting.InMeeting}"); } } - [Fact(Skip = "Requires active meeting context")] + [Fact] public async Task SendMeetingNotification() { string meetingId = Environment.GetEnvironmentVariable("TEST_MEETINGID") ?? throw new InvalidOperationException("TEST_MEETINGID environment variable not set"); @@ -190,17 +204,18 @@ public async Task SendMeetingNotification() meetingId, notification, _serviceUrl, + AgenticIdentitiyFromEnv.GetAgenticIdentity(), cancellationToken: CancellationToken.None); Assert.NotNull(result); - Console.WriteLine($"Meeting notification sent to meeting {meetingId}"); + testOutput.WriteLine($"Meeting notification sent to meeting {meetingId}"); if (result.RecipientsFailureInfo != null && result.RecipientsFailureInfo.Count > 0) { - Console.WriteLine($"Failed recipients:"); + testOutput.WriteLine($"Failed recipients:"); foreach (var failure in result.RecipientsFailureInfo) { - Console.WriteLine($" - {failure.RecipientMri}: {failure.ErrorCode} - {failure.FailureReason}"); + testOutput.WriteLine($" - {failure.RecipientMri}: {failure.ErrorCode} - {failure.FailureReason}"); } } } @@ -209,10 +224,10 @@ public async Task SendMeetingNotification() #region Batch Message Operations Tests - [Fact(Skip = "Batch operations require special permissions")] + [Fact] public async Task SendMessageToListOfUsers() { - string tenantId = Environment.GetEnvironmentVariable("TENANT_ID") ?? throw new InvalidOperationException("TENANT_ID environment variable not set"); + string tenantId = Environment.GetEnvironmentVariable("TEST_TENANTID") ?? throw new InvalidOperationException("TEST_TENANTID environment variable not set"); string userId = Environment.GetEnvironmentVariable("TEST_USER_ID") ?? throw new InvalidOperationException("TEST_USER_ID environment variable not set"); CoreActivity activity = new() @@ -223,6 +238,11 @@ public async Task SendMessageToListOfUsers() IList members = [ + new TeamMember(userId), + new TeamMember(userId), + new TeamMember(userId), + new TeamMember(userId), + new TeamMember(userId), new TeamMember(userId) ]; @@ -231,41 +251,47 @@ public async Task SendMessageToListOfUsers() members, tenantId, _serviceUrl, + AgenticIdentitiyFromEnv.GetAgenticIdentity(), cancellationToken: CancellationToken.None); Assert.NotNull(operationId); Assert.NotEmpty(operationId); - Console.WriteLine($"Batch message sent. Operation ID: {operationId}"); + testOutput.WriteLine($"Batch message sent. Operation ID: {operationId}"); } - [Fact(Skip = "Batch operations require special permissions")] + [Fact] public async Task SendMessageToAllUsersInTenant() { - string tenantId = Environment.GetEnvironmentVariable("TENANT_ID") ?? throw new InvalidOperationException("TENANT_ID environment variable not set"); + string tenantId = Environment.GetEnvironmentVariable("TEST_TENANTID") ?? throw new InvalidOperationException("TEST_TENANTID environment variable not set"); CoreActivity activity = new() { Type = ActivityType.Message, - Properties = { { "text", $"Tenant-wide message from Automated tests at `{DateTime.UtcNow:s}`" } } + Properties = { { "text", $"Tenant-wide message from Automated tests at `{DateTime.UtcNow:s}`" } }, + Conversation = new() + { + Id = Environment.GetEnvironmentVariable("TEST_CONVERSATIONID") ?? throw new InvalidOperationException("TEST_ConversationId environment variable not set") + } }; string operationId = await _teamsClient.SendMessageToAllUsersInTenantAsync( activity, tenantId, _serviceUrl, + AgenticIdentitiyFromEnv.GetAgenticIdentity(), cancellationToken: CancellationToken.None); Assert.NotNull(operationId); Assert.NotEmpty(operationId); - Console.WriteLine($"Tenant-wide message sent. Operation ID: {operationId}"); + testOutput.WriteLine($"Tenant-wide message sent. Operation ID: {operationId}"); } - [Fact(Skip = "Batch operations require special permissions")] + [Fact] public async Task SendMessageToAllUsersInTeam() { - string tenantId = Environment.GetEnvironmentVariable("TENANT_ID") ?? throw new InvalidOperationException("TENANT_ID environment variable not set"); + string tenantId = Environment.GetEnvironmentVariable("TEST_TENANTID") ?? throw new InvalidOperationException("TEST_TENANTID environment variable not set"); string teamId = Environment.GetEnvironmentVariable("TEST_TEAMID") ?? throw new InvalidOperationException("TEST_TEAMID environment variable not set"); CoreActivity activity = new() @@ -279,12 +305,13 @@ public async Task SendMessageToAllUsersInTeam() teamId, tenantId, _serviceUrl, + AgenticIdentitiyFromEnv.GetAgenticIdentity(), cancellationToken: CancellationToken.None); Assert.NotNull(operationId); Assert.NotEmpty(operationId); - Console.WriteLine($"Team-wide message sent. Operation ID: {operationId}"); + testOutput.WriteLine($"Team-wide message sent. Operation ID: {operationId}"); } [Fact(Skip = "Batch operations require special permissions")] @@ -309,44 +336,46 @@ public async Task SendMessageToListOfChannels() channels, tenantId, _serviceUrl, + AgenticIdentitiyFromEnv.GetAgenticIdentity(), cancellationToken: CancellationToken.None); Assert.NotNull(operationId); Assert.NotEmpty(operationId); - Console.WriteLine($"Channel batch message sent. Operation ID: {operationId}"); + testOutput.WriteLine($"Channel batch message sent. Operation ID: {operationId}"); } #endregion #region Batch Operation Management Tests - [Fact(Skip = "Requires valid operation ID from batch operation")] + [Fact] public async Task GetOperationState() { - string operationId = Environment.GetEnvironmentVariable("TEST_OPERATION_ID") ?? throw new InvalidOperationException("TEST_OPERATION_ID environment variable not set"); + string operationId = "amer_9d3424a5-6ce6-477f-934d-59e8ea5f7f27"; // Environment.GetEnvironmentVariable("TEST_OPERATION_ID") ?? throw new InvalidOperationException("TEST_OPERATION_ID environment variable not set"); BatchOperationState result = await _teamsClient.GetOperationStateAsync( operationId, _serviceUrl, + AgenticIdentitiyFromEnv.GetAgenticIdentity(), cancellationToken: CancellationToken.None); Assert.NotNull(result); Assert.NotNull(result.State); - Console.WriteLine($"Operation state for {operationId}:"); - Console.WriteLine($" - State: {result.State}"); - Console.WriteLine($" - Total Entries: {result.TotalEntriesCount}"); + testOutput.WriteLine($"Operation state for {operationId}:"); + testOutput.WriteLine($" - State: {result.State}"); + testOutput.WriteLine($" - Total Entries: {result.TotalEntriesCount}"); if (result.StatusMap != null) { - Console.WriteLine($" - Success: {result.StatusMap.Success}"); - Console.WriteLine($" - Failed: {result.StatusMap.Failed}"); - Console.WriteLine($" - Throttled: {result.StatusMap.Throttled}"); - Console.WriteLine($" - Pending: {result.StatusMap.Pending}"); + testOutput.WriteLine($" - Success: {result.StatusMap.Success}"); + testOutput.WriteLine($" - Failed: {result.StatusMap.Failed}"); + testOutput.WriteLine($" - Throttled: {result.StatusMap.Throttled}"); + testOutput.WriteLine($" - Pending: {result.StatusMap.Pending}"); } if (result.RetryAfter != null) { - Console.WriteLine($" - Retry After: {result.RetryAfter}"); + testOutput.WriteLine($" - Retry After: {result.RetryAfter}"); } } @@ -354,7 +383,7 @@ public async Task GetOperationState() public async Task GetOperationState_FailsWithInvalidOperationId() { await Assert.ThrowsAsync(() - => _teamsClient.GetOperationStateAsync("invalid-operation-id", _serviceUrl)); + => _teamsClient.GetOperationStateAsync("invalid-operation-id", _serviceUrl, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } [Fact(Skip = "Requires valid operation ID from batch operation")] @@ -365,26 +394,28 @@ public async Task GetPagedFailedEntries() BatchFailedEntriesResponse result = await _teamsClient.GetPagedFailedEntriesAsync( operationId, _serviceUrl, + null, + AgenticIdentitiyFromEnv.GetAgenticIdentity(), cancellationToken: CancellationToken.None); Assert.NotNull(result); - Console.WriteLine($"Failed entries for operation {operationId}:"); + testOutput.WriteLine($"Failed entries for operation {operationId}:"); if (result.FailedEntries != null && result.FailedEntries.Count > 0) { foreach (var entry in result.FailedEntries) { - Console.WriteLine($" - Id: {entry.Id}, Error: {entry.Error}"); + testOutput.WriteLine($" - Id: {entry.Id}, Error: {entry.Error}"); } } else { - Console.WriteLine(" No failed entries"); + testOutput.WriteLine(" No failed entries"); } if (!string.IsNullOrWhiteSpace(result.ContinuationToken)) { - Console.WriteLine($"Continuation token: {result.ContinuationToken}"); + testOutput.WriteLine($"Continuation token: {result.ContinuationToken}"); } } @@ -396,9 +427,10 @@ public async Task CancelOperation() await _teamsClient.CancelOperationAsync( operationId, _serviceUrl, + AgenticIdentitiyFromEnv.GetAgenticIdentity(), cancellationToken: CancellationToken.None); - Console.WriteLine($"Operation {operationId} cancelled successfully"); + testOutput.WriteLine($"Operation {operationId} cancelled successfully"); } #endregion @@ -409,56 +441,56 @@ await _teamsClient.CancelOperationAsync( public async Task FetchChannelList_ThrowsOnNullTeamId() { await Assert.ThrowsAsync(() - => _teamsClient.FetchChannelListAsync(null!, _serviceUrl)); + => _teamsClient.FetchChannelListAsync(null!, _serviceUrl, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } [Fact] public async Task FetchChannelList_ThrowsOnEmptyTeamId() { await Assert.ThrowsAsync(() - => _teamsClient.FetchChannelListAsync("", _serviceUrl)); + => _teamsClient.FetchChannelListAsync("", _serviceUrl, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } [Fact] public async Task FetchChannelList_ThrowsOnNullServiceUrl() { await Assert.ThrowsAsync(() - => _teamsClient.FetchChannelListAsync("team-id", null!)); + => _teamsClient.FetchChannelListAsync("team-id", null!, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } [Fact] public async Task FetchTeamDetails_ThrowsOnNullTeamId() { await Assert.ThrowsAsync(() - => _teamsClient.FetchTeamDetailsAsync(null!, _serviceUrl)); + => _teamsClient.FetchTeamDetailsAsync(null!, _serviceUrl, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } [Fact] public async Task FetchMeetingInfo_ThrowsOnNullMeetingId() { await Assert.ThrowsAsync(() - => _teamsClient.FetchMeetingInfoAsync(null!, _serviceUrl)); + => _teamsClient.FetchMeetingInfoAsync(null!, _serviceUrl, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } [Fact] public async Task FetchParticipant_ThrowsOnNullMeetingId() { await Assert.ThrowsAsync(() - => _teamsClient.FetchParticipantAsync(null!, "participant", "tenant", _serviceUrl)); + => _teamsClient.FetchParticipantAsync(null!, "participant", "tenant", _serviceUrl, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } [Fact] public async Task FetchParticipant_ThrowsOnNullParticipantId() { await Assert.ThrowsAsync(() - => _teamsClient.FetchParticipantAsync("meeting", null!, "tenant", _serviceUrl)); + => _teamsClient.FetchParticipantAsync("meeting", null!, "tenant", _serviceUrl, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } [Fact] public async Task FetchParticipant_ThrowsOnNullTenantId() { await Assert.ThrowsAsync(() - => _teamsClient.FetchParticipantAsync("meeting", "participant", null!, _serviceUrl)); + => _teamsClient.FetchParticipantAsync("meeting", "participant", null!, _serviceUrl, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } [Fact] @@ -466,21 +498,21 @@ public async Task SendMeetingNotification_ThrowsOnNullMeetingId() { var notification = new TargetedMeetingNotification(); await Assert.ThrowsAsync(() - => _teamsClient.SendMeetingNotificationAsync(null!, notification, _serviceUrl)); + => _teamsClient.SendMeetingNotificationAsync(null!, notification, _serviceUrl, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } [Fact] public async Task SendMeetingNotification_ThrowsOnNullNotification() { await Assert.ThrowsAsync(() - => _teamsClient.SendMeetingNotificationAsync("meeting", null!, _serviceUrl)); + => _teamsClient.SendMeetingNotificationAsync("meeting", null!, _serviceUrl, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } [Fact] public async Task SendMessageToListOfUsers_ThrowsOnNullActivity() { await Assert.ThrowsAsync(() - => _teamsClient.SendMessageToListOfUsersAsync(null!, [new TeamMember("id")], "tenant", _serviceUrl)); + => _teamsClient.SendMessageToListOfUsersAsync(null!, [new TeamMember("id")], "tenant", _serviceUrl, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } [Fact] @@ -488,7 +520,7 @@ public async Task SendMessageToListOfUsers_ThrowsOnNullMembers() { var activity = new CoreActivity { Type = ActivityType.Message }; await Assert.ThrowsAsync(() - => _teamsClient.SendMessageToListOfUsersAsync(activity, null!, "tenant", _serviceUrl)); + => _teamsClient.SendMessageToListOfUsersAsync(activity, null!, "tenant", _serviceUrl, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } [Fact] @@ -496,14 +528,14 @@ public async Task SendMessageToListOfUsers_ThrowsOnEmptyMembers() { var activity = new CoreActivity { Type = ActivityType.Message }; await Assert.ThrowsAsync(() - => _teamsClient.SendMessageToListOfUsersAsync(activity, [], "tenant", _serviceUrl)); + => _teamsClient.SendMessageToListOfUsersAsync(activity, [], "tenant", _serviceUrl, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } [Fact] public async Task SendMessageToAllUsersInTenant_ThrowsOnNullActivity() { await Assert.ThrowsAsync(() - => _teamsClient.SendMessageToAllUsersInTenantAsync(null!, "tenant", _serviceUrl)); + => _teamsClient.SendMessageToAllUsersInTenantAsync(null!, "tenant", _serviceUrl, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } [Fact] @@ -511,14 +543,14 @@ public async Task SendMessageToAllUsersInTenant_ThrowsOnNullTenantId() { var activity = new CoreActivity { Type = ActivityType.Message }; await Assert.ThrowsAsync(() - => _teamsClient.SendMessageToAllUsersInTenantAsync(activity, null!, _serviceUrl)); + => _teamsClient.SendMessageToAllUsersInTenantAsync(activity, null!, _serviceUrl, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } [Fact] public async Task SendMessageToAllUsersInTeam_ThrowsOnNullActivity() { await Assert.ThrowsAsync(() - => _teamsClient.SendMessageToAllUsersInTeamAsync(null!, "team", "tenant", _serviceUrl)); + => _teamsClient.SendMessageToAllUsersInTeamAsync(null!, "team", "tenant", _serviceUrl, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } [Fact] @@ -526,7 +558,7 @@ public async Task SendMessageToAllUsersInTeam_ThrowsOnNullTeamId() { var activity = new CoreActivity { Type = ActivityType.Message }; await Assert.ThrowsAsync(() - => _teamsClient.SendMessageToAllUsersInTeamAsync(activity, null!, "tenant", _serviceUrl)); + => _teamsClient.SendMessageToAllUsersInTeamAsync(activity, null!, "tenant", _serviceUrl, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } [Fact] @@ -534,28 +566,28 @@ public async Task SendMessageToListOfChannels_ThrowsOnEmptyChannels() { var activity = new CoreActivity { Type = ActivityType.Message }; await Assert.ThrowsAsync(() - => _teamsClient.SendMessageToListOfChannelsAsync(activity, [], "tenant", _serviceUrl)); + => _teamsClient.SendMessageToListOfChannelsAsync(activity, [], "tenant", _serviceUrl, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } [Fact] public async Task GetOperationState_ThrowsOnNullOperationId() { await Assert.ThrowsAsync(() - => _teamsClient.GetOperationStateAsync(null!, _serviceUrl)); + => _teamsClient.GetOperationStateAsync(null!, _serviceUrl, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } [Fact] public async Task GetPagedFailedEntries_ThrowsOnNullOperationId() { await Assert.ThrowsAsync(() - => _teamsClient.GetPagedFailedEntriesAsync(null!, _serviceUrl)); + => _teamsClient.GetPagedFailedEntriesAsync(null!, _serviceUrl, null, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } [Fact] public async Task CancelOperation_ThrowsOnNullOperationId() { await Assert.ThrowsAsync(() - => _teamsClient.CancelOperationAsync(null!, _serviceUrl)); + => _teamsClient.CancelOperationAsync(null!, _serviceUrl, AgenticIdentitiyFromEnv.GetAgenticIdentity())); } #endregion diff --git a/core/test/Microsoft.Teams.Bot.Core.Tests/readme.md b/core/test/Microsoft.Teams.Bot.Core.Tests/readme.md index 125a5289..4fb52089 100644 --- a/core/test/Microsoft.Teams.Bot.Core.Tests/readme.md +++ b/core/test/Microsoft.Teams.Bot.Core.Tests/readme.md @@ -8,6 +8,9 @@ To run these tests we need to configure the environment variables using a `.runs + 0d5eb8a3-1642-4e63-9ccc-a89aa461716c + 3fc62d4f-b04e-4c71-878b-02a2fa395fe2 + https://botapi.skype.com/.default a:17vxw6pGQOb3Zfh8acXT8m_PqHycYpaFgzu2mFMUfkT-h0UskMctq5ZPPc7FIQxn2bx7rBSm5yE_HeUXsCcKZBrv77RgorB3_1_pAdvMhi39ClxQgawzyQ9GBFkdiwOxT https://login.microsoftonline.com/ @@ -18,4 +21,4 @@ To run these tests we need to configure the environment variables using a `.runs -``` \ No newline at end of file +```