-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(maint) Add unit tests for ssl capable validation
- Loading branch information
1 parent
fafe517
commit c7589d9
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
Source/chocolatey-language-server.Tests/Validations/UrlSslCapableTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using Chocolatey.Language.Server.Models; | ||
using Chocolatey.Language.Server.Validations; | ||
using NUnit.Framework; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
|
||
namespace Chocolatey.Language.Server.Tests.Validations | ||
{ | ||
public class UrlSslCapableTests : ValidationBaseTests<UrlSslCapable> | ||
{ | ||
public static IEnumerable SupportedElements | ||
{ | ||
get => new[] | ||
{ | ||
"bugTrackerUrl", | ||
"docsUrl", | ||
"iconUrl", | ||
"licenseUrl", | ||
"mailingListUrl", | ||
"packageSourceUrl", | ||
"projectSourceUrl", | ||
"projectUrl", | ||
"wikiUrl" | ||
}; | ||
} | ||
|
||
public override string ExpectedId { get; } = "choco1002"; | ||
|
||
[Test] | ||
public void Should_FailValidationWhenSslCanBeUsedOnUrl([ValueSource(nameof(SupportedElements))] string xmlElement) | ||
{ | ||
var package = new Package | ||
{ | ||
AllElements = new Dictionary<string, MetaValue<string>> | ||
{ | ||
{ xmlElement, "http://chocolatey.org" } | ||
} | ||
}; | ||
|
||
ValidateDiagnosticResult(package, 1); | ||
} | ||
|
||
[Test] | ||
public void Should_NotFailValidationWhenSslIsUsedOnUrl([ValueSource(nameof(SupportedElements))] string xmlElement) | ||
{ | ||
var package = new Package | ||
{ | ||
AllElements = new Dictionary<string, MetaValue<string>> | ||
{ | ||
{ xmlElement, "https://chocolatey.org" } | ||
} | ||
}; | ||
|
||
ValidateDiagnosticResult(package, 0); | ||
} | ||
|
||
// TODO: Validation for when a url is not ssl capable should also be tested. | ||
} | ||
} |