fix(cli): resolve CLI-002..007 — robust response rendering, URL/JSON arg validation, credential env-vars, doc refresh
This commit is contained in:
31
tests/ScadaLink.CLI.Tests/UrlValidationTests.cs
Normal file
31
tests/ScadaLink.CLI.Tests/UrlValidationTests.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using ScadaLink.CLI.Commands;
|
||||
|
||||
namespace ScadaLink.CLI.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Regression tests for CLI-004 — a malformed <c>--url</c> previously reached
|
||||
/// <c>new Uri(...)</c> in the <see cref="ScadaLink.CLI.ManagementHttpClient"/> constructor
|
||||
/// and threw an unhandled <see cref="UriFormatException"/>.
|
||||
/// </summary>
|
||||
public class UrlValidationTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("http://localhost:9001")]
|
||||
[InlineData("https://central-host:5000/")]
|
||||
[InlineData("http://central")]
|
||||
public void IsValidManagementUrl_AcceptsAbsoluteHttpUrls(string url)
|
||||
{
|
||||
Assert.True(CommandHelpers.IsValidManagementUrl(url));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("localhost:9001")] // no scheme
|
||||
[InlineData("")] // empty
|
||||
[InlineData(" ")] // whitespace
|
||||
[InlineData("not a url")]
|
||||
[InlineData("ftp://central:21")] // non-http scheme
|
||||
public void IsValidManagementUrl_RejectsMalformedOrNonHttpUrls(string url)
|
||||
{
|
||||
Assert.False(CommandHelpers.IsValidManagementUrl(url));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user