public FakeRoleProviderTest()
        {
            this.localProvider = Substitute.For <RoleProvider>();
            this.provider      = new FakeRoleProvider();
            this.provider.LocalProvider.Value = this.localProvider;

            this.roles = new[] { @"sitecore\Editors", @"sitecore\Authors" };
            this.users = new[] { @"sitecore\John", @"sitecore\Jane" };
        }
示例#2
0
        public async Task CanPerformCurrentActionOnRecord_NoRoleFromEntity_ReturnsGlobalRole()
        {
            var user       = GetIdentity("WildcardAppliedRoleId");
            var rp         = new FakeRoleProvider();
            var controller = new TestController(new SecurityAccessProvider(GetSecurityAccessProviderOptions()), rp, user);

            (await controller.ExecCanPerformCurrentActionOnRecord(new object(), "BogusAction")).Should().BeFalse();
            (await controller.ExecCanPerformCurrentActionOnRecord(new object(), "ReaderAppliedAction1")).Should().BeTrue();
        }
        public void ShouldDoNothingIfNoBehaviourSet()
        {
            // arrange
            var stubProvider = new FakeRoleProvider();

            // act & assert
            Assert.Null(stubProvider.ApplicationName);
            Assert.DoesNotThrow(() => stubProvider.AddUsersToRoles(null, null));
            Assert.DoesNotThrow(() => stubProvider.CreateRole(null));
            stubProvider.DeleteRole(null, false).Should().BeFalse();
            stubProvider.FindUsersInRole(null, null).Should().BeEmpty();
            stubProvider.GetAllRoles().Should().BeEmpty();
            stubProvider.GetRolesForUser(null).Should().BeEmpty();
            stubProvider.GetUsersInRole(null).Should().BeEmpty();
            stubProvider.IsUserInRole(null, null).Should().BeFalse();
            Assert.DoesNotThrow(() => stubProvider.RemoveUsersFromRoles(null, null));
            stubProvider.RoleExists(null).Should().BeFalse();
        }