Example #1
0
        internal static async Task RegisterUser(User user, string token)
        {
            List <PureRight> pureRights = new List <PureRight>();

            pureRights.Add(new PureRight
            {
                Authorized     = true,
                Operation      = "StartServer",
                RecourceModule = "ServerHandler"
            });
            string otherToken = await RightControl.Register(user.Uuid, pureRights, token);
        }
Example #2
0
        public async Task CheckRegisterGivenAuthorizationsDataBaseOnly()
        {
            RightControl rightControl = new RightControl("CheckRegister");
            string       token        = await rightControl.Register("1");

            if (!rightControl.IsGranted(token, "Add", "Authorizations"))
            {
                Assert.Fail();
            }
            if (rightControl.IsGranted(token, "Delete", "Authorizations"))
            {
                Assert.Fail();
            }
            if (rightControl.IsGranted(token, "Anything", "SometingElse"))
            {
                Assert.Fail();
            }
        }
Example #3
0
        public async Task CheckRegisterGivenAuthorizationsWithAdditionalAutorizations()
        {
            RightControl rightControl = new RightControl("CheckRegister");

            List <PureRight> pureRights = new List <PureRight>();

            pureRights.Add(new PureRight
            {
                Authorized     = false,
                Operation      = "Add",
                RecourceModule = "Authorizations"
            });
            pureRights.Add(new PureRight
            {
                Authorized     = true,
                Operation      = "Modify",
                RecourceModule = "Authorizations"
            });
            pureRights.Add(new PureRight
            {
                Authorized     = true,
                Operation      = "Any",
                RecourceModule = "SomethingElse"
            });

            string token = await rightControl.Register("1", pureRights);

            if (rightControl.IsGranted(token, "Add", "Authorizations"))
            {
                Assert.Fail();
            }
            if (rightControl.IsGranted(token, "Delete", "Authorizations"))
            {
                Assert.Fail();
            }
            if (!rightControl.IsGranted(token, "Modify", "Authorizations"))
            {
                Assert.Fail();
            }
            if (!rightControl.IsGranted(token, "Any", "SomethingElse"))
            {
                Assert.Fail();
            }
        }
Example #4
0
        public async Task CheckGrandManually()
        {
            RightControl     rightControl = new RightControl("CheckRegisterAnotherNamespace");
            string           token        = "SomeToken";
            List <PureRight> pureRights   = new List <PureRight>();

            pureRights.Add(new PureRight
            {
                Authorized     = true,
                Operation      = "AddServerSettings_" + "SomeUser",
                RecourceModule = "ServerSetting"
            });
            string otherToken = await rightControl.Register("1337", pureRights, token);

            if (!rightControl.IsGranted(token, "AddServerSettings_" + "SomeUser", "ServerSetting"))
            {
                Assert.Fail();
            }
        }
Example #5
0
        public async Task CheckRegisterGivenAuthorizationsWithAdditionalAutorization()
        {
            RightControl rightControl = new RightControl("CheckRegister");
            PureRight    pureRight    = new PureRight();

            pureRight.Authorized     = true;
            pureRight.Operation      = "Edit";
            pureRight.RecourceModule = "Authorizations";
            string token = await rightControl.Register("1", pureRight);

            if (!rightControl.IsGranted(token, "Add", "Authorizations"))
            {
                Assert.Fail();
            }
            if (rightControl.IsGranted(token, "Delete", "Authorizations"))
            {
                Assert.Fail();
            }
            if (!rightControl.IsGranted(token, "Edit", "Authorizations"))
            {
                Assert.Fail();
            }
        }