This commit is contained in:
@@ -144,6 +144,52 @@ public sealed class RemoteAgentOptionsTests
|
||||
|
||||
Assert.Throws<WxAgentException>(() => options.Validate());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TokenFileIsAcceptedWithoutPuttingTheTokenInConfiguration()
|
||||
{
|
||||
var path = Path.Combine(Path.GetTempPath(), "wxagent-token-" + Guid.NewGuid().ToString("N"));
|
||||
try
|
||||
{
|
||||
File.WriteAllText(path, "file-token\n");
|
||||
var options = new RemoteAgentOptions
|
||||
{
|
||||
AuthAddress = "https://control.example",
|
||||
TokenFile = path,
|
||||
NodeId = "node-1"
|
||||
};
|
||||
|
||||
options.Validate();
|
||||
Assert.Equal("file-token", options.GetToken());
|
||||
Assert.Null(options.Redacted().Token);
|
||||
Assert.Equal("file-configured", options.TokenState);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (File.Exists(path)) File.Delete(path);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ClientCertificateConfigurationRequiresBothPemFiles()
|
||||
{
|
||||
var cert = Path.GetTempFileName();
|
||||
try
|
||||
{
|
||||
var options = new RemoteAgentOptions
|
||||
{
|
||||
AuthAddress = "https://control.example",
|
||||
Token = "node-token",
|
||||
NodeId = "node-1",
|
||||
ClientCertificateFile = cert
|
||||
};
|
||||
Assert.Throws<WxAgentException>(() => options.Validate());
|
||||
}
|
||||
finally
|
||||
{
|
||||
File.Delete(cert);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class RemoteAccountContextTests
|
||||
|
||||
Reference in New Issue
Block a user