### 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:
parent
861bedcf43
commit
eb4349031b
5 changed files with 59 additions and 28 deletions
|
|
@ -4,21 +4,26 @@ namespace VRCAuthProxy;
|
|||
|
||||
public class ConfigAccount
|
||||
{
|
||||
public string username { get; set; }
|
||||
public string password { get; set; }
|
||||
public required string username { get; set; }
|
||||
public required string password { get; set; }
|
||||
public string? totpSecret { get; set; }
|
||||
}
|
||||
|
||||
public class iConfig
|
||||
{
|
||||
public List<ConfigAccount> accounts { get; set; }
|
||||
public required List<ConfigAccount> accounts { get; set; }
|
||||
}
|
||||
|
||||
// Load config from appsettings.json
|
||||
public class Config
|
||||
{
|
||||
private static Config? _instance;
|
||||
public List<ConfigAccount> Accounts { get; set; }
|
||||
public required List<ConfigAccount> Accounts { get; set; }
|
||||
|
||||
public Config()
|
||||
{
|
||||
Accounts = new List<ConfigAccount>();
|
||||
}
|
||||
|
||||
public static Config Instance
|
||||
{
|
||||
|
|
@ -31,8 +36,12 @@ public class Config
|
|||
|
||||
public static Config Load()
|
||||
{
|
||||
var config = new Config();
|
||||
var configPath = Path.Combine(AppContext.BaseDirectory, "appsettings.json");
|
||||
var config = new Config
|
||||
{
|
||||
Accounts = new List<ConfigAccount>()
|
||||
};
|
||||
|
||||
if (File.Exists(configPath))
|
||||
{
|
||||
var json = File.ReadAllText(configPath);
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ app.Use(async (context, next) =>
|
|||
var result = await source.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None);
|
||||
if (result.MessageType == WebSocketMessageType.Close)
|
||||
{
|
||||
await target.CloseAsync(result.CloseStatus.Value, result.CloseStatusDescription, CancellationToken.None);
|
||||
await target.CloseAsync(result.CloseStatus ?? WebSocketCloseStatus.NormalClosure, result.CloseStatusDescription, CancellationToken.None);
|
||||
break;
|
||||
}
|
||||
await target.SendAsync(new ArraySegment<byte>(buffer, 0, result.Count), result.MessageType, result.EndOfMessage, CancellationToken.None);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue