### Commit Summary

- **TestSetup.cs**
  - Updated `CreateTestConfig` method to initialize `Config` with required properties using object initializer syntax.

- **ProxyIntegrationTests.cs**
  - Added null checks for `mockServer.Urls` before accessing it to prevent potential null reference exceptions.
  - Improved error handling for mock server URL access.

- **VRChatAuthenticationTests.cs**
  - Added null checks for `mockServer.Urls` before accessing it to prevent potential null reference exceptions.
  - Enhanced the mock server setup to include null checks for request body content.

- **Config.cs**
  - Added the `required` modifier to non-nullable properties in `ConfigAccount` and `iConfig` classes.
  - Updated the `Load` method to initialize the `Config` instance with required properties using object initializer syntax.

- **Program.cs**
  - Added a null check for `result.CloseStatus` in WebSocket handling to prevent potential null reference exceptions.
This commit is contained in:
MiscFrizzy 2025-04-07 07:30:34 -04:00
parent 861bedcf43
commit eb4349031b
5 changed files with 59 additions and 28 deletions

View file

@ -38,9 +38,14 @@ namespace VRCAuthProxy.Tests.Integration
// Create a client with the test setup
var handler = new HttpClientHandler { UseCookies = true };
var mockServerUrls = mockServer.Urls;
if (mockServerUrls == null || !mockServerUrls.Any())
{
throw new InvalidOperationException("Mock server URLs not available");
}
var httpClient = new HttpClient(handler)
{
BaseAddress = new Uri(mockServer.Urls.First())
BaseAddress = new Uri(mockServerUrls.First())
};
// Act
@ -82,7 +87,7 @@ namespace VRCAuthProxy.Tests.Integration
mockServer.Given(Request.Create()
.WithPath("/api/1/auth/twofactorauth/totp/verify")
.UsingPost()
.WithBody(x => x.Contains("code")))
.WithBody(x => x != null && x.Contains("code")))
.RespondWith(Response.Create()
.WithStatusCode(200)
.WithHeader("Content-Type", "application/json")
@ -101,9 +106,14 @@ namespace VRCAuthProxy.Tests.Integration
// Create a client with the test setup
var handler = new HttpClientHandler { UseCookies = true };
var mockServerUrls = mockServer.Urls;
if (mockServerUrls == null || !mockServerUrls.Any())
{
throw new InvalidOperationException("Mock server URLs not available");
}
var httpClient = new HttpClient(handler)
{
BaseAddress = new Uri(mockServer.Urls.First())
BaseAddress = new Uri(mockServerUrls.First())
};
// Act - First authenticate which will indicate TOTP is required