예제 #1
0
        private void GlobalSetupForRbacModelWithScale(int groupCount, int userCount)
        {
            GlobalSetupForRbacModel();
            var policyList = new List <List <string> >();

            for (int i = 0; i < groupCount; i++)
            {
                policyList.Add(new[] { $"group{i}", $"data{i / 10}", "read" }.ToList());
            }
            NowEnforcer.AddPolicies(policyList);

            policyList.Clear();
            for (int i = 0; i < userCount; i++)
            {
                policyList.Add(new[] { $"user{i}", $"group{i / 10}" }.ToList());
            }
            NowEnforcer.EnableAutoBuildRoleLinks(false);
            NowEnforcer.AddGroupingPolicies(policyList);
            NowEnforcer.BuildRoleLinks();

            NowTestUserName = $"user{userCount / 2 + 1}";   // if 1000 => 501...
            NowTestDataName = $"data{groupCount / 10 - 1}"; // if 100 => 9...
            Console.WriteLine($"// Already set user name to {NowTestUserName}.");
            Console.WriteLine($"// Already set data name to {NowTestDataName}.");
        }
예제 #2
0
        private void GlobalSetupForRbacModelWithScale(int groupCount, int userCount)
        {
            GlobalSetupForRbacModel();
            for (int i = 0; i < groupCount; i++)
            {
                NowEnforcer.AddPolicy($"group{i}", $"data{i / 10}", "read");
            }

            // Because we still have the policies management api,
            // so it will run BuildRoleLink at every loop.
            NowEnforcer.EnableAutoBuildRoleLinks(false);
            for (int i = 0; i < userCount; i++)
            {
                NowEnforcer.AddGroupingPolicy($"group{i}", $"group{i / 10}");
            }
            NowEnforcer.BuildRoleLinks();

            NowTestUserName = $"user{userCount / 2 + 1}"; // if 1000 => 501...
            NowTestDataName = $"group{groupCount - 1}";   // if 100 => 99...
            Console.WriteLine($"// Already set user name to {NowTestUserName}.");
            Console.WriteLine($"// Already set data name to {NowTestDataName}.");
        }