Esempio n. 1
0
        public async Task CheckPermissions_HasOnePermission_Succeed()
        {
            // arrange
            var permission             = new PermissionDescriptor <bool>("Test");
            var participantPermissions = CreateParticipantPermissions(permission.Configure(true));

            var context = CreateContext(builder =>
                                        builder.RegisterInstance(participantPermissions).AsImplementedInterfaces());

            // act
            var result = await ServiceInvokerPermissionMiddleware.CheckPermissions(context, permission);

            // assert
            Assert.True(result.Success);
        }
Esempio n. 2
0
        public async Task CheckPermissions_RequireMultiplePermissionsAndDoesntHaveAll_Fail()
        {
            // arrange
            var permission             = new PermissionDescriptor <bool>("Test");
            var permission2            = new PermissionDescriptor <bool>("Test2");
            var participantPermissions = CreateParticipantPermissions(permission.Configure(true));

            var context = CreateContext(builder =>
                                        builder.RegisterInstance(participantPermissions).AsImplementedInterfaces());

            // act
            var result = await ServiceInvokerPermissionMiddleware.CheckPermissions(context, permission, permission2);

            // assert
            Assert.False(result.Success);
        }