public void DisablesGlimpseIfUserNotLoggedInAndNoCookie()
 {
     // Arrange
     var context = new Mock<HttpContextBase>();
     context.Setup(c => c.Request.IsAuthenticated)
            .Returns(false);
     var policy = new TestableGlimpseRuntimePolicy();
     
     // Act/Assert
     Assert.Equal(RuntimePolicy.Off, policy.Execute(context.Object));
 }
Beispiel #2
0
            public void DisablesGlimpseIfUserNotLoggedInAndNoCookie()
            {
                // Arrange
                var context = new Mock <HttpContextBase>();

                context.Setup(c => c.Request.IsAuthenticated)
                .Returns(false);
                var policy = new TestableGlimpseRuntimePolicy();

                // Act/Assert
                Assert.Equal(RuntimePolicy.Off, policy.Execute(context.Object));
            }
            public void DisablesGlimpseIfSSLRequiredAndConnectionIsNotSecureAndNoCookie()
            {
                // Arrange
                var context = new Mock<HttpContextBase>();
                context.Setup(c => c.Request.IsAuthenticated)
                       .Returns(true);
                context.Setup(c => c.Request.IsSecureConnection)
                       .Returns(false);
                var policy = new TestableGlimpseRuntimePolicy();
                policy.MockConfiguration
                    .Setup(c => c.RequireSSL)
                    .Returns(true);

                // Act/Assert
                Assert.Equal(RuntimePolicy.Off, policy.Execute(context.Object));
            }
            public void EnablesGlimpseCompletelyIfUserIsAdmin()
            {
                // Arrange
                var context = new Mock<HttpContextBase>();
                context.Setup(c => c.Request.IsAuthenticated)
                       .Returns(true);
                context.Setup(c => c.Request.IsSecureConnection)
                       .Returns(true);
                context.Setup(c => c.User.IsInRole(Constants.AdminRoleName))
                       .Returns(true);
                var policy = new TestableGlimpseRuntimePolicy();
                policy.MockConfiguration
                    .Setup(c => c.RequireSSL)
                    .Returns(true);

                // Act/Assert
                Assert.Equal(RuntimePolicy.On, policy.Execute(context.Object));
            }
Beispiel #5
0
            public void DisablesGlimpseIfSSLRequiredAndConnectionIsNotSecureAndNoCookie()
            {
                // Arrange
                var context = new Mock <HttpContextBase>();

                context.Setup(c => c.Request.IsAuthenticated)
                .Returns(true);
                context.Setup(c => c.Request.IsSecureConnection)
                .Returns(false);
                var policy = new TestableGlimpseRuntimePolicy();

                policy.MockConfiguration
                .Setup(c => c.RequireSSL)
                .Returns(true);

                // Act/Assert
                Assert.Equal(RuntimePolicy.Off, policy.Execute(context.Object));
            }
            public void DisablesGlimpseIfUserIsNotAdminAndNoCookie()
            {
                // Arrange
                var context = new Mock<HttpContextBase>();
                context.Setup(c => c.Request.IsAuthenticated)
                       .Returns(true);
                context.Setup(c => c.Request.IsSecureConnection)
                       .Returns(true);
                context.Setup(c => c.User.IsInRole(Constants.AdminRoleName))
                       .Returns(false);
                context.Setup(c => c.Request.Path)
                       .Returns("/api");
                var policy = new TestableGlimpseRuntimePolicy();
                policy.MockConfiguration
                    .Setup(c => c.RequireSSL)
                    .Returns(true);

                // Act/Assert
                Assert.Equal(RuntimePolicy.Off, policy.Execute(context.Object));
            }
Beispiel #7
0
            public void EnablesGlimpseCompletelyOverHTTPIfRequireSSLFalse()
            {
                // Arrange
                var context = new Mock <HttpContextBase>();

                context.Setup(c => c.Request.IsAuthenticated)
                .Returns(true);
                context.Setup(c => c.Request.IsSecureConnection)
                .Returns(false);
                context.Setup(c => c.User.IsInRole(Constants.AdminRoleName))
                .Returns(true);
                var policy = new TestableGlimpseRuntimePolicy();

                policy.MockConfiguration
                .Setup(c => c.RequireSSL)
                .Returns(false);

                // Act/Assert
                Assert.Equal(RuntimePolicy.On, policy.Execute(context.Object));
            }
