32 lines
1.0 KiB
C#
32 lines
1.0 KiB
C#
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));
|
|
}
|
|
}
|