fix: resolve nullability compilation errors in test fixtures
- Make WebServerFixture properties nullable to match async initialization - Add null-coalescing assertions where properties are guaranteed non-null - Fix GetDiscoveryDocumentAsync delegate signature in Remoting to allow nullable parameters - Build now succeeds with 0 errors, 7/9 tests passing
This commit is contained in:
parent
87d62791b8
commit
47323b2d85
2 changed files with 25 additions and 23 deletions
|
|
@ -100,8 +100,8 @@ namespace yavscTests
|
||||||
|
|
||||||
private bool ValidateCertificate(
|
private bool ValidateCertificate(
|
||||||
HttpRequestMessage request,
|
HttpRequestMessage request,
|
||||||
X509Certificate2 certificate,
|
X509Certificate2? certificate,
|
||||||
X509Chain chain,
|
X509Chain? chain,
|
||||||
SslPolicyErrors errors)
|
SslPolicyErrors errors)
|
||||||
{
|
{
|
||||||
// Accept all certificates (bypass validation)
|
// Accept all certificates (bypass validation)
|
||||||
|
|
|
||||||
|
|
@ -24,24 +24,24 @@ namespace isnd.tests
|
||||||
public class WebServerFixture : IDisposable
|
public class WebServerFixture : IDisposable
|
||||||
{
|
{
|
||||||
public List<string> Addresses { get; private set; } = new List<string>();
|
public List<string> Addresses { get; private set; } = new List<string>();
|
||||||
public Microsoft.Extensions.Logging.ILogger Logger { get; internal set; }
|
public Microsoft.Extensions.Logging.ILogger? Logger { get; internal set; }
|
||||||
|
|
||||||
private SiteSettings siteSettings;
|
private SiteSettings? siteSettings;
|
||||||
|
|
||||||
public IConfiguration Configuration { get; private set; }
|
public IConfiguration? Configuration { get; private set; }
|
||||||
|
|
||||||
private WebApplication app;
|
private WebApplication? app;
|
||||||
public string TestClientId { get; private set; }
|
public string? TestClientId { get; private set; }
|
||||||
|
|
||||||
public IServiceProvider Services { get; private set; }
|
public IServiceProvider? Services { get; private set; }
|
||||||
public string TestingUserName { get; private set; }
|
public string? TestingUserName { get; private set; }
|
||||||
public string TestingUserPassword { get; private set; }
|
public string? TestingUserPassword { get; private set; }
|
||||||
|
|
||||||
public string ProtectedTestingApiKey { get; internal set; }
|
public string? ProtectedTestingApiKey { get; internal set; }
|
||||||
public ApplicationUser TestingUser { get; private set; }
|
public ApplicationUser? TestingUser { get; private set; }
|
||||||
public bool DbCreated { get; internal set; }
|
public bool DbCreated { get; internal set; }
|
||||||
public SiteSettings SiteSettings { get => siteSettings; set => siteSettings = value; }
|
public SiteSettings? SiteSettings { get => siteSettings; set => siteSettings = value; }
|
||||||
public string TestClientSecret { get; set; }
|
public string? TestClientSecret { get; set; }
|
||||||
|
|
||||||
public WebServerFixture()
|
public WebServerFixture()
|
||||||
{
|
{
|
||||||
|
|
@ -107,7 +107,7 @@ namespace isnd.tests
|
||||||
AddAuthorizedClient(TestClientId, TestClientSecret);
|
AddAuthorizedClient(TestClientId, TestClientSecret);
|
||||||
TestingUser = await db.Users.FirstOrDefaultAsync(u => u.UserName == TestingUserName);
|
TestingUser = await db.Users.FirstOrDefaultAsync(u => u.UserName == TestingUserName);
|
||||||
}
|
}
|
||||||
await app.ConfigurePipeline();
|
await app!.ConfigurePipeline();
|
||||||
app.UseSession();
|
app.UseSession();
|
||||||
await app.StartAsync();
|
await app.StartAsync();
|
||||||
|
|
||||||
|
|
@ -120,16 +120,18 @@ namespace isnd.tests
|
||||||
|
|
||||||
var addressFeatures = server.Features.Get<IServerAddressesFeature>();
|
var addressFeatures = server.Features.Get<IServerAddressesFeature>();
|
||||||
|
|
||||||
foreach (var address in addressFeatures.Addresses)
|
if (addressFeatures?.Addresses != null)
|
||||||
{
|
{
|
||||||
Addresses.Add(address);
|
foreach (var address in addressFeatures.Addresses)
|
||||||
|
{
|
||||||
|
Addresses.Add(address);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddAuthorizedClient(string testClientId, string testClientSecret)
|
private void AddAuthorizedClient(string testClientId, string testClientSecret)
|
||||||
{
|
{
|
||||||
using (IServiceScope scope = app.Services.CreateScope())
|
using (IServiceScope scope = app!.Services.CreateScope())
|
||||||
{
|
{
|
||||||
var db = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
var db = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
|
||||||
Client testingClient = new Client
|
Client testingClient = new Client
|
||||||
|
|
@ -137,7 +139,7 @@ namespace isnd.tests
|
||||||
ClientId = testClientId,
|
ClientId = testClientId,
|
||||||
AccessTokenLifetime = 3600000,
|
AccessTokenLifetime = 3600000,
|
||||||
AccessTokenType = 1,
|
AccessTokenType = 1,
|
||||||
BackChannelLogoutUri = SiteSettings.Audience,
|
BackChannelLogoutUri = SiteSettings!.Audience,
|
||||||
ClientName = "Testing client",
|
ClientName = "Testing client",
|
||||||
Enabled = true
|
Enabled = true
|
||||||
};
|
};
|
||||||
|
|
@ -153,7 +155,7 @@ namespace isnd.tests
|
||||||
var testOrigin = new ClientCorsOrigin
|
var testOrigin = new ClientCorsOrigin
|
||||||
{
|
{
|
||||||
ClientId = testingClient.Id,
|
ClientId = testingClient.Id,
|
||||||
Origin = SiteSettings.Audience
|
Origin = SiteSettings!.Audience
|
||||||
|
|
||||||
};
|
};
|
||||||
db.ClientCorsOrigins.Add(testOrigin);
|
db.ClientCorsOrigins.Add(testOrigin);
|
||||||
|
|
@ -185,7 +187,7 @@ namespace isnd.tests
|
||||||
db.ClientRedirectUris.Add(new ClientRedirectUri
|
db.ClientRedirectUris.Add(new ClientRedirectUri
|
||||||
{
|
{
|
||||||
ClientId = testingClient.Id,
|
ClientId = testingClient.Id,
|
||||||
RedirectUri = SiteSettings.Audience
|
RedirectUri = SiteSettings!.Audience
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -197,7 +199,7 @@ namespace isnd.tests
|
||||||
{
|
{
|
||||||
if (TestingUser == null)
|
if (TestingUser == null)
|
||||||
{
|
{
|
||||||
using IServiceScope scope = app.Services.CreateScope();
|
using IServiceScope scope = app!.Services.CreateScope();
|
||||||
|
|
||||||
var userManager =
|
var userManager =
|
||||||
scope.ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>();
|
scope.ServiceProvider.GetRequiredService<UserManager<ApplicationUser>>();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue