public async void CanCreateUser() { var random = DateTime.Now.ToString("MMddyyhhmmssfff"); var user = new User(Guid.Empty , $"{DataGenerator.GenerateRandomName(1).FirstOrDefault()?.Item1}-{random}" , $"{DataGenerator.GenerateRandomName(1).FirstOrDefault().Item1}-{random}@testing.com" , true , _passwordStorage.HashPassword(new User(), "testdb99!!") , Guid.NewGuid().ToString() , true , true , false , false , 0 , DateTime.UtcNow , DateTime.UtcNow); user.Profile = new UserProfile(user.Id , DataGenerator.GenerateRandomName(1).FirstOrDefault().Item1 , DataGenerator.GenerateRandomName(1).FirstOrDefault().Item2 , Guid.Parse("5ebf5cca-df92-49c6-ae5f-f3c9670bf9d3") , Guid.Parse("2af6ff6c-8bb8-46f0-b27e-81def1b76b64") , Guid.Parse("8a29a4ab-62a7-4a06-b2fa-46a40f449a84")); user.Claims.Add(new UserClaim(user.Id, "http://schemas.microsoft.com/ws/2008/06/identity/claims/role", "USER")); var id = await _administrationManager.Create(user); Assert.True(id != Guid.Empty, "Failed to create user"); }
public async void CanCreateUser() { var random = DateTime.Now.ToString("MMddyyhhmmssfff"); var item = new UserDao(Guid.NewGuid() , $"{DataGenerator.GenerateRandomName(1).FirstOrDefault()?.Item1}-{random}" , $"{DataGenerator.GenerateRandomName(1).FirstOrDefault().Item1}-{random}@testing.com" , true , _passwordStorage.HashPassword(new UserDao(), "testdb99!!") , Guid.NewGuid().ToString() , true, true, false, false, 0 , DateTime.UtcNow, DateTime.UtcNow); var result = await item.InsertAsync(ConnectionString); Assert.True(result != null && result.Id != Guid.Empty, "Failed to create user"); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } string pw = Gebruiker.PASSWORD; var hashed = PasswordStorage.HashPassword(Encoding.UTF8.GetBytes(pw), PasswordStorage.GenerateSalt(), 50000); pw = Convert.ToBase64String(hashed); Gebruiker.PASSWORD = pw; _context.Users.Add(Gebruiker); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); }
public async void CanCreateUser() { var random = DateTime.Now.ToString("MMddyyhhmmssfff"); using (var db = new PRACTISEV1DB()) { try { db.BeginTransaction(); var guid = Guid.NewGuid(); var result = await db.Administration.Users .Value(c => c.Id, Guid.NewGuid()) .Value(c => c.UserName, $"{DataGenerator.GenerateRandomName(1).FirstOrDefault()?.Item1}-{random}") .Value(c => c.Email, $"{DataGenerator.GenerateRandomName(1).FirstOrDefault().Item1}-{random}@testing.com") .Value(c => c.PasswordHash, _passwordStorage.HashPassword(new AdministrationSchema.User(), "testdb99!!")) .Value(c => c.SecurityStamp, Guid.NewGuid().ToString()) .Value(c => c.PhoneNumber, "123-456-7890") .Value(c => c.EmailConfirmed, true) .Value(c => c.PhoneNumberConfirmed, true) .Value(c => c.MobileNumberConfirmed, true) .Value(c => c.LockoutEnabled, false) .Value(c => c.AccessFailedCount, 0) .Value(c => c.TwoFactorEnabled, false) .Value(c => c.CreatedOn, DateTime.UtcNow) .InsertAsync(); db.CommitTransaction(); Assert.True(result == 1, "Failed to create user"); } catch (Exception ex) { db.RollbackTransaction(); throw ex; } } }