Ejemplo n.º 1
0
        public void the_filter_doesnt_authorize_the_execution()
        {
            var context   = new InMemoryCommunicationContext();
            var principal = new PrincipalAuthorizationAttribute {
                InRoles = new[] { "Administrators" }
            };

            principal.ExecuteBefore(context)
            .ShouldBe(PipelineContinuation.RenderNow);
        }
Ejemplo n.º 2
0
        public void the_username_is_matched_and_execution_continues()
        {
            Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("johndoe"), new[] { "Administrator" });

            var rastaContext = new InMemoryCommunicationContext();
            var authorizer   = new PrincipalAuthorizationAttribute()
            {
                Users = new[] { "johndoe" }
            };

            authorizer.ExecuteBefore(rastaContext)
            .ShouldBe(PipelineContinuation.Continue);

            rastaContext.OperationResult.ShouldBeNull();
        }