コード例 #1
0
        public void Should_return_the_current_configuration()
        {
            const string expectedOutput = @"Ignore missing configuration: True

------------------------------------------------------------------------------------

FluentSecurity.Specification.TestData.BlogController > DeletePost
	FluentSecurity.Policy.RequireAnyRolePolicy (Owner or Publisher)

FluentSecurity.Specification.TestData.BlogController > Index
	FluentSecurity.Policy.DenyAnonymousAccessPolicy

------------------------------------------------------------------------------------";

            var securityConfiguration = new SecurityConfiguration(configuration =>
            {
                configuration.GetAuthenticationStatusFrom(StaticHelper.IsAuthenticatedReturnsFalse);
                configuration.Advanced.IgnoreMissingConfiguration();
                configuration.For <BlogController>(x => x.DeletePost(0)).DenyAnonymousAccess().RequireAnyRole(UserRole.Owner, UserRole.Publisher);
                configuration.For <BlogController>(x => x.Index()).DenyAnonymousAccess();
            });

            SecurityConfigurator.SetConfiguration(securityConfiguration);

            // Act
            var whatIHave = securityConfiguration.WhatDoIHave();

            // Assert
            Assert.That(whatIHave, Is.EqualTo(expectedOutput));
        }
コード例 #2
0
        public void Should_return_the_current_configuration()
        {
            var baseDirectory  = AppDomain.CurrentDomain.BaseDirectory;
            var fullFilePath   = Path.Combine(baseDirectory, "TestData", "DiagnosticsOutputExample.txt");
            var expectedOutput = File.ReadAllText(fullFilePath);

            var securityConfiguration = new SecurityConfiguration(configuration =>
            {
                configuration.GetAuthenticationStatusFrom(StaticHelper.IsAuthenticatedReturnsFalse);
                configuration.IgnoreMissingConfiguration();
                configuration.For <BlogController>(x => x.DeletePost(0)).DenyAnonymousAccess().RequireRole(UserRole.Owner, UserRole.Publisher);
                configuration.For <BlogController>(x => x.Index()).DenyAnonymousAccess();
            });

            SecurityConfigurator.SetConfiguration(securityConfiguration);

            // Act
            var whatIHave = securityConfiguration.WhatDoIHave();

            // Assert
            Assert.That(whatIHave, Is.EqualTo(expectedOutput));
        }
コード例 #3
0
        public void Should_return_the_current_configuration()
        {
            var securityConfiguration = new SecurityConfiguration(configuration =>
            {
                configuration.GetAuthenticationStatusFrom(StaticHelper.IsAuthenticatedReturnsFalse);
                configuration.IgnoreMissingConfiguration();
                configuration.For<BlogController>(x => x.DeletePost(0)).DenyAnonymousAccess().RequireRole(UserRole.Owner, UserRole.Publisher);
                configuration.For<BlogController>(x => x.Index()).DenyAnonymousAccess();
            });

            // Act
            var whatIHave = securityConfiguration.WhatDoIHave();

            // Assert
            Assert.That(whatIHave.Replace("\r\n", "|").Replace("\t", "%"), Is.EqualTo("Ignore missing configuration: True||------------------------------------------------------------------------------------|BlogController > DeletePost|%FluentSecurity.Policy.RequireRolePolicy (Owner or Publisher)|BlogController > Index|%FluentSecurity.Policy.DenyAnonymousAccessPolicy|------------------------------------------------------------------------------------"));
        }
コード例 #4
0
        public void Should_return_the_current_configuration()
        {
            var baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
            var fullFilePath = Path.Combine(baseDirectory, "TestData", "DiagnosticsOutputExample.txt");
            var expectedOutput = File.ReadAllText(fullFilePath);

            var securityConfiguration = new SecurityConfiguration(configuration =>
            {
                configuration.GetAuthenticationStatusFrom(StaticHelper.IsAuthenticatedReturnsFalse);
                configuration.IgnoreMissingConfiguration();
                configuration.For<BlogController>(x => x.DeletePost(0)).DenyAnonymousAccess().RequireRole(UserRole.Owner, UserRole.Publisher);
                configuration.For<BlogController>(x => x.Index()).DenyAnonymousAccess();
            });

            SecurityConfigurator.SetConfiguration(securityConfiguration);

            // Act
            var whatIHave = securityConfiguration.WhatDoIHave();

            // Assert
            Assert.That(whatIHave, Is.EqualTo(expectedOutput));
        }
コード例 #5
0
        public void Should_return_the_current_configuration()
        {
            const string expectedOutput = @"Ignore missing configuration: True

            ------------------------------------------------------------------------------------

            FluentSecurity.Specification.TestData.BlogController > DeletePost
            FluentSecurity.Policy.RequireAnyRolePolicy (Owner or Publisher)

            FluentSecurity.Specification.TestData.BlogController > Index
            FluentSecurity.Policy.DenyAnonymousAccessPolicy

            ------------------------------------------------------------------------------------";

            var securityConfiguration = new SecurityConfiguration(configuration =>
            {
                configuration.GetAuthenticationStatusFrom(StaticHelper.IsAuthenticatedReturnsFalse);
                configuration.Advanced.IgnoreMissingConfiguration();
                configuration.For<BlogController>(x => x.DeletePost(0)).DenyAnonymousAccess().RequireAnyRole(UserRole.Owner, UserRole.Publisher);
                configuration.For<BlogController>(x => x.Index()).DenyAnonymousAccess();
            });

            SecurityConfigurator.SetConfiguration(securityConfiguration);

            // Act
            var whatIHave = securityConfiguration.WhatDoIHave();

            // Assert
            Assert.That(whatIHave, Is.EqualTo(expectedOutput));
        }