public static void RegisterUrls(SecureUrlCollection secureUrls) { //Ignore defaults secureUrls.IgnoreUrl(@"(.*)\.css"); secureUrls.IgnoreUrl(@"(.*)\.js"); secureUrls.IgnoreUrl(@"(.*)\.png"); secureUrls.IgnoreUrl(@"(.*)\.jpg"); secureUrls.IgnoreUrl(@"(.*)\.gif"); // Add urls here secureUrls.AddRegex( @"(.*)account", RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.Singleline); //Secure Cart secureUrls.AddUrl("/cart"); //Custom rules SecurePagesConfiguration.RegisterCustomMatchRule( c => string.Equals( c.Request.Headers["X-Forwarded-Proto"], "https", StringComparison.InvariantCultureIgnoreCase)); #if DEBUG //For testing only SecurePagesConfiguration.IgnoreLocalRequests = false; SecurePagesConfiguration.HttpRootUrl = "http://localhost:63670/"; SecurePagesConfiguration.HttpsRootUrl = "https://localhost:44301/"; #endif }
public void IgnoreUrl_ShouldThorwArgumentException_WhenPatternIsNullOrEmpty() { // arrange var collection = new SecureUrlCollection(); //act and assert Assert.Throws<ArgumentException>(() => collection.IgnoreUrl(string.Empty)); Assert.Throws<ArgumentException>(() => collection.IgnoreUrl(null)); }
public void IgnoreUrl_ShouldAddNewIgnoreUrlTypeToCollection() { // arrange var collection = new SecureUrlCollection(); collection.IgnoreUrl(@"test"); // act var count = collection.IgnoreUrls.Count; //assert Assert.Equal(1, count); }