Skip to content

Commit

Permalink
(maint) Add unit tests for ssl capable validation
Browse files Browse the repository at this point in the history
  • Loading branch information
AdmiringWorm committed Feb 10, 2020
1 parent 80f3d8c commit 80a6bcb
Showing 1 changed file with 59 additions and 0 deletions.
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.
}
}

0 comments on commit 80a6bcb

Please sign in to comment.