Exemple #1
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();
            }
        }
Exemple #2
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();
            }
        }
Exemple #3
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();
            }
        }
Exemple #4
0
        private static bool HasUserStartServerAndUseSettingsRights(WebSocketHandler webSocketHandler, ServerSetting serverSetting)
        {
            if (!ServerSettingsHandler.RightControl.IsGranted(webSocketHandler.ConnectedUserToken, "UseServerSettings", "ServerSetting", serverSetting.Id) &&
                !ServerSettingsHandler.RightControl.IsGranted(webSocketHandler.ConnectedUserToken, "UseServerSettings", "ServerSetting"))
            {
                return(false);
            }

            if (!RightControl.IsGranted(webSocketHandler.ConnectedUserToken, "StartServer", "ServerHandler", null))
            {
                return(false);
            }

            return(true);
        }
Exemple #5
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();
            }
        }