Exemple #1
0
        public async Task RoleReadAndWrite()
        {
            LCUser currentUser = await LCUser.Login(TestPhone, TestPhone);

            string name    = $"role_{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}";
            LCACL  roleACL = new LCACL();

            roleACL.SetUserReadAccess(currentUser, true);
            roleACL.SetUserWriteAccess(currentUser, true);
            LCRole role = LCRole.Create(name, roleACL);

            role.AddRelation("users", currentUser);
            await role.Save();

            account = new Account();
            LCACL acl = new LCACL();

            acl.SetRoleReadAccess(role, true);
            acl.SetRoleWriteAccess(role, true);
            account.ACL = acl;
            await account.Save();

            Assert.IsTrue(acl.GetRoleReadAccess(role));
            Assert.IsTrue(acl.GetRoleWriteAccess(role));
        }
Exemple #2
0
        public async Task RoleReadAndWrite()
        {
            LCQuery <LCRole> query = LCRole.GetQuery();
            LCRole           owner = await query.Get("5e1440cbfc36ed006add1b8d");

            LCObject account = new LCObject("Account");
            LCACL    acl     = new LCACL();

            acl.SetRoleReadAccess(owner, true);
            acl.SetRoleWriteAccess(owner, true);
            account.ACL = acl;
            await account.Save();

            Assert.IsTrue(acl.GetRoleReadAccess(owner));
            Assert.IsTrue(acl.GetRoleWriteAccess(owner));
        }