public void ReturnFailureForInValidUri() { UriValidator validator = new UriValidator(); ValidationResults validationResults = validator.Validate("foo"); Assert.IsFalse(validationResults.IsValid); }
public void ReturnSuccessForEmptyString() { UriValidator validator = new UriValidator(); ValidationResults validationResults = validator.Validate(null); Assert.IsTrue(validationResults.IsValid); }
public void ReturnSuccessForValidUri() { UriValidator validator = new UriValidator(); ValidationResults validationResults = validator.Validate("http://foo"); Assert.IsTrue(validationResults.IsValid); }
internal static void Validate(EpcisEvent evt) { evt.Epcs.ForEach(e => UriValidator.Validate(e.Id)); if (IsAddOrDeleteAggregation(evt) && !evt.Epcs.Any(x => x.Type == EpcType.ParentId)) // TCR-7 parentID is Populated for ADD or DELETE Actions in Aggregation Events { throw new EpcisException(ExceptionType.ValidationException, "TCR-7: parentID must be populated for ADD or DELETE aggregation event."); } }
public void RegexURIFail1() { bool not_expected = true; string uri = "https://www.confirmit.com/logincallback"; IEnumerable <string> rules = new List <string>(new[] { @"@https:\/\/[\w]+.confirmit\.com\/[\w]+\/logincallback" }); bool result = UriValidator.Validate(uri, rules); Assert.AreNotEqual(not_expected, result); }
public void WildcardURIFail2() { bool not_expected = true; string uri = "https://www.confirmit.com/www/something/logincallback"; IEnumerable <string> rules = new List <string>(new[] { "https://*.confirmit.com/*/logincallback" }); bool result = UriValidator.Validate(uri, rules); Assert.AreNotEqual(not_expected, result); }
public void AbsoluteRuleMethod_No2() { UriValidator validator = new UriValidator(); string[] googleRules = new[] { "https://www.google.com/webapp/logincallback" // absolute rule }; var result = validator.Validate(@"https://www.google.com/webapp/logincallback/", googleRules); Assert.AreEqual(result, false); }
public void WildcardRuleMethod_No3() { UriValidator validator = new UriValidator(); string[] confirmitRules = new[] { "https://*.confirmit.com/*/logincallback" // wildcard rule }; var result = validator.Validate(@"https://confirmit.com/logincallback", confirmitRules); Assert.AreEqual(result, false); }
public void RegexRuleMethod_No1() { UriValidator validator = new UriValidator(); string[] aspRules = new[] { @"@https://([\w-]+\.)*asp\.net\/logincallback" // literal regex rule }; var result = validator.Validate(@"https://www.asp.net/webapp/login", aspRules); Assert.AreEqual(result, false); }
public void RegexRuleMethod_No2() { UriValidator validator = new UriValidator(); string[] confirmitRules = new[] { @"@https://([\w-]+\.)*confirmit\.com\/logincallback" // literal regex rule }; var result = validator.Validate(@"https://confirmit.com/logincallback", confirmitRules); Assert.AreEqual(result, true); }
public void AbsoluteURIFail() { //setup bool not_expected = true; string uri = "https://app.test.com/auth/logincallback"; IEnumerable <string> rules = new List <string>(new[] { "https://app.confirmit.com/auth/logincallback" }); bool result = UriValidator.Validate(uri, rules); Assert.AreNotEqual(not_expected, result); }
public void WildcardRuleMethod_No1() { UriValidator validator = new UriValidator(); string[] githubRules = new[] { "https://*.github.com/*/logincallback", // wildcard rule "https://*.github.com/webapp/login" // wildcard rule }; var result = validator.Validate(@"https://www.github.com/webapp/login", githubRules); Assert.AreEqual(result, true); }
public void AbsoluteURISuccess() { //setup bool expected = true; string uri = "https://app.confirmit.com/auth/logincallback"; IEnumerable <string> rules = new List <string>(new[] { "https://app.confirmit.com/auth/logincallback" }); //action bool result = UriValidator.Validate(uri, rules); //assert Assert.AreEqual(expected, result); }
private static void EnsureDestinationIsValidURI(Subscription request) => UriValidator.Validate(request.Destination, true);