### 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

@ -52,11 +52,17 @@ namespace VRCAuthProxy.Tests.Integration
.WithHeader("Content-Type", "application/json")
.WithBody(@"[{""id"":""usr_test1"",""displayName"":""TestUser1""},{""id"":""usr_test2"",""displayName"":""TestUser2""}]"));
// Create a client
var httpClient = new HttpClient();
// 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 baseUri = mockServerUrls.First();
// Call the users endpoint directly
var baseUri = mockServer.Urls.First();
var httpClient = new HttpClient(handler);
var response = await httpClient.GetAsync($"{baseUri}/api/1/users");
// Assert
@ -90,11 +96,17 @@ namespace VRCAuthProxy.Tests.Integration
.WithHeader("Content-Type", "application/json")
.WithBody(@"[{""id"":""wrld_test1"",""name"":""TestWorld1""},{""id"":""wrld_test2"",""name"":""TestWorld2""}]"));
// Create a client
var httpClient = new HttpClient();
// 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 baseUri = mockServerUrls.First();
// First authenticate
var baseUri = mockServer.Urls.First();
var httpClient = new HttpClient(handler);
await httpClient.GetAsync($"{baseUri}/api/1/auth/user");
// Then call the worlds endpoint