public void AddUser() { User user = new User(); user.Account = "test-adduser-" + StringFactory.NewGuid().Substring(0, 4); user.Name = "test-add-user"; user.IsActive = true; user.Save(); Organization org = Organization.Create(); org.Code = StringFactory.NewGuid(); org.Name = "org-test-name"; org.FullName = "org-test-fullname"; org.Save(); Position position = Position.Create(); position.Code = StringFactory.NewGuid(); position.OrganizationId = org.Id; position.Name = "test-add-Postion"; position.Save(); position.AddUser(user); var userInfo = position.UserList.FirstOrDefault(u => u.Account == user.Account); Assert.IsNotNull(userInfo); user.Delete(); position.RemoveUser(user); position.Delete(); org.Delete(); }
public void CancelRole() { User user = new User(); user.Name = "test-add-user"; user.Account = StringFactory.NewGuid(); user.Save(); Role role = Role.Create(); role.Code = StringFactory.NewGuid(); role.Name = "test-giverole-role"; role.Save(); user.GiveRole(role); User user1 = User.GetUser(user.Account); var user2 = user1.RoleList.Where(r => r.Code == role.Code).ToList(); Assert.AreEqual(1, user2.Count); user1.CancelRole(role); var user3 = user1.RoleList.Where(r => r.Code == role.Code).ToList(); Assert.AreEqual(0, user3.Count); role.Delete(); user.Delete(); }
public void AddUser() { Organization org1 = Organization.Create(); org1.Code = StringFactory.NewGuid(); org1.Name = "org-test-name"; org1.FullName = "org-test-fullname"; org1.Save(); Assert.IsNotNull(org1); User user1 = new User(); user1.Account = "test-user-add" + StringFactory.NewGuid().Substring(0, 4); user1.Name = "test-user-name"; user1.IsActive = true; user1.Save(); org1.AddUser(user1); var positionuser = org1.UserList.Where(pu => pu.Account == user1.Account).ToList(); Assert.AreEqual(1, positionuser.Count); user1.Delete(); org1.Delete(); org1.RemoveUser(user1); }
public void CheckPermission() { User user = new User(); user.Name = "test-add-user"; user.Account = StringFactory.NewGuid(); user.Save(); Operation target = new Operation(); target.Code = StringFactory.NewGuid(); target.AppId = StringFactory.NewGuid(); target.TargetId = StringFactory.NewGuid(); target.Name = "test-add-RoleTargetOperation"; bool b = user.CheckPermission(target); Assert.IsFalse(b); User user1 = new User(); user1.Name = "test-add-user"; user1.Account = StringFactory.NewGuid(); user1.Save(); Role role = Role.Create(); role.Name = "test-giverole-role"; role.Save(); role.GivePermission(target); user.GiveRole(role); User user2 = User.GetUser(user.Account); var b1 = user2.CheckPermission(target); Assert.IsTrue(b1); role.Delete(); user1.CancelRole(role); role.CancelPermission(target); user.Delete(); user1.Delete(); }
public void TargetOperationList() { User user = new User(); user.Name = "test-add-user"; user.Account = StringFactory.NewGuid(); user.Save(); Operation operation = new Operation(); operation.Code = StringFactory.NewGuid(); operation.AppId = StringFactory.NewGuid(); operation.TargetId = StringFactory.NewGuid(); operation.Name = "test-add-RoleTargetOperation"; operation.Save(); User user1 = new User(); user1.Name = "test-add-user"; user1.Account = StringFactory.NewGuid(); user1.Save(); Role role = Role.Create(); role.Name = "test-giverole-role"; role.Save(); role.GivePermission(operation); user.GiveRole(role); User user2 = User.GetUser(user.Account); Assert.AreEqual(1, user2.OperationList.Count); role.Delete(); user1.CancelRole(role); role.CancelPermission(operation); operation.Delete(); user.Delete(); user1.Delete(); }
public void TargetList() { User user = new User(); user.Name = "test-add-user"; user.Account = StringFactory.NewGuid(); user.Save(); Role role = Role.Create(); role.Name = "test-giverole-role"; role.Save(); user.GiveRole(role); Organization org1 = Organization.Create(); org1.Code = StringFactory.NewGuid(); org1.Name = "org-test-name"; org1.FullName = "org-test-fullname"; org1.Save(); Assert.IsNotNull(org1); org1.GiveRole(role); Target target = Target.Create(); target.Code = StringFactory.NewGuid(); target.AppId = StringFactory.NewGuid(); target.Save(); Operation targetoperation = new Operation(); targetoperation.Code = StringFactory.NewGuid(); targetoperation.AppId = StringFactory.NewGuid(); targetoperation.TargetId = StringFactory.NewGuid(); target.AddOperation(targetoperation); role.GivePermission(targetoperation); User user1 = User.GetUser(user.Account); Assert.IsNotNull(user.TargetList); user.Delete(); role.Delete(); org1.Delete(); org1.CancelRole(role); target.Delete(); target.RemoveOperation(targetoperation); role.CancelPermission(targetoperation); }
public void Save() { User user = new User(); user.Name = "test-add-user"; user.Account = StringFactory.NewGuid(); User user2 = User.GetUser(user.Account); Assert.IsNull(user2); user.Save(); User user1 = User.GetUser(user.Account); Assert.IsNotNull(user1); user.Delete(); }
public void PositionList() { User user = new User(); user.Account = "test-add-user" + StringFactory.NewGuid().Substring(0, 4); user.Save(); Organization org1 = Organization.Create(); org1.Code = StringFactory.NewGuid(); org1.Name = "org-test-name"; org1.FullName = "org-test-fullname"; org1.IsActive = true; org1.Save(); Position position = Position.Create(); position.Name = "test-Position-add"; position.Code = StringFactory.NewGuid(); position.OrganizationId = org1.Id; position.IsActive = true; position.Save(); position.AddUser(user); User user1 = User.GetUser(user.Account); Assert.IsNotNull(user1); Assert.AreEqual(1, user1.PositionList .Where(o => o.OrganizationId == org1.Id) .ToList().Count); user.Delete(); position.RemoveUser(user); position.Delete(); org1.Delete(); }
public void DeepRoleList() { User user = new User(); user.Name = "test-add-user"; user.Account = StringFactory.NewGuid(); user.Save(); Role role = Role.Create(); role.Name = "test-giverole-role"; role.Save(); user.GiveRole(role); User user1 = User.GetUser(user.Account); var user2 = user1.DeepRoleList.Where(r => r.Code == role.Code); ; Assert.IsNotNull(user2); user1.CancelRole(role); role.Delete(); user.Delete(); }
public void GetUserList() { Organization org1 = Organization.Create(); org1.Code = StringFactory.NewGuid(); org1.Name = "org-test-name"; org1.FullName = "org-test-fullname"; org1.Save(); Assert.IsNotNull(org1); User user1 = new User(); user1.Account = "test-user-add" + StringFactory.NewGuid().Substring(0, 4); user1.IsActive = true; user1.Save(); org1.AddUser(user1); Organization org2 = Organization.GetOrganization(org1.Code); Assert.IsNotNull(org2); Assert.AreNotEqual(0, org2.UserList.Count); org1.Delete(); org1.RemoveUser(user1); user1.Delete(); }