mirror of
https://github.com/bitwarden/server.git
synced 2024-12-01 13:43:23 +01:00
23 lines
757 B
C#
23 lines
757 B
C#
|
using System.Net;
|
|||
|
using Bit.Icons.Models;
|
|||
|
using Xunit;
|
|||
|
|
|||
|
namespace Bit.Icons.Test.Models;
|
|||
|
|
|||
|
public class IconUriTests
|
|||
|
{
|
|||
|
[Theory]
|
|||
|
[InlineData("https://icon.test", "1.1.1.1", true)]
|
|||
|
[InlineData("https://icon.test:4443", "1.1.1.1", false)] // Non standard port
|
|||
|
[InlineData("http://test", "1.1.1.1", false)] // top level domain
|
|||
|
[InlineData("https://icon.test", "127.0.0.1", false)] // IP is internal
|
|||
|
[InlineData("https://icon.test", "::1", false)] // IP is internal
|
|||
|
[InlineData("https://1.1.1.1", "::1", false)] // host is IP
|
|||
|
public void IsValid(string uri, string ip, bool expectedResult)
|
|||
|
{
|
|||
|
var result = new IconUri(new Uri(uri), IPAddress.Parse(ip)).IsValid;
|
|||
|
|
|||
|
Assert.Equal(expectedResult, result);
|
|||
|
}
|
|||
|
}
|