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:50535/"; SecurePagesConfiguration.HttpsRootUrl = "https://localhost:44302/"; #endif }
public static void RegisterUrls(SecureUrlCollection secureUrls) { // 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)); //For testing only SecurePagesConfiguration.IgnoreLocalRequests = false; //For testing with a different domain // SecurePagesConfiguration.HttpValue = "http://localhost:63670/"; // SecurePagesConfiguration.HttpsValue = "https://localhost:44300/"; }
public void Add_WithStringAndMatchTypeParams_ShouldSetMatchTypeToCaseInsensitive_WhenNoMatchTypeIsProvided() { // Arrange var collection = new SecureUrlCollection(); // Act collection.AddUrl("mock/url"); SecureUrl secureUrl = collection.OfType<SecureUrl>().First(); // Assert Assert.Equal(SecureUrlMatchType.CaseInsensitive, secureUrl.MatchType); }
public void Add_WithStringAndMatchTypeParams_ShouldIncramentTotalByOne_WhenPassedValidUrlString() { // Arrange var collection = new SecureUrlCollection(); // Act collection.AddUrl("mock/url"); // Assert Assert.NotEmpty(collection); Assert.Equal(1, collection.Count()); }
public void Clear_ShouldEmptyAllEntriesFromCollection() { // arrange var collection = new SecureUrlCollection(); collection.AddUrl("mock/url"); collection.AddUrl("mock/url2"); // assert Assert.NotEmpty(collection); // act collection.Clear(); // assert Assert.Empty(collection); }
public void Add_WithStringAndMatchTypeParams_ShouldThrowArgumentException_WhenStringUrlIsNullOrEmpty() { // Arrange var collection = new SecureUrlCollection(); // Act // Assert Assert.Throws<ArgumentException>(() => collection.AddUrl(string.Empty, false)); Assert.Throws<ArgumentException>(() => collection.AddUrl(null, true)); }
public void Add_WithStringAndMatchTypeParams_ShouldSetMatchTypeToProvidedMatchType() { // Arrange var collection = new SecureUrlCollection(); // Act collection.AddUrl("mock/url", false); SecureUrl secureUrl = collection.First(); // Assert Assert.Equal(SecureUrlMatchType.CaseSensitive, secureUrl.MatchType); }