mirror of
https://github.com/DuendeSoftware/products
synced 2026-05-24 09:28:24 +00:00
Migrate IdentityServer.UnitTests and IntegrationTests to xUnit v3
- Add [assembly: CaptureConsole] to both test projects - Replace ITestOutputHelper constructor injection with TestContext.Current pattern - Remove Xunit.Abstractions namespace usage - Remove xunit.runner.json reference from IntegrationTests csproj - Fix TheoryData collection expression syntax for xUnit v3 compatibility - Fix TheoryData.ToList to use Select(row => row.Data) pattern - Fix target-typed new ambiguity in TheoryData.Add calls - Fix TestTimeoutException to use ForTimedOutTest factory method
This commit is contained in:
parent
88428d4afc
commit
f728e95a6a
8 changed files with 19 additions and 14 deletions
|
|
@ -0,0 +1,4 @@
|
|||
// Copyright (c) Duende Software. All rights reserved.
|
||||
// See LICENSE in the project root for license information.
|
||||
|
||||
[assembly: CaptureConsole]
|
||||
|
|
@ -50,5 +50,5 @@ public class IntegrationTest<TClass, TDbContext, TStoreOption> : IClassFixture<D
|
|||
}
|
||||
}
|
||||
|
||||
protected IntegrationTest(DatabaseProviderFixture<TDbContext> fixture) => fixture.Options = TestDatabaseProviders.ToList<DbContextOptions<TDbContext>>();
|
||||
protected IntegrationTest(DatabaseProviderFixture<TDbContext> fixture) => fixture.Options = TestDatabaseProviders.Select(row => row.Data).ToList();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ public class ClientStoreTests : IntegrationTest<ClientStoreTests, ConfigurationD
|
|||
}
|
||||
else
|
||||
{
|
||||
throw new TestTimeoutException(timeout);
|
||||
throw TestTimeoutException.ForTimedOutTest(timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -406,8 +406,8 @@ public class DynamicProvidersTests
|
|||
{
|
||||
public DynamicProviderConfigurationData()
|
||||
{
|
||||
Add(new("Default PathPrefix", _ => { }));
|
||||
Add(new("PathPrefix Callback",
|
||||
Add(new DynamicProviderTestScenario("Default PathPrefix", _ => { }));
|
||||
Add(new DynamicProviderTestScenario("PathPrefix Callback",
|
||||
options => options.DynamicProviders.PathMatchingCallback = ctx =>
|
||||
{
|
||||
if (ctx.Request.Path.StartsWithSegments("/federation/idp1", StringComparison.InvariantCulture))
|
||||
|
|
|
|||
|
|
@ -27,9 +27,6 @@
|
|||
<None Update="identityserver_testing.pfx">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="xunit.runner.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
// Copyright (c) Duende Software. All rights reserved.
|
||||
// See LICENSE in the project root for license information.
|
||||
|
||||
[assembly: CaptureConsole]
|
||||
|
|
@ -6,13 +6,13 @@ using System.Security.Claims;
|
|||
using Duende.IdentityServer;
|
||||
using Duende.IdentityServer.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Xunit.Abstractions;
|
||||
using static Duende.License;
|
||||
|
||||
namespace UnitTests.Licensing;
|
||||
|
||||
public class IdentityServerLicenseValidatorTests(ITestOutputHelper output)
|
||||
public class IdentityServerLicenseValidatorTests
|
||||
{
|
||||
private readonly ITestOutputHelper _output = TestContext.Current.TestOutputHelper!;
|
||||
private const string Category = "License validator tests";
|
||||
|
||||
[Fact]
|
||||
|
|
@ -31,7 +31,7 @@ public class IdentityServerLicenseValidatorTests(ITestOutputHelper output)
|
|||
licenseValidator.ValidateIssuer("c2");
|
||||
|
||||
var logMessages = string.Join(Environment.NewLine, mockLogger.LogMessages);
|
||||
output.WriteLine(logMessages);
|
||||
_output.WriteLine(logMessages);
|
||||
mockLogger.LogMessages.ShouldContain("Your license for IdentityServer includes 1 issuers but you have processed requests for 2 issuers. This indicates that requests for each issuer are being sent to this instance of IdentityServer, which may be due to a network infrastructure configuration issue. If you intend to use multiple issuers, please contact contact@duendesoftware.com at _test or start a conversation with us at https://duende.link/l/contact to upgrade your license as soon as possible. In a future version, this limit will be enforced after a threshold is exceeded. The issuers used were c1, c2.");
|
||||
}
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ public class IdentityServerLicenseValidatorTests(ITestOutputHelper output)
|
|||
licenseValidator.ValidateClient("c6");
|
||||
|
||||
var logMessages = string.Join(Environment.NewLine, mockLogger.LogMessages);
|
||||
output.WriteLine(logMessages);
|
||||
_output.WriteLine(logMessages);
|
||||
mockLogger.LogMessages.ShouldContain("Your license for IdentityServer includes 5 clients but you have processed requests for 6 clients. Please contact contact@duendesoftware.com at _test or start a conversation with us at https://duende.link/l/contact to upgrade your license as soon as possible. In a future version, this limit will be enforced after a threshold is exceeded. The clients used were: c1, c2, c3, c4, c5, c6.");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -514,13 +514,13 @@ public class ClientConfigurationValidation
|
|||
context.ErrorMessage.ShouldBe(expectedError);
|
||||
}
|
||||
|
||||
public static TheoryData<ICollection<string>> GrantTypesWithClientCredentialsTestData =>
|
||||
[
|
||||
public static TheoryData<ICollection<string>> GrantTypesWithClientCredentialsTestData => new()
|
||||
{
|
||||
GrantTypes.ImplicitAndClientCredentials,
|
||||
GrantTypes.CodeAndClientCredentials,
|
||||
GrantTypes.HybridAndClientCredentials,
|
||||
GrantTypes.ClientCredentials,
|
||||
GrantTypes.ResourceOwnerPasswordAndClientCredentials
|
||||
];
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue