Beispiel #1
0
        public void ReturnSuccessForEmptyString()
        {
            UriValidator      validator         = new UriValidator();
            ValidationResults validationResults = validator.Validate(null);

            Assert.IsTrue(validationResults.IsValid);
        }
		public void ReturnFailureForInValidUri()
		{
			UriValidator validator = new UriValidator();
			ValidationResults validationResults = validator.Validate("foo");

			Assert.IsFalse(validationResults.IsValid);
		}
Beispiel #3
0
        public void ReturnFailureForInValidUri()
        {
            UriValidator      validator         = new UriValidator();
            ValidationResults validationResults = validator.Validate("foo");

            Assert.IsFalse(validationResults.IsValid);
        }
		public void ReturnSuccessForValidUri()
		{
			UriValidator validator = new UriValidator();
			ValidationResults validationResults = validator.Validate("http://foo");

			Assert.IsTrue(validationResults.IsValid);
		}
		public void ReturnSuccessForEmptyString()
		{
			UriValidator validator = new UriValidator();
			ValidationResults validationResults = validator.Validate(null);

			Assert.IsTrue(validationResults.IsValid);
		}
Beispiel #6
0
        /// <inheritdoc />
        public async Task <Stream> GetAsStreamAsync(string relativeUrl, IEnumerable <KeyValuePair <string, string> > parameters, CancellationToken cancellationToken)
        {
            var u = new UriBuilder(ServerURL);

            u.Path += relativeUrl;
            u.Query = GetQuery(parameters);

            HttpResponseMessage response;

            if (UriValidator.UriLength(u) > MaxUriLength)
            {
                u.Query  = null;
                response = await HttpClient.PostAsync(u.Uri, new FormUrlEncodedContent(parameters), cancellationToken);
            }
            else
            {
                response = await HttpClient.GetAsync(u.Uri, cancellationToken);
            }

            if (!response.IsSuccessStatusCode)
            {
                throw new SolrConnectionException(await response.Content.ReadAsStringAsync(), null, u.Uri.ToString());
            }

            return(await response.Content.ReadAsStreamAsync());
        }
Beispiel #7
0
        public void Configuration(IAppBuilder app)
        {
            // The OpenID Connect discovery endpoint is: https://localhost:44346/IdentityServer/.well-known/openid-configuration
            // Confirm the certificate has taken and is open to discovery: https://localhost:44346/IdentityServer/.well-known/jwks
            app.Map(
                "/IdentityServer",
                coreApp =>
            {
                var userService      = new UserService();
                var uriValidator     = new UriValidator();
                var requestValidator = new RequestValidator();

                coreApp.UseIdentityServer(
                    new IdentityServerOptions
                {
                    SiteName           = "Standalone Identity Server",
                    SigningCertificate = this.LoadCertificate(),
                    Factory            = new IdentityServerServiceFactory
                    {
                        ClientStore            = new Registration <IClientStore>(r => new InMemoryClientStore(Clients.Get())),
                        UserService            = new Registration <IUserService>(r => userService),
                        ScopeStore             = new Registration <IScopeStore>(r => new InMemoryScopeStore(Scopes.Get())),
                        RedirectUriValidator   = new Registration <IRedirectUriValidator>(r => uriValidator),
                        CustomRequestValidator = new Registration <ICustomRequestValidator>(r => requestValidator),
                        ViewService            = new Registration <IViewService, CustomViewService>()
                    },
                    RequireSsl = true
                });
            });
        }
Beispiel #8
0
        public void ReturnSuccessForValidUri()
        {
            UriValidator      validator         = new UriValidator();
            ValidationResults validationResults = validator.Validate("http://foo");

            Assert.IsTrue(validationResults.IsValid);
        }
Beispiel #9
0
 private static void ValidateUrl(string s)
 {
     try {
         UriValidator.ValidateHTTP(s);
     } catch (InvalidURLException e) {
         throw new FacilityException("", e);
     }
 }
Beispiel #10
0
        public void UriValidator_IsSupportedScheme_UppercaseValidator_CaseInsensitive()
        {
            var uppercaseValidator = new UriValidator(
                supportedSchemes: new HashSet <string>(new[] { "CASE" }),
                insecureSchemes: new HashSet <string>(new[] { "CASE" })
                );

            VerifyIsSupportedSchemeCaseSensitivity(uppercaseValidator);
        }
            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.");
                }
            }
