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); }
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(); }