Ejemplo n.º 1
0
        public void CanGrantAccessForAnActionWithParameters()
        {
            var authorization = new Authorization(_store, RolesProvider);
            var param1        = new ActionParam1 {
                P1 = "P1Value", Owner = "OwnerValue"
            };

            authorization.GrantAccess("ActionName", "RoleName", param1);
            var permissions = authorization.Query <ActionParam1>("ActionName")
                              .Where(ep => ep.ActionParameters.P1 == "P1Value" && ep.ActionParameters.Owner == "OwnerValue").ToList();

            Assert.AreEqual(permissions[0].ActionParameters.P1, "P1Value");
        }
Ejemplo n.º 2
0
        public void CanDenyAccessForAnActionAndEntityIdWithParameters()
        {
            var authorization = new Authorization(_store, RolesProvider);
            var eGuid         = Guid.NewGuid().ToString();
            var param1        = new ActionParam1 {
                P1 = "P1Value", Owner = "OwnerValue"
            };

            authorization.DenyAccess("ActionName", "RoleName", eGuid, param1);
            var permissions = authorization.Query <ActionParam1>("ActionName")
                              .Where(
                ep =>
                ep.EntityId == eGuid && ep.ActionParameters.P1 == "P1Value" &&
                ep.ActionParameters.Owner == "OwnerValue").ToList();

            Assert.AreEqual(permissions[0].ActionParameters.P1, "P1Value");
        }