public bool IsCurrentUserAdministrator()
        {
            IEnumerable <string> roles = _configurationReader.GetStringArray("TarantinoWebManagementRoles");

            string[] roleArray       = new List <string>(roles).ToArray();
            bool     isAdministrator = _manager.IsCurrentUserInAtLeastOneRole(roleArray);
            bool     isAuthenticatedAdministrator = _context.UserIsAuthenticated() && isAdministrator;

            return(isAuthenticatedAdministrator);
        }
Beispiel #2
0
        public bool CurrentUrlCanBeRedirected()
        {
            string extension = Path.GetExtension(_context.GetCurrentUrl());
            IEnumerable <string> extensions = _configurationReader.GetStringArray("TarantinoWebManagementMaintenanceExtensions");

            List <string> extensionList       = new List <string>(extensions);
            bool          isExtensionIncluded = Array.IndexOf(extensionList.ToArray(), extension.ToLower()) >= 0;

            return(isExtensionIncluded);
        }
        public void Should_read_mapping_assemblies()
        {
            string[] mappingAssemblies = new string[0];

            MockRepository       mocks  = new MockRepository();
            IConfigurationReader reader = mocks.CreateMock <IConfigurationReader>();

            using (mocks.Record())
            {
                Expect.Call(reader.GetStringArray("MappingAssemblies")).Return(mappingAssemblies);
            }

            using (mocks.Playback())
            {
                IApplicationSettings settings = new ApplicationSettings(reader);
                Assert.That(settings.GetMappingAssemblies(), Is.SameAs(mappingAssemblies));
            }
        }
Beispiel #4
0
        public void Correctly_determines_when_mixed_case_extension_is_in_list_of_extensions()
        {
            MockRepository       mocks   = new MockRepository();
            IConfigurationReader reader  = mocks.CreateMock <IConfigurationReader>();
            IWebContext          context = mocks.CreateMock <IWebContext>();

            using (mocks.Record())
            {
                Expect.Call(reader.GetStringArray("TarantinoWebManagementMaintenanceExtensions")).Return(new string[] { ".aspx", ".html" });
                Expect.Call(context.GetCurrentUrl()).Return("/website/mypage.Aspx");
            }

            using (mocks.Playback())
            {
                IFileExtensionChecker checker = new FileExtensionChecker(reader, context);
                bool canBeRedirected          = checker.CurrentUrlCanBeRedirected();

                Assert.That(canBeRedirected);
            }
        }
        public void Validates_authenticated_administrator()
        {
            string[] roles = new string[] { @"BUILTIN\Administrators", "Administrators" };

            MockRepository       mocks               = new MockRepository();
            IWebContext          context             = mocks.CreateMock <IWebContext>();
            IRoleManager         roleManager         = mocks.CreateMock <IRoleManager>();
            IConfigurationReader configurationReader = mocks.CreateMock <IConfigurationReader>();

            using (mocks.Record())
            {
                Expect.Call(context.UserIsAuthenticated()).Return(true);
                Expect.Call(configurationReader.GetStringArray("TarantinoWebManagementRoles")).Return(roles);
                Expect.Call(roleManager.IsCurrentUserInAtLeastOneRole(roles)).Return(true);
            }

            using (mocks.Playback())
            {
                IAdministratorSecurityChecker checker = new AdministratorSecurityChecker(context, roleManager, configurationReader);
                Assert.That(checker.IsCurrentUserAdministrator(), Is.True);
            }

            mocks.VerifyAll();
        }
        public IEnumerable <string> GetMappingAssemblies()
        {
            IEnumerable <string> settings = _configurationReader.GetStringArray("MappingAssemblies");

            return(settings);
        }