Example #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();
        }
Example #2
0
        private static void DELETECheckPermission(int id)
        {
            Trace.WriteLine("SECDEL> Start check thread id " + id);
            var ctx     = new SecurityContextForConcurrencyTests(TestUser.User1);
            var eid     = Id("E99");
            var catched = false;
            var count   = 0;

            while (!_stopped)
            {
                try
                {
                    var hp = ctx.HasPermission(eid, PermissionType.See);
                    if (hp)
                    {
                        errors++;
                    }

                    count++;
                }
                catch (EntityNotFoundException)
                {
                    // the entity was deleted in the meantime
                    _stopped = true;
                    catched  = true;
                }
            }

            Trace.WriteLine("SECDEL> End check thread id " + id + ". Catched: " + catched + ". Count: " + count);
        }
Example #3
0
        private static void ACLExercise1(int id)
        {
            var name  = "Reader-" + id;
            var ctx   = new SecurityContextForConcurrencyTests(TestUser.User2);
            var count = 0;
            var rnd   = new Random();

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

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

                var ok = ctx.HasPermission(52, PermissionType.See);

                if (!ok)
                {
                    Console.WriteLine("Running time: {0}, errors: {1}. {2} {3}  ERROR", DateTime.UtcNow - started, ++errors, name, count);
                }

                count++;
            }
        }
Example #4
0
        internal static void StartTheSystem(ISecurityDataProvider securityDataProvider)
        {
            MessageSender.Initialize("asdf");

            // Call SecurityContext starter method.
            SecurityContextForConcurrencyTests.StartTheSystem(new SecurityConfiguration
            {
                SecurityDataProvider = securityDataProvider,
                MessageProvider      = new DefaultMessageProvider(),
                CommunicationMonitorRunningPeriodInSeconds = 31,
            });
        }