Permalink
Browse files

- Moved the feature IgnoreMisssingConfiguration to Advanced.

- Removed IgnoreMissingConfiguration property from ISecurityConfiguration and SecurityConfiguration.
  • Loading branch information...
1 parent 13b66e3 commit 2b969a64a9c05aed05bc51f337fbbbc7da526e8d Kristoffer Ahl committed Jun 16, 2012
@@ -23,6 +23,12 @@ public void SetUp()
}
[Test]
+ public void Should_not_ignore_missing_configurations()
+ {
+ Assert.That(_advancedConfiguration.ShouldIgnoreMissingConfiguration, Is.False);
+ }
+
+ [Test]
public void Should_have_default_policy_cache_lifecycle_set_to_DoNotCache()
{
Assert.That(_advancedConfiguration.DefaultResultsCacheLifecycle, Is.EqualTo(Cache.DoNotCache));
@@ -45,6 +51,24 @@ public void Should_have_conventions_for_default_PolicyViolationHandler_applied()
[TestFixture]
[Category("AdvancedConfigurationSpec")]
+ public class When_ignoring_missing_configuration
+ {
+ [Test]
+ public void Should_ignore_missing_configurations()
+ {
+ // Arrange
+ var advancedConfiguration = new AdvancedConfiguration();
+
+ // Act
+ advancedConfiguration.IgnoreMissingConfiguration();
+
+ // Assert
+ Assert.That(advancedConfiguration.ShouldIgnoreMissingConfiguration, Is.True);
+ }
+ }
+
+ [TestFixture]
+ [Category("AdvancedConfigurationSpec")]
public class When_setting_the_default_policy_results_cache_lifecycle
{
[Test]
@@ -28,16 +28,6 @@ public void Should_not_contain_any_policycontainers()
var containers = _securityConfiguration.PolicyContainers.Count();
Assert.That(containers, Is.EqualTo(0));
}
-
- [Test]
- public void Should_not_ignore_missing_configurations()
- {
- // Act
- Because();
-
- // Assert
- Assert.That(_securityConfiguration.IgnoreMissingConfiguration, Is.False);
- }
[Test]
public void Should_not_have_ServiceLocator()
@@ -77,28 +67,6 @@ public void Should_throw()
[TestFixture]
[Category("SecurityConfigurationSpec")]
- public class When_calling_configure_with_ignore_missing_configuration
- {
- private static SecurityConfiguration _securityConfiguration;
-
- private static void Because()
- {
- _securityConfiguration = new SecurityConfiguration(policy => policy.IgnoreMissingConfiguration());
- }
-
- [Test]
- public void Should_ignore_missing_configurations()
- {
- // Act
- Because();
-
- // Assert
- Assert.That(_securityConfiguration.IgnoreMissingConfiguration, Is.True);
- }
- }
-
- [TestFixture]
- [Category("SecurityConfigurationSpec")]
public class When_I_check_what_I_have
{
[Test]
@@ -111,7 +79,7 @@ public void Should_return_the_current_configuration()
var securityConfiguration = new SecurityConfiguration(configuration =>
{
configuration.GetAuthenticationStatusFrom(StaticHelper.IsAuthenticatedReturnsFalse);
- configuration.IgnoreMissingConfiguration();
+ configuration.Advanced.IgnoreMissingConfiguration();
configuration.For<BlogController>(x => x.DeletePost(0)).DenyAnonymousAccess().RequireRole(UserRole.Owner, UserRole.Publisher);
configuration.For<BlogController>(x => x.Index()).DenyAnonymousAccess();
});
@@ -250,11 +250,11 @@ public void Should_throw_ConfigurationErrorsException_when_IgnoreMissingConfigur
public void Should_not_throw_ConfigurationErrorsException_when_IgnoreMissingConfigurations_is_true()
{
// Arrange
- SecurityConfigurator.Configure(policy =>
+ SecurityConfigurator.Configure(configuration =>
{
- policy.GetAuthenticationStatusFrom(StaticHelper.IsAuthenticatedReturnsTrue);
- policy.IgnoreMissingConfiguration();
- policy.For<BlogController>(x => x.Index()).DenyAnonymousAccess();
+ configuration.GetAuthenticationStatusFrom(StaticHelper.IsAuthenticatedReturnsTrue);
+ configuration.Advanced.IgnoreMissingConfiguration();
+ configuration.For<BlogController>(x => x.Index()).DenyAnonymousAccess();
});
var securityHandler = new SecurityHandler();
@@ -10,7 +10,7 @@ public static ISecurityConfiguration CreateSecurityConfiguration()
SecurityConfigurator.Configure(configuration =>
{
configuration.GetAuthenticationStatusFrom(() => false);
- configuration.IgnoreMissingConfiguration();
+ configuration.Advanced.IgnoreMissingConfiguration();
configuration.For<SampleController>(x => x.Index()).DenyAuthenticatedAccess();
configuration.For<SampleController>(x => x.List()).DenyAnonymousAccess();
@@ -31,7 +31,7 @@ public static ISecurityConfiguration CreateEmptySecurityConfiguration()
SecurityConfigurator.Configure(configuration =>
{
configuration.GetAuthenticationStatusFrom(() => false);
- configuration.IgnoreMissingConfiguration();
+ configuration.Advanced.IgnoreMissingConfiguration();
});
return SecurityConfiguration.Current;
@@ -42,7 +42,7 @@ public static ISecurityConfiguration CreateSecurityConfigurationWithTwoExpectati
SecurityConfigurator.Configure(configuration =>
{
configuration.GetAuthenticationStatusFrom(() => false);
- configuration.IgnoreMissingConfiguration();
+ configuration.Advanced.IgnoreMissingConfiguration();
configuration.For<SampleController>(x => x.Index());
configuration.For<SampleController>(x => x.List());
@@ -16,22 +16,29 @@ internal AdvancedConfiguration()
};
SetDefaultResultsCacheLifecycle(Cache.DoNotCache);
+ ShouldIgnoreMissingConfiguration = false;
}
public Conventions Conventions { get; private set; }
public Cache DefaultResultsCacheLifecycle { get; private set; }
public Action<ISecurityContext> SecurityContextModifyer { get; private set; }
+ public bool ShouldIgnoreMissingConfiguration { get; private set; }
- public void SetDefaultResultsCacheLifecycle(Cache lifecycle)
+ public void IgnoreMissingConfiguration()
{
- DefaultResultsCacheLifecycle = lifecycle;
+ ShouldIgnoreMissingConfiguration = true;
}
public void ModifySecurityContext(Action<ISecurityContext> modifyer)
{
SecurityContextModifyer = modifyer;
}
+ public void SetDefaultResultsCacheLifecycle(Cache lifecycle)
+ {
+ DefaultResultsCacheLifecycle = lifecycle;
+ }
+
public void Violations(Action<ViolationConfiguration> violationConfiguration)
{
if (violationConfiguration == null) throw new ArgumentNullException("violationConfiguration");
@@ -9,5 +9,6 @@ public interface IAdvancedConfiguration
Conventions Conventions { get; }
Cache DefaultResultsCacheLifecycle { get; }
Action<ISecurityContext> SecurityContextModifyer { get; }
+ bool ShouldIgnoreMissingConfiguration { get; }
}
}
@@ -19,7 +19,6 @@ public class ConfigurationExpression
internal Func<bool> IsAuthenticated { get; private set; }
internal Func<IEnumerable<object>> Roles { get; private set; }
internal ISecurityServiceLocator ExternalServiceLocator { get; private set; }
- internal bool ShouldIgnoreMissingConfiguration { get; private set; }
private IPolicyAppender PolicyAppender { get; set; }
@@ -140,11 +139,6 @@ public void GetRolesFrom(Func<IEnumerable<object>> rolesFunction)
Roles = rolesFunction;
}
- public void IgnoreMissingConfiguration()
- {
- ShouldIgnoreMissingConfiguration = true;
- }
-
public void SetPolicyAppender(IPolicyAppender policyAppender)
{
if (policyAppender == null)
@@ -9,7 +9,7 @@ public string WhatDoIHave(ISecurityConfiguration configuration)
{
var builder = new StringBuilder();
- builder.AppendFormat("Ignore missing configuration: {0}", configuration.IgnoreMissingConfiguration);
+ builder.AppendFormat("Ignore missing configuration: {0}", configuration.Advanced.ShouldIgnoreMissingConfiguration);
builder.AppendLine().AppendLine().AppendLine("------------------------------------------------------------------------------------").AppendLine();
@@ -8,7 +8,6 @@ public interface ISecurityConfiguration
IAdvancedConfiguration Advanced { get; }
IEnumerable<IPolicyContainer> PolicyContainers { get; }
ISecurityServiceLocator ExternalServiceLocator { get; }
- bool IgnoreMissingConfiguration { get; }
string WhatDoIHave();
}
}
@@ -18,7 +18,6 @@ public SecurityConfiguration(Action<ConfigurationExpression> configurationExpres
Advanced = Expression.Advanced;
ExternalServiceLocator = Expression.ExternalServiceLocator;
- IgnoreMissingConfiguration = Expression.ShouldIgnoreMissingConfiguration;
PolicyContainers = Expression.PolicyContainers;
}
@@ -27,8 +26,6 @@ public SecurityConfiguration(Action<ConfigurationExpression> configurationExpres
public IEnumerable<IPolicyContainer> PolicyContainers { get; private set; }
public ISecurityServiceLocator ExternalServiceLocator { get; private set; }
- public bool IgnoreMissingConfiguration { get; private set; }
-
public string WhatDoIHave()
{
return ServiceLocation.ServiceLocator.Current.Resolve<IWhatDoIHaveBuilder>().WhatDoIHave(this);
@@ -32,7 +32,7 @@ public ActionResult HandleSecurityFor(string controllerName, string actionName,
return null;
}
- if (configuration.IgnoreMissingConfiguration)
+ if (configuration.Advanced.ShouldIgnoreMissingConfiguration)
return null;
throw ExceptionFactory.CreateConfigurationErrorsException("Security has not been configured for controller {0}, action {1}".FormatWith(controllerName, actionName));

0 comments on commit 2b969a6

Please sign in to comment.