Exemple #1
0
        private static void RunACL(ProgramArguments arguments)
        {
            var entities    = SystemStartTests.CreateTestEntities();
            var groups      = SystemStartTests.CreateTestGroups();
            var memberships = Tools.CreateInMemoryMembershipTable(groups);
            var aces        = SystemStartTests.CreateTestAces();
            var storage     = new DatabaseStorage {
                Aces = aces, Memberships = memberships, Entities = entities, Messages = new List <Tuple <int, DateTime, byte[]> >()
            };

            StartTheSystem(new MemoryDataProvider(storage));

            var ctx = new SecurityContextForConcurrencyTests(TestUser.User2);
            var ok  = ctx.HasPermission(1, PermissionType.See);

            AclEditor.Create(ctx)
            .Allow(1, TestUser.User3.Id, false, PermissionType.Custom10)
            .Allow(2, TestUser.User3.Id, false, PermissionType.Custom10)
            .Allow(5, TestUser.User3.Id, false, PermissionType.Custom10)
            .Allow(14, TestUser.User3.Id, false, PermissionType.Custom10)
            .Allow(50, TestUser.User3.Id, false, PermissionType.Custom10)
            .Allow(51, TestUser.User3.Id, false, PermissionType.Custom10)
            .Allow(52, TestUser.User3.Id, false, PermissionType.Custom10)
            .Apply();
            ok = ctx.HasPermission(52, PermissionType.See);

            started = DateTime.UtcNow;

            Task.Run(() => ACLExercise1(0));
            Enumerable.Range(1, arguments.Agents).Select(x => Task.Run(() => ACLExercise(x))).ToArray();
        }
Exemple #2
0
        private static void ACLExercise2(int id)
        {
            var name      = "Writer-" + id;
            var ctx       = new SecurityContext(TestUser.User2);
            var count     = 0;
            var permTypes = new[] { PermissionType.Custom01, PermissionType.Custom02 };

            while (!_stopped)
            {
                Thread.Sleep(10);

                if (0 == (count % 1000))
                {
                    Console.WriteLine("Running time: {0}, errors: {1}. {2} {3}", DateTime.UtcNow - started, errors, name, count);
                }

                PermissionType perm1, perm2;

                var i = count % 2;
                perm1 = permTypes[i];
                perm2 = permTypes[1 - i];

                AclEditor.Create(ctx)
                .Allow(5, TestUser.User1.Id, false, perm1)
                .Allow(5, TestUser.User1.Id, false, perm2)
                .Apply();

                count++;
            }
        }
 public void UnbreakInheritance(TestEntity entity, bool normalize = false)
 {
     AclEditor.Create(this).UnbreakInheritance(entity.Id, normalize).Apply();
 }
 public void BreakInheritance(TestEntity entity, bool convertToExplicit = true)
 {
     AclEditor.Create(this).BreakInheritance(entity.Id, convertToExplicit).Apply();
 }