public async Task <IActionResult> Edit(int id, [Bind("Id,ProjectId,SprintId,Description,Status,Estimated,Comments,Priority,Color")] UserStories userStories) { if (id != userStories.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(userStories); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserStoriesExists(userStories.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ProjectId"] = new SelectList(_context.Projects, "Id", "Description", userStories.ProjectId); ViewData["SprintId"] = new SelectList(_context.Sprints, "Id", "Description", userStories.SprintId); return(View(userStories)); }
public async Task CanChangeEmail() { // Arrange var emails = new ContosoEmailSender(); void ConfigureTestServices(IServiceCollection services) => services.SetupTestEmailSender(emails); var server = ServerFactory .WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices)); var client = server.CreateClient(); var newClient = server.CreateClient(); var failedClient = server.CreateClient(); var userName = $"{Guid.NewGuid()}@example.com"; var password = $"[PLACEHOLDER]-1a"; var newEmail = "*****@*****.**"; var index = await UserStories.RegisterNewUserAsync(client, userName, password); var email = await UserStories.SendUpdateEmailAsync(index, newEmail); // Act & Assert Assert.Equal(2, emails.SentEmails.Count); await UserStories.ConfirmEmailAsync(emails.SentEmails[1], client); // Verify can login with new email, fails with old await UserStories.LoginExistingUserAsync(newClient, newEmail, password); await UserStories.LoginFailsWithWrongPasswordAsync(failedClient, userName, password); }
public async Task CanRegisterAUserWithRequiredConfirmation() { // Arrange void ConfigureTestServices(IServiceCollection services) { services.Configure <IdentityOptions>(o => o.SignIn.RequireConfirmedAccount = true); }; var server = ServerFactory .WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices)); var client = server.CreateClient(); var client2 = server.CreateClient(); var userName = $"{Guid.NewGuid()}@example.com"; var password = $"[PLACEHOLDER]-1a"; // Act & Assert var register = await UserStories.RegisterNewUserAsyncWithConfirmation(client, userName, password); // Since we aren't confirmed yet, login should fail until we confirm await UserStories.LoginFailsWithWrongPasswordAsync(client, userName, password); await register.ClickConfirmLinkAsync(); await UserStories.LoginExistingUserAsync(client, userName, password); }
public async Task CanChangePassword() { // Arrange var principals = new List <ClaimsPrincipal>(); void ConfigureTestServices(IServiceCollection services) => services.SetupGetUserClaimsPrincipal(user => principals.Add(user), IdentityConstants.ApplicationScheme); var server = ServerFactory .WithWebHostBuilder(whb => whb.ConfigureTestServices(ConfigureTestServices)); var client = server.CreateClient(); var newClient = server.CreateClient(); var userName = $"{Guid.NewGuid()}@example.com"; var password = "******"; var newPassword = "******"; var index = await UserStories.RegisterNewUserAsync(client, userName, password); // Act 1 var changedPassword = await UserStories.ChangePasswordAsync(index, password, newPassword); // Assert 1 // RefreshSignIn generates a new security stamp claim AssertClaimsNotEqual(principals[0], principals[1], "AspNet.Identity.SecurityStamp"); // Act 2 await UserStories.LoginExistingUserAsync(newClient, userName, newPassword); // Assert 2 // Signing in again with a different client uses the same security stamp claim AssertClaimsEqual(principals[1], principals[2], "AspNet.Identity.SecurityStamp"); }
public async Task <IActionResult> Create(UserStories userStories) { userStories.Screen = _context.Screens.FirstOrDefault(s => s.ID == userStories.ScreenID); if (userStories.Screen != null) { try { _context.UserStories.Add(userStories); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserStoriesExists(userStories.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index), new { screenId = userStories.ScreenID })); } return(View(userStories)); }
public async Task CanLogInAfterConfirmingEmail_WithGlobalAuthorizeFilter() { // Arrange var emailSender = new ContosoEmailSender(); void ConfigureTestServices(IServiceCollection services) => services .SetupTestEmailSender(emailSender) .SetupEmailRequired() .SetupGlobalAuthorizeFilter(); var server = ServerFactory.WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices)); var client = server.CreateClient(); var newClient = server.CreateClient(); var userName = $"{Guid.NewGuid()}@example.com"; var password = $"[PLACEHOLDER]-1a"; var loggedIn = await UserStories.RegisterNewUserAsync(client, userName, password); // Act & Assert // Use a new client to simulate a new browser session. var email = Assert.Single(emailSender.SentEmails); await UserStories.ConfirmEmailAsync(email, newClient); await UserStories.LoginExistingUserAsync(newClient, userName, password); }
public async Task CanResendConfirmingEmail() { // Arrange var emailSender = new ContosoEmailSender(); void ConfigureTestServices(IServiceCollection services) => services .SetupTestEmailSender(emailSender) .SetupEmailRequired(); var server = ServerFactory.WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices)); var client = server.CreateClient(); var newClient = server.CreateClient(); var userName = $"{Guid.NewGuid()}@example.com"; var password = $"[PLACEHOLDER]-1a"; var loggedIn = await UserStories.RegisterNewUserAsync(client, userName, password); // Act & Assert // Use a new client to simulate a new browser session. await UserStories.ResendConfirmEmailAsync(server.CreateClient(), userName); Assert.Equal(2, emailSender.SentEmails.Count); var email = emailSender.SentEmails.Last(); await UserStories.ConfirmEmailAsync(email, newClient); }
public async Task CanRemoveExternalLogin() { // Arrange var principals = new List <ClaimsPrincipal>(); void ConfigureTestServices(IServiceCollection services) => services .SetupTestThirdPartyLogin() .SetupGetUserClaimsPrincipal(user => principals.Add(user), IdentityConstants.ApplicationScheme); var server = ServerFactory .WithWebHostBuilder(whb => whb.ConfigureTestServices(ConfigureTestServices)); var client = server.CreateClient(); var guid = Guid.NewGuid(); var userName = $"{guid}"; var email = $"{guid}@example.com"; // Act var index = await UserStories.RegisterNewUserAsync(client, email, "[PLACEHOLDER]-1a"); var linkLogin = await UserStories.LinkExternalLoginAsync(index, email); await UserStories.RemoveExternalLoginAsync(linkLogin, email); // RefreshSignIn generates a new security stamp claim AssertClaimsNotEqual(principals[0], principals[1], "AspNet.Identity.SecurityStamp"); }
public void CreateUstories(UserStories user) { display d = new display(); d.userstories.Add(user); d.SaveChanges(); }
public async Task UserNotLockedOut_AfterMaxFailedAccessAttempts_WithGlobalAuthorizeFilter() { // Arrange var emailSender = new ContosoEmailSender(); void ConfigureTestServices(IServiceCollection services) => services.SetupGlobalAuthorizeFilter().SetupMaxFailedAccessAttempts().SetupTestEmailSender(emailSender); var server = ServerFactory.WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices)); var client = server.CreateClient(); var newClient = server.CreateClient(); var userName = $"{Guid.NewGuid()}@example.com"; var password = $"[PLACEHOLDER]-1a"; var wrongPassword = $"[PLACEHOLDER]-1a-wrong"; await UserStories.RegisterNewUserAsync(client, userName, password); var registrationEmail = Assert.Single(emailSender.SentEmails); await UserStories.ConfirmEmailAsync(registrationEmail, client); // Act & Assert await UserStories.LoginFailsWithWrongPasswordAsync(newClient, userName, wrongPassword); }
public async Task CanRegisterWithASocialLoginProviderFromLoginWithConfirmationAndRealEmailSender() { // Arrange var emailSender = new ContosoEmailSender(); void ConfigureTestServices(IServiceCollection services) { services.SetupTestEmailSender(emailSender); services .Configure <IdentityOptions>(o => o.SignIn.RequireConfirmedAccount = true) .SetupTestThirdPartyLogin(); } var client = ServerFactory .WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices)) .CreateClient(); var guid = Guid.NewGuid(); var userName = $"{guid}"; var email = $"{guid}@example.com"; // Act & Assert await UserStories.RegisterNewUserWithSocialLoginWithConfirmationAsync(client, userName, email, hasRealEmailSender : true); Assert.Single(emailSender.SentEmails); }
public async Task CanLogInWithTwoFactorAuthentication_WithGlobalAuthorizeFilter() { // Arrange void ConfigureTestServices(IServiceCollection services) => services.SetupGlobalAuthorizeFilter(); var server = ServerFactory .WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices)); var client = server.CreateClient(); var newClient = server.CreateClient(); var userName = $"{Guid.NewGuid()}@example.com"; var password = $"[PLACEHOLDER]-1a"; var loggedIn = await UserStories.RegisterNewUserAsync(client, userName, password); var showRecoveryCodes = await UserStories.EnableTwoFactorAuthentication(loggedIn); var twoFactorKey = showRecoveryCodes.Context.AuthenticatorKey; // Act & Assert // Use a new client to simulate a new browser session. await UserStories.LoginExistingUser2FaAsync(newClient, userName, password, twoFactorKey); }
public async Task <Response <UserStories> > CreateUserHistoryAsync(UserStories userStories) { var response = new Response <UserStories>(); try { var firebase = new FirebaseClient(ConfigurationManager.AppSettings[Constant.Url]); var createUserStory = await firebase.Child(Constant.UserStory).PostAsync(userStories); userStories.Uid = createUserStory.Key; if (createUserStory.Key == null) { response.IsSuccess = false; response.Message = $"{Messages.NoSePudoCrearLaHistoriadeUsuario}"; return(response); } await firebase.Child(Constant.UserStory).Child(createUserStory.Key).PutAsync(userStories); response.IsSuccess = true; response.Data = null; } catch (Exception ex) { response.IsSuccess = false; response.Message = $"{ex.Message}"; } return(response); }
public async Task CanResetPassword_WithGlobalAuthorizeFilter() { // Arrange var emailSender = new ContosoEmailSender(); void ConfigureTestServices(IServiceCollection services) => services.SetupGlobalAuthorizeFilter().SetupTestEmailSender(emailSender); var server = ServerFactory.WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices)); var client = server.CreateClient(); var resetPasswordClient = server.CreateClient(); var newClient = server.CreateClient(); var userName = $"{Guid.NewGuid()}@example.com"; var password = $"[PLACEHOLDER]-1a"; var newPassword = $"[PLACEHOLDER]-1a-updated"; await UserStories.RegisterNewUserAsync(client, userName, password); var registrationEmail = Assert.Single(emailSender.SentEmails); await UserStories.ConfirmEmailAsync(registrationEmail, client); // Act & Assert await UserStories.ForgotPasswordAsync(resetPasswordClient, userName); Assert.Equal(2, emailSender.SentEmails.Count); var email = emailSender.SentEmails[1]; await UserStories.ResetPasswordAsync(resetPasswordClient, email, userName, newPassword); await UserStories.LoginExistingUserAsync(newClient, userName, newPassword); }
public ResourceClassTests() { money = new Money(); prototype = new Prototypes(); usecase = new UseCases(); userstory = new UserStories(); }
public async Task CanDownloadPersonalData(bool twoFactor, bool social) { // Arrange void ConfigureTestServices(IServiceCollection services) => services.SetupTestThirdPartyLogin(); var client = ServerFactory .WithWebHostBuilder(whb => whb.ConfigureTestServices(ConfigureTestServices)) .CreateClient(); var userName = $"{Guid.NewGuid()}@example.com"; var guid = Guid.NewGuid(); var email = userName; var index = social ? await UserStories.RegisterNewUserWithSocialLoginAsync(client, userName, email) : await UserStories.RegisterNewUserAsync(client, email, "[PLACEHOLDER]-1a"); if (twoFactor) { await UserStories.EnableTwoFactorAuthentication(index); } // Act & Assert var jsonData = await UserStories.DownloadPersonalData(index, userName); Assert.NotNull(jsonData); Assert.True(jsonData.ContainsKey("Id")); Assert.NotNull(jsonData["Id"]); Assert.True(jsonData.ContainsKey("UserName")); Assert.Equal(userName, (string)jsonData["UserName"]); Assert.True(jsonData.ContainsKey("Email")); Assert.Equal(userName, (string)jsonData["Email"]); Assert.True(jsonData.ContainsKey("EmailConfirmed")); Assert.False((bool)jsonData["EmailConfirmed"]); Assert.True(jsonData.ContainsKey("PhoneNumber")); Assert.Equal("null", (string)jsonData["PhoneNumber"]); Assert.True(jsonData.ContainsKey("PhoneNumberConfirmed")); Assert.False((bool)jsonData["PhoneNumberConfirmed"]); Assert.Equal(twoFactor, (bool)jsonData["TwoFactorEnabled"]); if (twoFactor) { Assert.NotNull(jsonData["Authenticator Key"]); } else { Assert.Null((string)jsonData["Authenticator Key"]); } if (social) { Assert.Equal(userName, (string)jsonData["Contoso external login provider key"]); } else { Assert.Null((string)jsonData["Contoso external login provider key"]); } }
public void Delete(int id) { display d = new display(); UserStories us = SearchById(id, d); d.userstories.Remove(us); d.SaveChanges(); }
public Task <UserStory> FindUserStoryById(long userStoryId) { return(UserStories .Include(userStory => userStory.Rules) .ThenInclude(rule => rule.Examples) .Include(userStory => userStory.Questions) .SingleOrDefaultAsync(userStory => userStory.Id == userStoryId)); }
public async Task LoadIssuesAsync() { AssignedUserStories stories = await JiraBackend.Instance.Client.GetAssignedUserStoriesAsync(); foreach (var issue in stories.issues) { UserStories.Add(new UserStoryModel(issue)); } }
public void Edit(UserStories ua, int id) { display d = new display(); UserStories us = SearchById(id, d); us.Story = ua.Story; us.ProId = ua.ProId; d.SaveChanges(); }
public async Task <IHttpActionResult> CreateUserHistory(UserStories userStories) { var response = await _userStory.CreateUserHistoryAsync(userStories); if (response.IsSuccess) { return(Ok(response)); } return(BadRequest(response.Message)); }
public StoriesViewmodel(UserStories selectedUser, List <UserStories> userStories) { LeftSideStatusTappedCommand = new Command <UserStories>(MoveToPreviousStory); RightSideStatusTappedCommand = new Command <UserStories>(MoveToNextStory); CurentStoriesChangedCommand = new Command(CurentStoriesChanged); SeeMoreCommand = new Command(SeeMore); Stories = userStories; CurrentUser = selectedUser; StartTimer(); }
public async Task <IActionResult> Create([Bind("Id,ProjectId,SprintId,Description,Status,Estimated,Comments,Priority,Color")] UserStories userStories) { if (ModelState.IsValid) { _context.Add(userStories); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ProjectId"] = new SelectList(_context.Projects, "Id", "Description", userStories.ProjectId); ViewData["SprintId"] = new SelectList(_context.Sprints, "Id", "Description", userStories.SprintId); return(View(userStories)); }
public async Task AuthenticatedUserCanAccessAuthorizedPages(string url) { // Arrange var client = ServerFactory .CreateClient(); await UserStories.RegisterNewUserAsync(client); // Act var response = await client.GetAsync(url); // Assert await ResponseAssert.IsHtmlDocumentAsync(response); }
public async Task CannotEnableTwoFactorAuthenticationWithoutCookieConsent() { // Arrange var client = ServerFactory .CreateClient(); var userName = $"{Guid.NewGuid()}@example.com"; var password = $"[PLACEHOLDER]-1a"; var index = await UserStories.RegisterNewUserAsync(client, userName, password); // Act & Assert Assert.Null(await UserStories.EnableTwoFactorAuthentication(index, consent: false)); }
public async Task CanDeleteUser() { // Arrange var client = ServerFactory .CreateClient(); var userName = $"{Guid.NewGuid()}@example.com"; var password = $"[PLACEHOLDER]-1a"; var index = await UserStories.RegisterNewUserAsync(client, userName, password); // Act & Assert await UserStories.DeleteUser(index, password); }
public async Task GetOnDownloadPersonalData_ReturnsNotFound() { // Arrange var client = ServerFactory .CreateClient(); await UserStories.RegisterNewUserAsync(client); // Act var response = await client.GetAsync("/Identity/Account/Manage/DownloadPersonalData"); // Assert Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); }
/// <summary> /// Entfernt ein Item aus der Datenbank /// </summary> /// <param name="item"></param> public void RemoveItem(ItemBase item) { foreach (ItemControl ic in item.Representations) { ic.RemoveFromSurface(); } if (item.GetType() == typeof(UserStory)) { UserStories.Remove(item as UserStory); } if (item.GetType() == typeof(Epic)) { Epics.Remove(item as Epic); } }
public async Task CanLogInWithAPreviouslyRegisteredUser() { // Arrange var client = ServerFactory.CreateClient(); var newClient = ServerFactory.CreateClient(); var userName = $"{Guid.NewGuid()}@example.com"; var password = $"[PLACEHOLDER]-1a"; // Act & Assert await UserStories.RegisterNewUserAsync(client, userName, password); // Use a new client to simulate a new browser session. await UserStories.LoginExistingUserAsync(newClient, userName, password); }
public async Task <TwoFactorAuthentication> ClickTwoFactorLinkAsync(bool consent = true) { // Accept cookie consent if requested if (consent) { await UserStories.AcceptCookiePolicy(Client); } var goToTwoFactor = await Client.GetAsync(_twoFactorLink.Href); var twoFactor = await ResponseAssert.IsHtmlDocumentAsync(goToTwoFactor); var context = consent ? Context.WithCookieConsent() : Context; return(new TwoFactorAuthentication(Client, twoFactor, context)); }