-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUserEndpointsTests.cs
More file actions
30 lines (24 loc) · 949 Bytes
/
UserEndpointsTests.cs
File metadata and controls
30 lines (24 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using Microsoft.AspNetCore.Mvc.Testing;
using System.Net.Http.Json;
namespace BffMicrosoftEntraID.Server.IntegrationTests;
public class UserEndpointsTests : IClassFixture<WebApplicationFactory<Program>>
{
private readonly WebApplicationFactory<Program> _factory;
public UserEndpointsTests(WebApplicationFactory<Program> factory)
{
_factory = factory;
}
[Fact]
public async Task Get_AsUnauthenticatedUser_ReturnsAnonymousUserInfo()
{
// Arrange
var client = _factory.CreateClient();
// Act
var response = await client.GetAsync("/api/user", TestContext.Current.CancellationToken);
// Assert
response.EnsureSuccessStatusCode();
var userInfo = await response.Content.ReadFromJsonAsync<Models.UserInfo>(cancellationToken: TestContext.Current.CancellationToken);
Assert.NotNull(userInfo);
Assert.False(userInfo!.IsAuthenticated);
}
}