public void delegates_by_bool_func()
        {
            var policy = new AuthorizationByService<AuthCheckingService>(x => x.IsOk);

            var context = new MockedFubuRequestContext();
            context.Services.As<InMemoryServiceLocator>().Add(new AuthCheckingService
            {
                IsOk = true
            });

            policy.RightsFor(context).ShouldBe(AuthorizationRight.Allow);

            context.Services.As<InMemoryServiceLocator>().Add(new AuthCheckingService
            {
                IsOk = false
            });

            policy.RightsFor(context).ShouldBe(AuthorizationRight.Deny);
        }
Ejemplo n.º 2
0
        public void delegates_by_bool_func()
        {
            var policy = new AuthorizationByService <AuthCheckingService>(x => x.IsOk);

            var context = new MockedFubuRequestContext();

            context.Services.As <InMemoryServiceLocator>().Add(new AuthCheckingService
            {
                IsOk = true
            });

            policy.RightsFor(context).ShouldBe(AuthorizationRight.Allow);

            context.Services.As <InMemoryServiceLocator>().Add(new AuthCheckingService
            {
                IsOk = false
            });

            policy.RightsFor(context).ShouldBe(AuthorizationRight.Deny);
        }
Ejemplo n.º 3
0
        public void delegates_by_auth_rights_func()
        {
            var policy = new AuthorizationByService <AuthCheckingService>(x => x.Rights);

            var context = new MockedFubuRequestContext();

            context.Services.As <InMemoryServiceLocator>().Add(new AuthCheckingService
            {
                Rights = AuthorizationRight.Allow
            });

            policy.RightsFor(context).ShouldEqual(AuthorizationRight.Allow);

            context.Services.As <InMemoryServiceLocator>().Add(new AuthCheckingService
            {
                Rights = AuthorizationRight.Deny
            });

            policy.RightsFor(context).ShouldEqual(AuthorizationRight.Deny);
        }
Ejemplo n.º 4
0
        public void delegates_by_auth_rights_func()
        {
            var policy = new AuthorizationByService<AuthCheckingService>(x => x.Rights);

            var context = new MockedFubuRequestContext();
            context.Services.As<InMemoryServiceLocator>().Add(new AuthCheckingService
            {
                Rights = AuthorizationRight.Allow
            });

            policy.RightsFor(context).ShouldEqual(AuthorizationRight.Allow);

            context.Services.As<InMemoryServiceLocator>().Add(new AuthCheckingService
            {
                Rights = AuthorizationRight.Deny
            });

            policy.RightsFor(context).ShouldEqual(AuthorizationRight.Deny);

        }