Beispiel #8
0
            public void DisablesGlimpseIfUserIsNotAdminAndNoCookie()
            {
                // Arrange
                var context = new Mock <HttpContextBase>();

                context.Setup(c => c.Request.IsAuthenticated)
                .Returns(true);
                context.Setup(c => c.Request.IsSecureConnection)
                .Returns(true);
                context.Setup(c => c.User.IsInRole(Constants.AdminRoleName))
                .Returns(false);
                context.Setup(c => c.Request.Path)
                .Returns("/api");
                var policy = new TestableGlimpseRuntimePolicy();

                policy.MockConfiguration
                .Setup(c => c.RequireSSL)
                .Returns(true);

                // Act/Assert
                Assert.Equal(RuntimePolicy.Off, policy.Execute(context.Object));
            }
Beispiel #9
0
            public void DisablesGlimpseIfPathIsKnownToBeStaticContent(string path)
            {
                // Arrange
                var context = new Mock <HttpContextBase>();

                context.Setup(c => c.Request.IsLocal)
                .Returns(false);
                context.Setup(c => c.Request.IsAuthenticated)
                .Returns(true);
                context.Setup(c => c.Request.IsSecureConnection)
                .Returns(true);
                context.Setup(c => c.User.IsInRole(Constants.AdminRoleName))
                .Returns(true);
                context.Setup(c => c.Request.Path)
                .Returns(path);
                var policy = new TestableGlimpseRuntimePolicy();

                policy.MockConfiguration
                .Setup(c => c.RequireSSL)
                .Returns(true);

                // Act/Assert
                Assert.Equal(RuntimePolicy.Off, policy.Execute(context.Object));
            }
Beispiel #10
0
            public void EnablesGlimpsePersistenceIfRequestIsLocal()
            {
                // Arrange
                var context = new Mock <HttpContextBase>();

                context.Setup(c => c.Request.IsLocal)
                .Returns(true);
                context.Setup(c => c.Request.IsAuthenticated)
                .Returns(false);
                context.Setup(c => c.Request.IsSecureConnection)
                .Returns(false);
                context.Setup(c => c.User.IsInRole(Constants.AdminRoleName))
                .Returns(false);
                context.Setup(c => c.Request.Path)
                .Returns("/api");
                var policy = new TestableGlimpseRuntimePolicy();

                policy.MockConfiguration
                .Setup(c => c.RequireSSL)
                .Returns(true);

                // Act/Assert
                Assert.Equal(RuntimePolicy.PersistResults, policy.Execute(context.Object));
            }
            public void DisablesGlimpseIfPathIsKnownToBeStaticContent(string path)
            {
                // Arrange
                var context = new Mock<HttpContextBase>();
                context.Setup(c => c.Request.IsLocal)
                       .Returns(false);
                context.Setup(c => c.Request.IsAuthenticated)
                       .Returns(true);
                context.Setup(c => c.Request.IsSecureConnection)
                       .Returns(true);
                context.Setup(c => c.User.IsInRole(Constants.AdminRoleName))
                       .Returns(true);
                context.Setup(c => c.Request.Path)
                    .Returns(path);
                var policy = new TestableGlimpseRuntimePolicy();
                policy.MockConfiguration
                    .Setup(c => c.RequireSSL)
                    .Returns(true);

                // Act/Assert
                Assert.Equal(RuntimePolicy.Off, policy.Execute(context.Object));
            }
            public void EnablesGlimpsePersistenceIfRequestIsLocal()
            {
                // Arrange
                var context = new Mock<HttpContextBase>();
                context.Setup(c => c.Request.IsLocal)
                       .Returns(true);
                context.Setup(c => c.Request.IsAuthenticated)
                       .Returns(false);
                context.Setup(c => c.Request.IsSecureConnection)
                       .Returns(false);
                context.Setup(c => c.User.IsInRole(Constants.AdminRoleName))
                       .Returns(false);
                context.Setup(c => c.Request.Path)
                    .Returns("/api");
                var policy = new TestableGlimpseRuntimePolicy();
                policy.MockConfiguration
                    .Setup(c => c.RequireSSL)
                    .Returns(true);

                // Act/Assert
                Assert.Equal(RuntimePolicy.PersistResults, policy.Execute(context.Object));
            }