public void TestTakeOwnershipDisallowed() { Blog blog = new Blog(); blog.Account = _user; blog.Created = DateTime.UtcNow; blog.Description = Guid.NewGuid().ToString(); blog.Name = Guid.NewGuid().ToString(); Session.Save(blog); Session.Flush(); Account user2 = CreateUser(); using (new Impersonator(new UserContext(user2))) { try { blog.Description = Guid.NewGuid().ToString(); blog.Account = user2; Session.Save(blog); Session.Flush(); } finally { // delete temp user DeleteUser(user2); using (new Impersonator(new UserContext(blog.Account))) { // delete blog Blog blogCopy = Session.Load<Blog>(blog.Id); Session.Delete(blogCopy); Session.Flush(); } } } }
public void DeleteBlog(Blog instance) { using (new Impersonator(new UserContext(instance.Account))) { Blog instanceCopy = Session.Load<Blog>(instance.Id); Session.Delete(instanceCopy); Session.Flush(); } }
public BlogClassACL(Blog instance) { // allow every authenticated user to create a blog this.Add(new ACLAuthenticatedAllowCreate()); // allow everyone to get information about this blog this.Add(new ACLEveryoneAllowRetrieve()); // the owner has full privileges this.Add(new ACLAccount(instance.Account, DataOperation.All)); }
public void TestCreateDelete() { Blog blog = new Blog(); blog.Account = _user; blog.Created = DateTime.UtcNow; blog.Description = Guid.NewGuid().ToString(); blog.Name = Guid.NewGuid().ToString(); Session.Save(blog); Session.Delete(blog); }
public Blog CreateBlog() { Blog instance = new Blog(); instance.Account = _user; instance.Created = DateTime.UtcNow; instance.Description = Guid.NewGuid().ToString(); instance.Name = Guid.NewGuid().ToString(); Session.Save(instance); Session.Flush(); return instance; }
public override void SetUp() { base.SetUp(); _blog = CreateBlog(); }