protected PackageHasSignatureValidator CreateTarget(bool requireRepositorySignature = true) { var endpoint = ValidatorTestUtility.CreateCatalogEndpoint(); var config = ValidatorTestUtility.CreateValidatorConfig(requireRepositorySignature: requireRepositorySignature); return(new PackageHasSignatureValidator(endpoint, config, _logger.Object)); }
public async Task PassesIfEqual( RegistrationLeafValidator validator, PackageRegistrationIndexMetadata v2, PackageRegistrationIndexMetadata v3) { await validator.CompareLeafAsync(ValidatorTestUtility.GetFakeValidationContext(), v2, v3); }
protected PackageIsRepositorySignedValidator CreateTarget(bool requireRepositorySignature = true) { var endpoint = ValidatorTestUtility.CreateFlatContainerEndpoint(); var logger = Mock.Of <ILogger <PackageIsRepositorySignedValidator> >(); var config = ValidatorTestUtility.CreateValidatorConfig(requireRepositorySignature: requireRepositorySignature); return(new PackageIsRepositorySignedValidator(endpoint, config, logger)); }
protected SearchHasVersionValidator CreateTarget() { var endpoint = ValidatorTestUtility.CreateSearchEndpoint(); var logger = Mock.Of <ILogger <SearchHasVersionValidator> >(); var config = ValidatorTestUtility.CreateValidatorConfig(); return(new SearchHasVersionValidator(endpoint, config, logger)); }
public async Task FailsIfUnequal( RegistrationLeafValidator validator, PackageRegistrationIndexMetadata v2, PackageRegistrationIndexMetadata v3) { await Assert.ThrowsAnyAsync <MetadataInconsistencyException>( () => validator.CompareLeafAsync(ValidatorTestUtility.GetFakeValidationContext(), v2, v3)); }
protected override RegistrationDeprecationValidator CreateValidator( ILogger <RegistrationDeprecationValidator> logger) { var endpoint = ValidatorTestUtility.CreateRegistrationEndpoint(); var config = new ValidatorConfiguration("https://nuget.test/packages", requireRepositorySignature: false); return(new RegistrationDeprecationValidator(endpoint, config, logger)); }
private static CatalogAggregateValidator CreateValidator( ValidationContext context, bool requirePackageSignature) { var config = ValidatorTestUtility.CreateValidatorConfig(requirePackageSignature: requirePackageSignature); var loggerFactory = CreateLoggerFactory(); var validatorFactory = new ValidatorFactory(config, loggerFactory); return(new CatalogAggregateValidator(validatorFactory, config)); }
private static IEnumerable <object[]> ValidatorTestData <T>(Func <IRegistrationLeafValidatorTestData, IEnumerable <Tuple <T, T> > > getPairs) { foreach (var testData in ValidatorTestUtility.GetImplementations <IRegistrationLeafValidatorTestData>()) { var validator = testData.CreateValidator(); foreach (var pair in getPairs(testData)) { yield return(new object[] { validator, pair.Item1, pair.Item2 }); } } }
public FactsBase() { _mockServer = new MockServerHttpClientHandler(); // Mock a catalog entry and leaf for the package we are validating. _catalogEntries = new[] { new CatalogIndexEntry( new Uri("https://nuget.test/catalog/leaf.json"), CatalogConstants.NuGetPackageDetails, Guid.NewGuid().ToString(), DateTime.UtcNow, PackageIdentity) }; ValidatorTestUtility.AddCatalogLeafToMockServer(_mockServer, new Uri("/catalog/leaf.json", UriKind.Relative), new CatalogLeaf { Created = PackageCreationTime, LastEdited = PackageCreationTime }); }
public Constructor() { _endpoint = ValidatorTestUtility.CreateFlatContainerEndpoint(); _configuration = new ValidatorConfiguration(packageBaseAddress: "a", requireRepositorySignature: true); }
protected void AddCatalogLeaf(string path, CatalogLeaf leaf) { ValidatorTestUtility.AddCatalogLeafToMockServer(_mockServer, new Uri(path, UriKind.Relative), leaf); }
public async Task SpecialCasesReturnAsExpected( RegistrationLeafValidator validator, PackageRegistrationIndexMetadata v2, PackageRegistrationIndexMetadata v3, bool shouldPass) { var compareTask = Task.Run(async() => await validator.CompareLeafAsync(ValidatorTestUtility.GetFakeValidationContext(), v2, v3)); if (shouldPass) { await compareTask; } else { await Assert.ThrowsAnyAsync <MetadataInconsistencyException>( () => compareTask); } }
public async Task Skips( RegistrationLeafValidator validator, PackageRegistrationLeafMetadata v2, PackageRegistrationLeafMetadata v3) { Assert.Equal(ShouldRunTestResult.No, await validator.ShouldRunLeafAsync(ValidatorTestUtility.GetFakeValidationContext(), v2, v3)); }
public async Task Runs( RegistrationIndexValidator validator, PackageRegistrationIndexMetadata v2, PackageRegistrationIndexMetadata v3) { Assert.Equal(ShouldRunTestResult.Yes, await validator.ShouldRunIndexAsync(ValidatorTestUtility.GetFakeValidationContext(), v2, v3)); }