microsoft/teams.net
Publicmirrored from https://github.com/microsoft/teams.netAvailable
core/test/Microsoft.Teams.Bot.Core.UnitTests/UserTokenClientTests.cs
28lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using Microsoft.Extensions.Configuration; |
| 5 | |
| 6 | namespace Microsoft.Teams.Bot.Core.UnitTests; |
| 7 | |
| 8 | public class UserTokenClientTests |
| 9 | { |
| 10 | [Fact] |
| 11 | public void UserTokenClient_SetsUserAgentHeader() |
| 12 | { |
| 13 | // Arrange |
| 14 | HttpClient httpClient = new(); |
| 15 | IConfiguration configuration = new ConfigurationBuilder().Build(); |
| 16 | |
| 17 | // Act |
| 18 | UserTokenClient userTokenClient = new(httpClient, configuration, null!); |
| 19 | |
| 20 | // Assert |
| 21 | Assert.True(userTokenClient.DefaultCustomHeaders.ContainsKey("User-Agent")); |
| 22 | var userAgent = userTokenClient.DefaultCustomHeaders["User-Agent"]; |
| 23 | Assert.NotNull(userAgent); |
| 24 | Assert.Contains("Microsoft.Teams.Bot.Core", userAgent); |
| 25 | Assert.Contains("/", userAgent); // Should have format Name/Version |
| 26 | Assert.Matches(@"^[\w\.]+/[\w\.\-\+]+$", userAgent); // Validates RFC 7231 format |
| 27 | } |
| 28 | } |
| 29 | |