Beispiel #12
0
        public void UriValidator_IsSupportedScheme_MixedValidator_CaseInsensitive()
        {
            var mixedcaseValidator = new UriValidator(
                supportedSchemes: new HashSet <string>(new[] { "cAsE" }),
                insecureSchemes: new HashSet <string>(new[] { "cAsE" })
                );

            VerifyIsSupportedSchemeCaseSensitivity(mixedcaseValidator);
        }
        private static SolrCore GetCore(SolrServerElement server)
        {
            var id           = server.Id ?? Guid.NewGuid().ToString();
            var documentType = GetCoreDocumentType(server);
            var coreUrl      = GetCoreUrl(server);

            UriValidator.ValidateHTTP(coreUrl);
            return(new SolrCore(id, documentType, coreUrl));
        }
Beispiel #14
0
        public void UriValidator_IsInsecureScheme_LowercaseValidator_CaseInsensitive()
        {
            var lowercaseValidator = new UriValidator(
                supportedSchemes: new HashSet <string>(new[] { "case" }),
                insecureSchemes: new HashSet <string>(new[] { "case" })
                );

            VerifyIsInsecureSchemeCaseSensitivity(lowercaseValidator);
        }
Beispiel #15
0
        public void UriLength_Equivalent()
        {
            var property =
                from uri in Property.ForAll(GenX.uri)
                let ub = new UriBuilder(uri)
                         let expected = ub.Uri.ToString().Length
                                        let actual = UriValidator.UriLength(ub)
                                                     select AssertEqual(expected : expected, actual : actual);

            Property.Check(property);
        }
Beispiel #16
0
        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);
        }
Beispiel #17
0
        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);
        }
Beispiel #18
0
        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);
        }
Beispiel #19
0
        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);
        }
        protected virtual string GetCoreUrl(ISolrServer server)
        {
            var url = server.Url;

            if (string.IsNullOrEmpty(url))
            {
                throw new StructureMapConfigurationException("Core url missing in SolrNet core configuration");
            }

            UriValidator.ValidateHTTP(url);
            return(url);
        }
        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 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 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);
        }
Beispiel #24
0
        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 void VerifyIsInsecureSchemeCaseSensitivity(UriValidator validator)
        {
            Uri lowercaseUri = CreateUri("case", "localhost");
            Uri uppercaseUri = CreateUri("CASE", "localhost");
            Uri mixedcaseUri = CreateUri("cAsE", "localhost");

            // Test
            bool lowercaseInsecure = validator.IsInsecureScheme(lowercaseUri);
            bool uppercaseInsecure = validator.IsInsecureScheme(uppercaseUri);
            bool mixedcaseInsecure = validator.IsInsecureScheme(mixedcaseUri);

            // Verify
            Assert.IsTrue(lowercaseInsecure, "Lowercase scheme should be insecure");
            Assert.IsTrue(uppercaseInsecure, "Uppercase scheme should be insecure");
            Assert.IsTrue(mixedcaseInsecure, "Mixed-case scheme should be insecure");
        }
Beispiel #27
0
        private void VerifyIsSupportedSchemeCaseSensitivity(UriValidator validator)
        {
            Uri lowercaseUri = CreateUri("case", "localhost");
            Uri uppercaseUri = CreateUri("CASE", "localhost");
            Uri mixedcaseUri = CreateUri("cAsE", "localhost");

            // Test
            bool lowercaseSupported = validator.IsSupportedScheme(lowercaseUri);
            bool uppercaseSupported = validator.IsSupportedScheme(uppercaseUri);
            bool mixedcaseSupported = validator.IsSupportedScheme(mixedcaseUri);

            // Assert
            lowercaseSupported.Should().BeTrue("Lowercase scheme should be supported");
            uppercaseSupported.Should().BeTrue("Uppercase scheme should be supported");
            mixedcaseSupported.Should().BeTrue("Mixed-case scheme should be supported");
        }
 public SolrMoreLikeThisHandlerStreamUrlQuery(string url)
 {
     this.url = new Uri(UriValidator.ValidateHTTP(url));
 }
Beispiel #29
0
 private static void EnsureDestinationIsValidURI(Subscription request) => UriValidator.Validate(request.Destination, true);
Beispiel #30
0
 internal /* testing purposes */ ConnectionInfoDialogViewModel(UriValidator uriValidator, BasicAuthenticationCredentialsValidator credentialsValidator)
 {
     this.uriValidator         = uriValidator;
     this.credentialsValidator = credentialsValidator;
 }
 internal /* testing purposes */ ConnectionInfoDialogViewModel(UriValidator uriValidator, BasicAuthenticationCredentialsValidator credentialsValidator)
 {
     this.uriValidator = uriValidator;
     this.credentialsValidator = credentialsValidator;
 }