public void GetAllProfilesReturnTwoTestUsers() { using (var profileService = new ProfileService.ProfileServiceClient()) { var profile = profileService.GetOrCreateProfile( userName: testBase.TestProfileOne.UserName, regionId: (int)testBase.TestProfileOne.Region, platformId: (int)testBase.TestProfileOne.Region); testBase.TestProfileOne.ProfileGuid = profile.ProfileGuid; profile = profileService.GetOrCreateProfile( userName: testBase.TestProfileTwo.UserName, regionId: (int)testBase.TestProfileTwo.Region, platformId: (int)testBase.TestProfileTwo.Region); testBase.TestProfileTwo.ProfileGuid = profile.ProfileGuid; } var profList = new List <Profile>(); using (var profileService = new ProfileService.ProfileServiceClient()) { profList = profileService.RetieveAllProfiles().ToList(); } var testProfileOneExists = profList.Any(p => p.ProfileGuid == testBase.TestProfileOne.ProfileGuid); var testProfileTwoExists = profList.Any(p => p.ProfileGuid == testBase.TestProfileTwo.ProfileGuid); Assert.IsTrue(testProfileOneExists, "Test Profile One was not returned"); Assert.IsTrue(testProfileTwoExists, "Test Profile Two was not returned"); }
public void CleanUpProfileScriptShouldDeleteTestUserOne() { using (var profileService = new ProfileService.ProfileServiceClient()) { var profile = profileService.GetOrCreateProfile( userName: testBase.TestProfileOne.UserName, regionId: (int)testBase.TestProfileOne.Region, platformId: (int)testBase.TestProfileOne.Region); testBase.TestProfileOne.ProfileGuid = profile.ProfileGuid; } using (var cleanUpService = new CleanUpService.CleanUpServiceClient()) { cleanUpService.DeleteUser(testBase.TestProfileOne.ProfileGuid); } using (var profileService = new ProfileService.ProfileServiceClient()) { var profile = profileService.RetrieveProfile( userName: testBase.TestProfileOne.UserName, regionId: (int)testBase.TestProfileOne.Region, platformId: (int)testBase.TestProfileOne.Region); testBase.TestProfileOne.ProfileGuid = (profile == null) ? profile.ProfileGuid : Guid.Empty; } }
public void GetOrCreateProfileShouldReturnNewProfile() { using (var profileService = new ProfileService.ProfileServiceClient()) { var profile = profileService.GetOrCreateProfile( userName: testBase.TestProfileOne.UserName, regionId: (int)testBase.TestProfileOne.Region, platformId: (int)testBase.TestProfileOne.Region); testBase.TestProfileOne.ProfileGuid = profile.ProfileGuid; } Assert.AreNotEqual(notExpected: Guid.Empty, actual: testBase.TestProfileOne.ProfileGuid); }
internal void AddProfiles() { using (var profileService = new ProfileService.ProfileServiceClient()) { profilebase.TestProfileOne.ProfileGuid = profileService .GetOrCreateProfile( userName: profilebase.TestProfileOne.UserName, platformId: (int)profilebase.TestProfileOne.Platform, regionId: (int)profilebase.TestProfileOne.Region).ProfileGuid; profilebase.TestProfileTwo.ProfileGuid = profileService .GetOrCreateProfile( userName: profilebase.TestProfileTwo.UserName, platformId: (int)profilebase.TestProfileTwo.Platform, regionId: (int)profilebase.TestProfileTwo.Region).ProfileGuid; } }
protected override bool AuthorizeCore(HttpContextBase httpContext) { if (httpContext == null) { throw new ArgumentNullException("httpContext"); } IPrincipal user = httpContext.User; if (!user.Identity.IsAuthenticated) { return false; } if (Users.Length > 0 && !Users.Split(',').Contains(user.Identity.Name, StringComparer.OrdinalIgnoreCase)) { return false; } if (Roles.Length > 0) { string [] roles = Roles.Split(','); var service = new ProfileService.ProfileServiceClient(); return service.IsUserInRoles(user.Identity.Name,roles); } return true; }
protected override bool AuthorizeCore(HttpContextBase httpContext) { if (httpContext == null) { throw new ArgumentNullException("httpContext"); } IPrincipal user = httpContext.User; if (!user.Identity.IsAuthenticated) { return(false); } if (Users.Length > 0 && !Users.Split(',').Contains(user.Identity.Name, StringComparer.OrdinalIgnoreCase)) { return(false); } if (Roles.Length > 0) { string [] roles = Roles.Split(','); var service = new ProfileService.ProfileServiceClient(); return(service.IsUserInRoles(user.Identity.Name, roles)); } return(true); }