Пример #1
0
        public void the_filter_doesnt_authorize_the_execution()
        {
            var context   = new InMemoryCommunicationContext();
            var principal = new PrincipalAuthorizationInterceptor(context)
            {
                InRoles = new[] { "Administrators" }
            };

            principal.BeforeExecute(new Mock <IOperation>().Object).ShouldBe(true);
        }
Пример #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 PrincipalAuthorizationInterceptor(rastaContext)
            {
                Users = new[] { "johndoe" }
            };

            authorizer.BeforeExecute(new Mock <IOperation>().Object).ShouldBe(true);

            rastaContext.OperationResult.ShouldBeNull();
        }