Skip to content

Commit f8d1c14

Browse files
Update dependencies and refactor tests
- Updated `Microsoft.Identity.Client` package to version `4.71.1`. - Commented out tests in `AnonymousUserServiceTests.cs` that require extensive mocking of `GraphServiceClient`. - Minor reformatting changes in `Codebreaker.Identity.Tests.csproj`. - Changed `ClearUsers_ShouldRemoveAllUsers` method to async in `MockAnonymousUserServiceTests.cs`. - Updated `MailNickname` generation in `GraphAnonymousUserService.cs` to use range operator for clarity.
1 parent e4b3662 commit f8d1c14

5 files changed

Lines changed: 52 additions & 52 deletions

File tree

src/Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
<PackageVersion Include="Microsoft.FluentUI.AspNetCore.Components" Version="4.11.0" />
7777
<PackageVersion Include="Microsoft.FluentUI.AspNetCore.Components.Icons" Version="4.10.4" />
7878
<PackageVersion Include="Microsoft.Graph" Version="5.67.0" />
79-
<PackageVersion Include="Microsoft.Identity.Client" Version="4.66.2" />
79+
<PackageVersion Include="Microsoft.Identity.Client" Version="4.71.1" />
8080
<PackageVersion Include="Microsoft.Identity.Web" Version="3.5.0" />
8181
<PackageVersion Include="Microsoft.Identity.Web.DownstreamApi" Version="3.5.0" />
8282
<PackageVersion Include="Microsoft.Identity.Web.UI" Version="3.5.0" />

src/services/identity/Codebreaker.Identity.Tests/AnonymousUserServiceTests.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,26 @@ public AnonymousUserServiceTests()
3030
_mockLogger = new Mock<ILogger<GraphAnonymousUserService>>();
3131
}
3232

33-
[Fact(Skip = "Requires mocking of GraphServiceClient which is challenging")]
34-
public async Task CreateAnonUser_ShouldCreateAnonymousUser()
35-
{
36-
// This test would require extensive mocking of GraphServiceClient
37-
// In a real implementation, we would use a test double or wrapper for GraphServiceClient
38-
}
33+
//[Fact(Skip = "Requires mocking of GraphServiceClient which is challenging")]
34+
//public async Task CreateAnonUser_ShouldCreateAnonymousUser()
35+
//{
36+
// // This test would require extensive mocking of GraphServiceClient
37+
// // In a real implementation, we would use a test double or wrapper for GraphServiceClient
38+
//}
3939

40-
[Fact(Skip = "Requires mocking of GraphServiceClient which is challenging")]
41-
public async Task DeleteAnonUsers_ShouldDeleteStaleAnonymousUsers()
42-
{
43-
// This test would require extensive mocking of GraphServiceClient
44-
// In a real implementation, we would use a test double or wrapper for GraphServiceClient
45-
}
40+
//[Fact(Skip = "Requires mocking of GraphServiceClient which is challenging")]
41+
//public async Task DeleteAnonUsers_ShouldDeleteStaleAnonymousUsers()
42+
//{
43+
// // This test would require extensive mocking of GraphServiceClient
44+
// // In a real implementation, we would use a test double or wrapper for GraphServiceClient
45+
//}
4646

47-
[Fact(Skip = "Requires mocking of GraphServiceClient which is challenging")]
48-
public async Task PromoteAnonUser_ShouldPromoteAnonymousUser()
49-
{
50-
// This test would require extensive mocking of GraphServiceClient
51-
// In a real implementation, we would use a test double or wrapper for GraphServiceClient
52-
}
47+
//[Fact(Skip = "Requires mocking of GraphServiceClient which is challenging")]
48+
//public async Task PromoteAnonUser_ShouldPromoteAnonymousUser()
49+
//{
50+
// // This test would require extensive mocking of GraphServiceClient
51+
// // In a real implementation, we would use a test double or wrapper for GraphServiceClient
52+
//}
5353

5454
[Fact]
5555
public void ServiceInitialization_WithValidOptions_ShouldNotThrow()
Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
2-
3-
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
7-
8-
<IsPackable>false</IsPackable>
9-
<IsTestProject>true</IsTestProject>
10-
</PropertyGroup>
11-
12-
<ItemGroup>
13-
<PackageReference Include="Microsoft.NET.Test.Sdk" />
14-
<PackageReference Include="xunit" />
15-
<PackageReference Include="xunit.runner.visualstudio">
16-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
17-
<PrivateAssets>all</PrivateAssets>
18-
</PackageReference>
19-
<PackageReference Include="coverlet.collector">
20-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
21-
<PrivateAssets>all</PrivateAssets>
22-
</PackageReference>
23-
<PackageReference Include="Moq" />
24-
</ItemGroup>
25-
26-
<ItemGroup>
27-
<ProjectReference Include="..\Codebreaker.Identity\Codebreaker.Identity.csproj" />
28-
</ItemGroup>
29-
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
8+
<IsPackable>false</IsPackable>
9+
<IsTestProject>true</IsTestProject>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" />
14+
<PackageReference Include="xunit" />
15+
<PackageReference Include="xunit.runner.visualstudio">
16+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
17+
<PrivateAssets>all</PrivateAssets>
18+
</PackageReference>
19+
<PackageReference Include="coverlet.collector">
20+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
21+
<PrivateAssets>all</PrivateAssets>
22+
</PackageReference>
23+
<PackageReference Include="Moq" />
24+
</ItemGroup>
25+
26+
<ItemGroup>
27+
<ProjectReference Include="..\Codebreaker.Identity\Codebreaker.Identity.csproj" />
28+
</ItemGroup>
29+
3030
</Project>

src/services/identity/Codebreaker.Identity.Tests/MockAnonymousUserServiceTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ public void GetUsers_ShouldReturnReadOnlyListOfUsers()
153153
}
154154

155155
[Fact]
156-
public void ClearUsers_ShouldRemoveAllUsers()
156+
public async Task ClearUsers_ShouldRemoveAllUsers()
157157
{
158158
// Arrange
159159
var service = new MockAnonymousUserService(_mockLogger.Object);
160-
_ = service.CreateAnonUser("User1").Result;
161-
_ = service.CreateAnonUser("User2").Result;
160+
_ = await service.CreateAnonUser("User1");
161+
_ = await service.CreateAnonUser("User2");
162162
Assert.Equal(2, service.GetUsers().Count);
163163

164164
// Act

src/services/identity/Codebreaker.Identity/Services/GraphAnonymousUserService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public async Task<AnonymousUser> CreateAnonUser(string userName)
6060
{
6161
AccountEnabled = true,
6262
DisplayName = displayName,
63-
MailNickname = _options.UserNamePrefix + Guid.NewGuid().ToString("N").Substring(0, 8),
63+
MailNickname = _options.UserNamePrefix + Guid.NewGuid().ToString("N")[..8],
6464
UserPrincipalName = email,
6565
PasswordProfile = new PasswordProfile
6666
{

0 commit comments

Comments
 (0)