- Timestamp:
- 06/29/10 20:00:06 (14 years ago)
- Location:
- branches/HeuristicLab.Services.Authentication Prototype
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Services.Authentication Prototype/HeuristicLab.Services.Authentication Prototyp.sln
r3956 r3978 11 11 ProjectSection(SolutionItems) = preProject 12 12 HeuristicLab.Services.Authentication Prototyp.vsmdi = HeuristicLab.Services.Authentication Prototyp.vsmdi 13 HeuristicLab.Services.Authentication Prototyp1.vsmdi = HeuristicLab.Services.Authentication Prototyp1.vsmdi 13 14 HeuristicLab.Services.Authentication Prototyp2.vsmdi = HeuristicLab.Services.Authentication Prototyp2.vsmdi 14 15 LocalTestRun.testrunconfig = LocalTestRun.testrunconfig … … 17 18 Global 18 19 GlobalSection(TestCaseManagementSettings) = postSolution 19 CategoryFile = HeuristicLab.Services.Authentication Prototyp 2.vsmdi20 CategoryFile = HeuristicLab.Services.Authentication Prototyp1.vsmdi 20 21 EndGlobalSection 21 22 GlobalSection(SolutionConfigurationPlatforms) = preSolution -
branches/HeuristicLab.Services.Authentication Prototype/Persistence/HeuristicLabUserRole.cs
r3955 r3978 7 7 partial class HeuristicLabUserRole { 8 8 public override bool Equals(object obj) { 9 return ((HeuristicLabUserRole)obj).HeuristicLabRole.Equals(this.HeuristicLabRole) && ((HeuristicLabUserRole)obj).HeuristicLabUser.Equals(this.HeuristicLabUser); 9 if(this.ID == null ^ ((HeuristicLabUserRole)obj).ID == null ) 10 { 11 return false; 12 } 13 else if (this.ID == null && ((HeuristicLabUserRole)obj).ID == null) 14 { 15 return base.Equals(obj); 16 } 17 return ((HeuristicLabUserRole)obj).ID.Equals(this.ID); 10 18 } 11 19 } -
branches/HeuristicLab.Services.Authentication Prototype/Service/Provider/HeuristicLabRoleProvider.cs
r3967 r3978 126 126 127 127 public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames) { 128 throw new NotImplementedException(); 128 129 DataClassesDataContext context = DatabaseUtil.createDataClassesDataContext(); 130 131 foreach (string userName in usernames) { 132 if (userName != null && context.HeuristicLabUsers.Count(u => u.UserName == userName) > 0) { 133 Persistence.HeuristicLabUser user = context.HeuristicLabUsers.Single(u => u.UserName == userName); 134 foreach (Persistence.HeuristicLabUserRole userRole in user.HeuristicLabUserRoles) { 135 if (roleNames.Contains(userRole.HeuristicLabRole.RoleName)) { 136 context.HeuristicLabUserRole.DeleteOnSubmit(userRole); 137 //deleteList.Add(userRole); 138 }//if 139 }//foreach 140 }//if 141 }//foreach 142 context.SubmitChanges(); 143 context.Dispose(); 129 144 } 130 145 -
branches/HeuristicLab.Services.Authentication Prototype/UnitTests/HeuristicLabRoleProviderTest.cs
r3974 r3978 90 90 [TestMethod()] 91 91 public void RemoveUsersFromRolesTest() { 92 HeuristicLabRoleProvider target = new HeuristicLabRoleProvider(); // TODO: Initialize to an appropriate value 93 string[] usernames = null; // TODO: Initialize to an appropriate value 94 string[] roleNames = null; // TODO: Initialize to an appropriate value 95 target.RemoveUsersFromRoles(usernames, roleNames); 96 Assert.Inconclusive("A method that does not return a value cannot be verified."); 92 93 //creates users dkhan,hmayer,bfarka (with AddUsersToRolesTest()) 94 //and add all these users to groups admin and users 95 AddUsersToRolesTest(); 96 HeuristicLabRoleProvider target = new HeuristicLabRoleProvider(); 97 string[] users = new string[2]; 98 string[] roles = new string[1]; 99 100 //remove hmayer from role admin 101 users[0] = "hmayr"; 102 roles[0] = "admin"; 103 104 105 //before removing, check if all three users exits correctly in admin group 106 Assert.IsTrue((target.GetRolesForUser("hmayr").ToList()).Contains(roles[0])); 107 Assert.IsTrue((target.GetRolesForUser("dkhan").ToList()).Contains(roles[0])); 108 Assert.IsTrue((target.GetRolesForUser("bfarka").ToList()).Contains(roles[0])); 109 110 //remmove hmayr from admin group 111 target.RemoveUsersFromRoles(users, roles); 112 113 //final check 114 Assert.IsTrue((target.GetRolesForUser("dkhan").ToList()).Contains(roles[0])); 115 Assert.IsTrue((target.GetRolesForUser("bfarka").ToList()).Contains(roles[0])); 116 Assert.IsFalse((target.GetRolesForUser("hmayr").ToList()).Contains(roles[0])); 117 97 118 } 98 119 … … 132 153 Assert.IsTrue(target.GetUsersInRole(null).Length == 0); 133 154 Assert.IsTrue(target.GetUsersInRole(dummyRole).Length == 0); 134 Persistence.HeuristicLabUser user = new Persistence.HeuristicLabUser("dummyUser", "foo ", "foo", "foo");135 Persistence.HeuristicLabUser user2 = new Persistence.HeuristicLabUser("dummyUser2", "foo ", "foo", "foo");155 Persistence.HeuristicLabUser user = new Persistence.HeuristicLabUser("dummyUser", "foo1", "foo", "foo"); 156 Persistence.HeuristicLabUser user2 = new Persistence.HeuristicLabUser("dummyUser2", "foo2", "foo", "foo"); 136 157 db.HeuristicLabUsers.InsertOnSubmit(user); 137 158 db.HeuristicLabUsers.InsertOnSubmit(user2); … … 174 195 Assert.IsTrue(target.GetRolesForUser(dummyUser).Length == 0); 175 196 Persistence.HeuristicLabUser user = new Persistence.HeuristicLabUser("dummyUser", "foo", "foo", "foo"); 176 Persistence.HeuristicLabUser user2 = new Persistence.HeuristicLabUser("dummyUser2", "foo ", "foo", "foo");197 Persistence.HeuristicLabUser user2 = new Persistence.HeuristicLabUser("dummyUser2", "foo2", "foo", "foo"); 177 198 db.HeuristicLabUsers.InsertOnSubmit(user); 178 199 db.HeuristicLabUsers.InsertOnSubmit(user2); … … 212 233 roleNames.Add("Pascal"); 213 234 roleNames.Add("Java"); 214 roleNames.Add(" Pascal");235 roleNames.Add("c++"); 215 236 roleNames.Add("VisalBasic"); 216 237 foreach (string s in roleNames) { … … 235 256 Assert.IsTrue(target.FindUsersInRole(null, "dummyUser").Length == 0); 236 257 Persistence.HeuristicLabUser user = new Persistence.HeuristicLabUser("dummyUser", "foo", "foo", "foo"); 237 Persistence.HeuristicLabUser user2 = new Persistence.HeuristicLabUser("dummyUser2", "foo ", "foo", "foo");258 Persistence.HeuristicLabUser user2 = new Persistence.HeuristicLabUser("dummyUser2", "foo2", "foo", "foo"); 238 259 db.HeuristicLabUsers.InsertOnSubmit(user); 239 260 db.HeuristicLabUsers.InsertOnSubmit(user2); … … 294 315 Dictionary<string, Persistence.HeuristicLabUser> users = new Dictionary<string, Persistence.HeuristicLabUser>(); 295 316 List<string> roles = new List<string>(); 296 users.Add("dkhan", new Persistence.HeuristicLabUser("dkhan", "foo ", "password", "comment"));297 users.Add("hmayr", new Persistence.HeuristicLabUser("hmayr", "foo ", "password", "comment"));298 users.Add("bfarka", new Persistence.HeuristicLabUser("bfarka", "foo ", "password", "comment"));317 users.Add("dkhan", new Persistence.HeuristicLabUser("dkhan", "foo1", "password", "comment")); 318 users.Add("hmayr", new Persistence.HeuristicLabUser("hmayr", "foo2", "password", "comment")); 319 users.Add("bfarka", new Persistence.HeuristicLabUser("bfarka", "foo3", "password", "comment")); 299 320 300 321 roles.Add("admin"); … … 314 335 db.SubmitChanges(); 315 336 target.AddUsersToRoles(users.Keys.ToArray(), roles.ToArray()); 316 Assert.IsTrue(getUserRolesCount() == (roles.Count +users.Count));337 Assert.IsTrue(getUserRolesCount() == (roles.Count * users.Count)); 317 338 318 339 }
Note: See TracChangeset
for help on using the changeset viewer.