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)); }
public async Task FileACL() { LCUser user = await LCUser.LoginAnonymously(); LCFile file = new LCFile("avatar", AvatarFilePath); LCACL acl = new LCACL(); acl.SetUserReadAccess(user, true); file.ACL = acl; await file.Save(); LCQuery <LCFile> query = LCFile.GetQuery(); LCFile avatar = await query.Get(file.ObjectId); Assert.NotNull(avatar.ObjectId); await LCUser.LoginAnonymously(); try { LCFile forbiddenAvatar = await query.Get(file.ObjectId); } catch (LCException e) { Assert.AreEqual(e.Code, 403); } }